Delete a draft invoice
const url = 'https://api.emite.cr/v1/invoices/example';const options = {method: 'DELETE', 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 DELETE \ --url https://api.emite.cr/v1/invoices/example \ --header 'Authorization: Bearer <token>'Permanently deletes a draft (status="draft") and all its child rows (lines, taxes, discounts, exonerations, payment methods — cascading via FK). Only a draft WITHOUT a number: one that already has a consecutivo (allocated by a signature that failed afterwards) returns 409 INVOICE_HAS_FISCAL_NUMBER — deleting it would leave a hole in the numbering; sign/submit it instead, and void it with a credit note if unwanted. Returns 409 INVOICE_NOT_DRAFT if the invoice has been signed or submitted — those documents cannot be deleted (Hacienda v4.4 requires a Nota de Crédito to revoke an accepted invoice). Returns 404 if the invoice does not exist or belongs to a different tenant.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Invoice UUID
Responses
Section titled “Responses”Draft deleted.
Invoice not found.
Invoice is not a draft (INVOICE_NOT_DRAFT), or is a draft that already has a consecutivo (INVOICE_HAS_FISCAL_NUMBER).