Skip to content

List import batches for the current scope

GET
/v1/documents/imports
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.

Media typeapplication/json
Array<object>
object
id
required

Id of the batch.

string format: uuid
environment
required

Environment the batch belongs to — that of the session or API key that created it. Its documents are written there.

string
Allowed values: sandbox production
mode
required

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).

string
Allowed values: validate commit
status
required

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.

string
Allowed values: pending processing completed partial failed
sourceFilename
required

Name of the ZIP uploaded with the batch; null when only XML files were.

string
nullable
totalFiles
required

XML files in the batch. It grows while a ZIP is being extracted, by one per .xml entry.

number
processedCount
required

Files processed so far.

number
succeededCount
required

Files with status imported (saved or, in a dry run, saveable).

number
skippedCount
required

Files with status skipped.

number
failedCount
required

Files with status failed.

number
createdAt
required

When the batch was created.

string format: date-time
completedAt
required

When the batch finished processing; null while it has not.

string format: date-time
nullable
items

One entry per XML file, oldest first. Present when reading, starting or committing one batch; absent from the list.

Array<object>
object
id
required

Id of the item.

string format: uuid
originalFilename
required

Name of the XML file; for an entry of a ZIP, its name inside the archive.

string
status
required

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).

string
Allowed values: pending imported skipped failed
kind
required

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.

string
nullable
Allowed values: document response unknown
direction
required

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.

string
nullable
Allowed values: issued received
detectedDocType
required

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.

string
nullable
detectedClave
required

The 50-digit clave read from the XML; null when not detected.

string
nullable
resultCode
required

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.

string
nullable
Allowed values: IMPORTED DUPLICATE_CLAVE NOT_TENANT_DOCUMENT RECEPTION_LIMIT_REACHED RESPONSE_PAIRED RESPONSE_NO_MATCH MENSAJE_RECEPTOR_SKIPPED UNSUPPORTED_ROOT PARSE_ERROR INVALID_CLAVE PERSIST_ERROR
errorMessage
required

Technical detail of a failure, in English; null otherwise.

string
nullable
resultInvoiceId
required

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.

string format: uuid
nullable
resultReceivedDocumentId
required

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.

string format: uuid
nullable
processedAt
required

When the file was processed; null while pending.

string format: date-time
nullable
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"
}
]
}
]