Skip to content

Create an import batch and get presigned upload URLs

POST
/v1/documents/imports
curl --request POST \
--url https://api.emite.cr/v1/documents/imports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "files": [ { "filename": "factura-001.xml", "contentType": "application/xml", "size": 12048 } ] }'

Creates a dry-run (validate) import batch in the environment of the session or API key and returns one presigned PUT URL per file, so each XML or ZIP is uploaded straight to object storage. Once every file is uploaded, call POST /v1/documents/imports/{id}/start with the filename and key of each target.

Media typeapplication/json
object
files
required

The files to upload. The response returns one upload target per file, in the same order: a storage key and a presigned uploadUrl valid for 15 minutes.

Array<object>
<= 5000 items
object
filename
required

Name of the file to upload, up to 255 characters. A name ending in .zip marks a ZIP archive whose .xml entries are extracted and imported one by one; any other name is processed as a single XML document.

string
Example
factura-001.xml
contentType

MIME type the file will be uploaded with. The upload URL is signed for it, so the PUT must send the same Content-Type header. Defaults to application/zip for a .zip name and to application/xml otherwise.

string
Example
application/xml
size
required

Byte size of the file to upload.

number
Example
12048
Media typeapplication/json
object
importId
required

Id of the new batch, for start, commit and reading it.

string format: uuid
mode
required

Always validate: a new batch starts as a dry run.

string
Allowed values: validate commit
targets
required

One upload target per file of the request, in the same order.

Array<object>
object
filename
required

The filename of the file, as sent when the batch was created.

string
key
required

Storage key of the upload. Send it back, with the filename, in POST /v1/documents/imports/{id}/start once the file is uploaded.

string
uploadUrl
required

Presigned URL to upload the file to with an HTTP PUT of its raw bytes, valid for 15 minutes. The Content-Type header must be the one the file was declared with (application/zip for a .zip name and application/xml otherwise, when none was given). The bytes go straight to object storage, never through the API.

string format: uri
Example
{
"mode": "validate",
"targets": [
{
"filename": "factura-001.xml",
"key": "tenants/<id>/sandbox/imports/<batch>/0-factura-001.xml"
}
]
}