Skip to content

Export the (filtered) drafts list as a spreadsheet

GET
/v1/drafts/export
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.

q
string
Example
0010001

Free-text search. Matches against consecutivo, clave, and the receiver name (case-insensitive substring). Trimmed; empty strings are ignored.

status
Array<string>
Allowed values: draft signed submitted accepted rejected error

Invoice lifecycle status. Repeat the param to filter by multiple values.

haciendaStatus
Array<string>
Allowed values: recibido procesando aceptado rechazado error

ATV-reported status. Repeat the param to filter by multiple values.

docType
Array<string>
Allowed values: 01 02 03 04 05 06 07 08 09 10

Hacienda document type code (01-10). Repeatable.

receiverPartyId
string

Filter to invoices issued to a specific persisted party (tenant_parties.id).

externalReference
string

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.

from
string
Example
2026-01-01

Lower 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.

to
string
Example
2026-12-31

Upper 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.

fechaEmisionFrom
string
Example
2026-10-01

Lower 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.

fechaEmisionTo
string
Example
2026-10-31

Upper 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
string
default: createdAt
Allowed values: createdAt fechaEmision consecutivo total

Sort key. Default createdAt. fechaEmision orders by the date the document was issued, documents without one (drafts) last in either direction.

order
string
default: desc
Allowed values: asc desc

Sort direction. Default desc.

page
number
Example
1

1-indexed page number. Default 1.

pageSize
number
Example
25

Rows per page. Default 25, max 100.

format
string
Allowed values: xlsx csv

File format: xlsx (the default) or csv; any other value is 400.

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.

string format: binary
Content-Disposition
string

attachment; filename="borradores_<YYYY-MM-DD>.<xlsx|csv>", dated with the Costa Rica day of the export.

X-Export-Truncated
string
Allowed values: true false

true when the 25000-row cap cut the set short, false otherwise.

X-Export-Row-Count
integer

Rows written to the file.