Download an invoice XML
const url = 'https://api.emite.cr/v1/invoices/example/xml?type=unsigned&disposition=attachment';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/invoices/example/xml?type=unsigned&disposition=attachment' \ --header 'Authorization: Bearer <token>'Requires invoices:export (reading a document is invoices:read; taking its XML out is an export). Returns one of three XML documents. unsigned is the v4.4 XML before XAdES signing, written when the document is signed; signed is the same XML with the XAdES-EPES signature applied (the fiscal document submitted to Hacienda); hacienda-response is Hacienda's answer (MensajeHacienda) with its verdict, stored when a status check — the background poll or GET /v1/hacienda/status/{clave} — sees the document accepted or rejected. A document imported from XML has no unsigned. Each download is recorded in the audit log as invoice.downloaded.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Invoice UUID
Query Parameters
Section titled “Query Parameters”Which XML artifact to return. Defaults to signed.
Content-Disposition: attachment (default) downloads, inline previews in-browser.
Responses
Section titled “Responses”The XML file, named after the document's consecutivo: <consecutivo>.xml for signed, <consecutivo>-unsigned.xml and <consecutivo>-hacienda-response.xml for the others.
Headers
Section titled “Headers”attachment (default) or inline, as disposition asks, with the file name.
Invoice not found, or that XML does not exist: a draft has neither unsigned nor signed (both are written when it is signed), hacienda-response exists once the verdict is in, and an unknown type matches nothing.