Limai Docs
API ReferenceDocument Processing

Get Upload URL

Request a pre-signed URL and file ID for secure document upload.

GET/api/v1/document/{extractionSchemaId}/get-url

Request 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

NameTypeInRequiredDescription
extractionSchemaIdstringpathYesThe 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.
filenamestringqueryYesThe original filename of the document. Used for file type detection and storage.
allowDuplicatebooleanqueryNoSet 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

Response200
{
  "url": "https://s3.amazonaws.com/bucket/path?AWSAccessKeyId=...",
  "fileId": "file_abc123def456",
  "fileName": "document.pdf",
  "isDuplicate": false,
  "modelId": "dep_abc123",
  "viaDeploymentId": "dpl_prod01"
}

Response Fields

FieldTypeDescription
urlstringPre-signed upload URL. Temporary and expires after a short period. Empty when the content is a duplicate.
fileIdstringUnique file identifier. Use this in subsequent API calls. For a duplicate, the identifier of the document the project already stores.
fileNamestringThe stored document's name. Returned with a duplicate.
isDuplicatebooleanWhether the content is already stored in the project.
modelIdstringThe model the request resolved to.
viaDeploymentIdstring | nullThe 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.

Response200
{
  "url": "",
  "fileId": "file_abc123def456",
  "fileName": "document.pdf",
  "isDuplicate": true,
  "deploymentId": "dep_abc123",
  "sameModel": true,
  "modelId": "dep_abc123",
  "viaDeploymentId": "dpl_prod01"
}
FieldTypeDescription
deploymentIdstringThe 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.
sameModelbooleanWhether the existing document belongs to the model this request addressed.

Error Responses

Filename missing:

Response400
{
  "error": "Missing filename query parameter"
}

allowDuplicate set to anything other than true or false:

Response400
{
  "error": "allowDuplicate must be true or false"
}

On this page