Create an import batch and get presigned upload URLs
const url = 'https://api.emite.cr/v1/documents/imports';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"files":[{"filename":"factura-001.xml","contentType":"application/xml","size":12048}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
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.
object
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.
Example
factura-001.xmlMIME 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.
Example
application/xmlByte size of the file to upload.
Example
12048Responses
Section titled “Responses”object
Id of the new batch, for start, commit and reading it.
Always validate: a new batch starts as a dry run.
One upload target per file of the request, in the same order.
object
The filename of the file, as sent when the batch was created.
Storage key of the upload. Send it back, with the filename, in POST /v1/documents/imports/{id}/start once the file is uploaded.
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.
Example
{ "mode": "validate", "targets": [ { "filename": "factura-001.xml", "key": "tenants/<id>/sandbox/imports/<batch>/0-factura-001.xml" } ]}