Download purchase invoice XML
GET /api/v1/facturas-compra/{clave}/xml
Returns the original signed XML (XAdES) of the purchase invoice, bit-for-bit identical to what was sent to Hacienda. Same behavior as GET /facturas/{clave}/xml, applied to the 08-type key space.
As of v1.5 the purchase invoice has its own signed XML, which was previously missing — only the PDF was available.
Authentication
| Attribute | Value |
|---|---|
| Scheme | API key (X-Api-Key) |
| Required scope | facturas-compra:read |
Response
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Disposition: attachment; filename="50615012600310112345600100001080000000123456789012_Firmado.xml"(XAdES XML)
When to use it
- Tax audits — the signed XML is the official evidence before Hacienda (Costa Rica’s tax authority) of the self-invoice issued to the supplier.
- Syncing with accounting systems that consume XML.
- Signature verification by third parties (experts, oversight bodies, etc.).
Notes
- Right after issuance, this endpoint can return
404for a few seconds. Signing and uploading the XML happen in the background, same as for sales invoices — see Download XML. - If the purchase invoice ended up in
errorstatus and was never signed, the404is permanent. - The acknowledgment signed by Hacienda is a different document, downloaded separately: see Download the Hacienda message for purchase invoices.
Errors
| Code | Meaning |
|---|---|
404 Not Found | The key doesn’t exist, exists but isn’t of type 08, or the XML hasn’t been generated yet. |