Get Upload URL
Request a pre-signed URL and file ID for secure document upload.
/api/v1/document/{extractionSchemaId}/get-urlRequest a pre-signed URL for uploading a file to cloud storage. Returns both the upload URL and a fileId that you will use in subsequent processing requests.
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
extractionSchemaId | string | path | Yes | The model's ID, the ID of a deployment that points at it, or the model's extraction schema ID. The extraction schema ID is returned when listing a project's deployments, and is also shown at the bottom of the data page in the dashboard. |
filename | string | query | Yes | The original filename of the document. Used for file type detection and storage. |
allowDuplicate | boolean | query | No | Set to true to skip duplicate detection and create a second document for content the project already stores. Omitting it is the same as false. |
Duplicate Detection
The platform hashes the uploaded content (SHA-256) and looks for a file in the same project with that hash whose status is neither FAILED nor UPLOADING. On a match no new document is created: the response carries the existing file's fileId and fileName, isDuplicate is true, and url is an empty string, so there is nothing to upload.
isDuplicate means the document is already stored in the project. It does not mean the document has been extracted. To extract a document that already exists, pass its fileId to one of the processing endpoints.
With allowDuplicate=true the hash lookup is skipped and a genuine second document is created, with a new fileId, a pre-signed upload URL, and isDuplicate set to false. The new document records the same content hash, so a later request with detection on matches the most recent copy.
Request
const response = await fetch(
`https://app.limai.io/api/v1/document/${SCHEMA_ID}/get-url?filename=${filename}`,
{
headers: { "Authorization": `Bearer ${API_TOKEN}` }
}
)
const { url, fileId } = await response.json()Response
{
"url": "https://s3.amazonaws.com/bucket/path?AWSAccessKeyId=...",
"fileId": "file_abc123def456",
"fileName": "document.pdf",
"isDuplicate": false,
"modelId": "dep_abc123",
"viaDeploymentId": "dpl_prod01"
}Response Fields
| Field | Type | Description |
|---|---|---|
url | string | Pre-signed upload URL. Temporary and expires after a short period. Empty when the content is a duplicate. |
fileId | string | Unique file identifier. Use this in subsequent API calls. For a duplicate, the identifier of the document the project already stores. |
fileName | string | The stored document's name. Returned with a duplicate. |
isDuplicate | boolean | Whether the content is already stored in the project. |
modelId | string | The model the request resolved to. |
viaDeploymentId | string | null | The deployment the request arrived through, or null when the request named the model directly. |
Duplicate Response
A duplicate response carries two extra fields naming where the stored document lives.
{
"url": "",
"fileId": "file_abc123def456",
"fileName": "document.pdf",
"isDuplicate": true,
"deploymentId": "dep_abc123",
"sameModel": true,
"modelId": "dep_abc123",
"viaDeploymentId": "dpl_prod01"
}| Field | Type | Description |
|---|---|---|
deploymentId | string | The model the existing document belongs to. The lookup prefers the addressed model and otherwise falls back to any model in the project, so this is not always modelId. |
sameModel | boolean | Whether the existing document belongs to the model this request addressed. |
Error Responses
Filename missing:
{
"error": "Missing filename query parameter"
}allowDuplicate set to anything other than true or false:
{
"error": "allowDuplicate must be true or false"
}