Upload email attachments to a draft invoice
const url = 'https://api.emite.cr/v1/invoices/example/attachments';const form = new FormData();form.append('files', 'file');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.emite.cr/v1/invoices/example/attachments \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form files=@fileMultipart upload (files field, one request for all files). Attaches extra files that travel with the invoice email once Hacienda accepts it. Allowed only while the invoice has not been submitted (status draft/error). Validates each file's MIME (against a whitelist, by signature — not the declared content-type) and size, and the combined cap of 5 attachments (tenant-fixed + per-invoice). Returns the created attachments.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Invoice UUID
Request Bodyrequired
Section titled “Request Bodyrequired”object
Responses
Section titled “Responses”object
Attachment id.
Original (sanitized) filename, shown in the list and used in the email.
MIME type.
Size in bytes.
When the file was uploaded (ISO 8601).
Tenant-fixed only: when true the attachment cannot be omitted from an individual invoice.
Examplegenerated
[ { "id": "example", "filename": "example", "contentType": "example", "sizeBytes": 1, "createdAt": "example", "isMandatory": true }]No file, disallowed MIME (ATTACHMENT_MIME_NOT_ALLOWED), too large (ATTACHMENT_TOO_LARGE), corrupt content (ATTACHMENT_CONTENT_INVALID), or over the combined limit (ATTACHMENT_LIMIT_REACHED).
Invoice not found.
Invoice already submitted/accepted (INVOICE_NOT_ATTACHABLE).