Skip to content

List drafts for the current tenant (cross-env by design)

GET
/v1/drafts
curl --request GET \
--url 'https://api.emite.cr/v1/drafts?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' \
--header 'Authorization: Bearer <token>'

Returns drafts across BOTH sandbox and production for the current tenant. Sorted active-env-first so the user's current work surfaces at the top. Each item carries environment so the UI can render a per-row badge.

Differs from GET /v1/invoices?status=draft, which filters strict by the caller's active environment. Use this endpoint when surfacing drafts to a human (Settings / drafts page); use the env-strict variant for API/automation consumers.

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.

Cross-env listing.

Media typeapplication/json
object
items
required

The documents on this page, in the requested order.

Array<object>
object
id
required

Id of the document; read the whole document with GET /v1/invoices/{id}.

string format: uuid
consecutivo
required

The document's 20-digit number, <NumeroConsecutivo>: branch (3) + terminal (5) + document type (2) + sequence (10). Null until the document gets its number, when it is signed.

string
nullable
clave
required

The document's 50-digit Hacienda key, <Clave>. Null until the document gets its number, when it is signed.

string
nullable
docType
required

Hacienda document type: 01 invoice (FE), 02 debit note (ND), 03 credit note (NC), 04 ticket (TE), 08 purchase invoice (FEC), 09 export invoice (FEE), 10 payment receipt (REP). 05–07 name the receiver's messages, which are not invoices. Details under docType in the document read by GET /v1/invoices/{id}.

string
Allowed values: 01 02 03 04 05 06 07 08 09 10
environment
required

Environment the document belongs to, fixed when it is created: sandbox (Hacienda's test environment, free and with no fiscal value) or production (real fiscal documents). GET /v1/invoices lists only the active environment; GET /v1/drafts lists the drafts of both.

string
Allowed values: sandbox production
status
required

Where the document is in EmiteCR: draft (not signed yet), signed (numbered and signed, delivered to Hacienda automatically), submitted (received by Hacienda, verdict pending), accepted, rejected, or error (could not be signed or delivered, or no verdict within 24 hours).

string
Allowed values: draft signed submitted accepted rejected error
haciendaStatus
required

Hacienda's own state for the document, as its reception API (ATV) reports it: recibido (received, not judged yet), procesando (being processed), aceptado (accepted), rechazado (rejected), or error (ATV's error state, or one it does not name). Null until an answer from Hacienda is recorded.

string
nullable
Allowed values: recibido procesando aceptado rechazado error
haciendaDetailMessage
required

Hacienda's explanation of its verdict (<DetalleMensaje>), so a rejection's reasons can be shown without reading the whole document; when ATV refused a submission, ATV's own message about it. Null until there is one.

string
nullable
currency
required

ISO 4217 currency of the document; totalComprobante is in this currency.

string
totalComprobante
required

Document total (<TotalComprobante>), in currency. Null until the document is signed, when its totals are computed. Positive on a credit note too.

number
nullable
receiverName
required

Name of the receiver (the supplier on a purchase invoice, FEC): the current name of the linked contact when receiverPartyId is set, otherwise the name captured on the document. Null for a ticket (TE) without a receiver.

string
nullable
receiverPartyId
required

Id of the contact in the company's contacts the document was issued to, when it was created with receiverId. Null for a receiver given inline and for a ticket (TE) without a receiver.

string format: uuid
nullable
createdAt
required

When the record was created (ISO 8601 instant): the draft was first saved, or the XML was imported. Not the emission date, which is fechaEmision.

string format: date-time
fechaEmision
required

When the document was issued (ISO 8601 instant): the <FechaEmision> its clave and XML declare and its PDF prints, the date reports count by. Null while it has no number.

string format: date-time
nullable
submittedAt
required

When Hacienda received the document from EmiteCR (ISO 8601 instant); for a document imported from XML, the emission date its XML declares. Null until then.

string format: date-time
nullable
scheduledSendAt
required

When a draft is scheduled to be signed and sent automatically (ISO 8601 instant). Null for a draft without a schedule and for any document that is no longer a draft.

string format: date-time
nullable
externalReference
required

Your own id for the sale behind the document (for example a POS ticket UUID), as sent at creation; unique per company and environment. Null when none was sent.

string
nullable
total
required

How many documents match the filters, across all pages.

number
page
required

The page returned (1-based).

number
pageSize
required

Rows per page used for this answer: 25 by default, at most 100.

number
Example
{
"items": [
{
"consecutivo": "00100001010000000042",
"docType": "01",
"environment": "sandbox",
"status": "draft",
"haciendaStatus": "recibido",
"currency": "CRC",
"totalComprobante": 1130
}
],
"total": 137,
"page": 1,
"pageSize": 25
}

Missing or invalid JWT / API key.