Export the (filtered) drafts list as a spreadsheet
const url = 'https://api.emite.cr/v1/drafts/export?q=0010001&from=2026-01-01&to=2026-12-31&fechaEmisionFrom=2026-10-01&fechaEmisionTo=2026-10-31&sort=createdAt&order=asc&page=1&pageSize=25&format=xlsx';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/drafts/export?q=0010001&from=2026-01-01&to=2026-12-31&fechaEmisionFrom=2026-10-01&fechaEmisionTo=2026-10-31&sort=createdAt&order=asc&page=1&pageSize=25&format=xlsx' \ --header 'Authorization: Bearer <token>'The cross-env drafts listing as a file, under the same filters as GET /v1/drafts. format=xlsx (default) or csv; page/pageSize are ignored. The Ambiente column earns its place here — this listing spans both environments, so it is the only way to tell a stale sandbox draft from a real one in the file. Capped at 25000 rows, with X-Export-Truncated: true when the cap cut the set. Recorded as invoice.exported.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Example
0010001Free-text search. Matches against consecutivo, clave, and the receiver name (case-insensitive substring). Trimmed; empty strings are ignored.
Invoice lifecycle status. Repeat the param to filter by multiple values.
ATV-reported status. Repeat the param to filter by multiple values.
Hacienda document type code (01-10). Repeatable.
Filter to invoices issued to a specific persisted party (tenant_parties.id).
Exact-match filter on the caller-owned externalReference (business-level idempotency id, e.g. a POS ticket uuid). For reconciliation after any disaster recovery: ask instead of guessing. Attempt suffixes (:2, :3) are distinct values — query each explicitly.
Example
2026-01-01Lower bound for createdAt — when the RECORD was created (a draft can be issued days later, an imported XML is created the day it is imported). For a fiscal period use fechaEmisionFrom/fechaEmisionTo. A bare YYYY-MM-DD is a Costa Rica calendar day (midnight CR = 06:00Z); a full ISO 8601 instant is used verbatim. Inclusive. Combine with to for a range; omit either side for an open bound.
Example
2026-12-31Upper bound for createdAt. A bare YYYY-MM-DD covers that whole Costa Rica calendar day (up to, but excluding, midnight CR of the next day) — so to=2026-08-31 includes a document created 8pm CR on the 31st. A full ISO 8601 instant is an inclusive cut at that exact instant.
Example
2026-10-01Lower bound for fechaEmision — the date the document was ISSUED: the one its clave and its XML declare and its PDF prints, and the one /v1/reports/* and the dashboard count by. A bare YYYY-MM-DD is a Costa Rica calendar day; a full ISO 8601 instant is used verbatim. Inclusive. A document without a number (a draft) has no emission date and never matches.
Example
2026-10-31Upper bound for fechaEmision. A bare YYYY-MM-DD covers that whole Costa Rica calendar day; a full ISO 8601 instant is an inclusive cut at that exact instant.
Sort key. Default createdAt. fechaEmision orders by the date the document was issued, documents without one (drafts) last in either direction.
Sort direction. Default desc.
Example
11-indexed page number. Default 1.
Example
25Rows per page. Default 25, max 100.
File format: xlsx (the default) or csv; any other value is 400.
Responses
Section titled “Responses”The file, named borradores_<YYYY-MM-DD>.xlsx or .csv: an Excel workbook with one sheet, or CSV (UTF-8 with a byte-order mark, comma-separated, CRLF line endings) with the same columns. Column headers are in Spanish; dates and times are Costa Rica time. Read X-Export-Truncated before treating the file as complete.
Headers
Section titled “Headers”attachment; filename="borradores_<YYYY-MM-DD>.<xlsx|csv>", dated with the Costa Rica day of the export.
true when the 25000-row cap cut the set short, false otherwise.
Rows written to the file.