List import batches for the current scope
const url = 'https://api.emite.cr/v1/documents/imports';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.emite.cr/v1/documents/imports \ --header 'Authorization: Bearer <token>'The 50 most recent import batches of the company in the environment of the session or API key, newest first, with their counters but without the per-file items (read one batch for those). Requires documents:read.
Authorizations
Section titled “Authorizations”Responses
Section titled “Responses”object
Id of the batch.
Environment the batch belongs to — that of the session or API key that created it. Its documents are written there.
What processing the batch does: validate — a dry run, which parses and classifies each file without writing anything; commit — the files are persisted (after POST /v1/documents/imports/{id}/commit).
Where the batch is: pending — created, waiting for start; processing — files being processed in the background; completed — every file processed without failures; partial — processed, with at least one failed file; failed — processed, and every file failed.
Name of the ZIP uploaded with the batch; null when only XML files were.
XML files in the batch. It grows while a ZIP is being extracted, by one per .xml entry.
Files processed so far.
Files with status imported (saved or, in a dry run, saveable).
Files with status skipped.
Files with status failed.
When the batch was created.
When the batch finished processing; null while it has not.
One entry per XML file, oldest first. Present when reading, starting or committing one batch; absent from the list.
object
Id of the item.
Name of the XML file; for an entry of a ZIP, its name inside the archive.
Outcome of the file: pending — not processed yet; imported — saved (in a validate batch, it would be saved by the commit); skipped — left out without an error (a duplicate, a document of another company…, see resultCode); failed — it could not be processed (see resultCode and errorMessage).
What the XML is: document — an electronic document (invoice, ticket, note…); response — a message about one (Hacienda's MensajeHacienda or a MensajeReceptor); unknown — neither. Null until the file is processed.
Which side of the document the company is on: issued — it is the issuer (Emisor); received — it is the receiver (Receptor), a purchase. Null until it is known.
Hacienda document type (TipoDocumento) read from the XML: 01 invoice, 02 debit note, 03 credit note, 04 ticket, 05–07 receptor messages, 08 purchase invoice, 09 export invoice, 10 payment receipt. Null when not detected.
The 50-digit clave read from the XML; null when not detected.
Why the file ended as it did, a closed vocabulary:
IMPORTED— saved (or, in a dry run, would be).RESPONSE_PAIRED— a response matched to a document already in EmiteCR, whose status it updated.DUPLICATE_CLAVE— a document with that clave already exists in this environment (skipped).NOT_TENANT_DOCUMENT— the company is neither its issuer nor its receiver (skipped).RECEPTION_LIMIT_REACHED— the monthly cap of received documents was reached (skipped).RESPONSE_NO_MATCH— a response without a matching document (skipped).MENSAJE_RECEPTOR_SKIPPED— a MensajeReceptor with an unrecognized<Mensaje>(skipped).UNSUPPORTED_ROOT— an XML that is not a Hacienda document (failed).PARSE_ERROR— empty, unreadable or malformed (failed).INVALID_CLAVE— the clave is not 50 digits (failed).PERSIST_ERROR— it could not be saved (failed).
Null while pending.
Technical detail of a failure, in English; null otherwise.
Id of the invoice the file became (an issued document), or the existing invoice a response was paired with; null otherwise, and in a dry run.
Id of the received document the file became (a purchase), or the existing one a response was paired with; null otherwise, and in a dry run.
When the file was processed; null while pending.
Example
[ { "environment": "sandbox", "mode": "validate", "status": "pending", "sourceFilename": "xml-junio.zip", "items": [ { "originalFilename": "factura-001.xml", "status": "pending", "kind": "document", "direction": "issued", "detectedDocType": "01", "resultCode": "IMPORTED" } ] }]