POST
/api/invoice/get_xmlBatch export NF-e
Starts an asynchronous bulk export task for the user's invoices, filtering by period and status. Can generate an Excel spreadsheet (metadata only) or a ZIP package with the XMLs. The first call creates the task and returns status: "Processing"; subsequent calls with the same parameters return the progress until status: "Success", when the url field contains the download link.
Required headers
tokenstring | string | Issuing company token |
signstring | string | MD5 signature |
timestampstring | string | Unix timestamp in seconds |
Body
type*string | string | Output format: "excel" (metadata spreadsheet), "xml" (ZIP of XML files) or "pdf" (ZIP of DANFE PDFs).Any other value creates a task that ends in failure |
statusstring | string | Filter by invoice status: a status name (e.g."Success", "Canceled", "Voided", case-insensitive) or "all" (every status). Optional when type is "xml" or "pdf", in which case every status is exported; required when type is "excel" |
monthint | int | Month (1–12). When provided, overrides start_create_time/end_create_time; uses America/Sao_Paulo timezone and the current year (or previous year if the month is in the future) |
start_long | long | Period start, inclusive (Unix timestamp in milliseconds). The UTC date and time of the value are read as Brasília time: send the UTC midnight of the day, e.g. Date.UTC(2026, 7, 1) = 1785542400000 means 2026-08-01 00:00 in Brasília |
end_long | long | Period end, exclusive (same rule). Send the UTC midnight of the day after the last day you want: for the whole of August 2026, Date.UTC(2026, 8, 1) = 1788220800000 |
* Required field.
Period:
start_create_time/end_create_time are read by their UTC date and time and interpreted as Brasília time (UTC−3, no daylight saving). Send the UTC midnight of the calendar days: start inclusive, end exclusive. Example, full days 2026-08-29 through 2026-09-01: start_create_time = 1787961600000 (2026-08-29T00:00Z) and end_create_time = 1788307200000 (2026-09-02T00:00Z). Do not add 3 hours to the value.
Export scope:
month, or both start_create_time and end_create_time, must be sent; otherwise the request is rejected with a parameter error and no export task is created. The period applies to the issue time, and only production invoices are included. Once an export file exceeds the storage retention period, a call with the same parameters generates it again.
Response fields
statusstring | string | "Processing" while the task runs, "Success" when the file is ready |
progress_int | int | Number of invoices processed so far |
total_int | int | Total invoices to process |
urlstring | string | Download URL of the final file (empty while status = Processing) |
Idempotency: tasks are deduplicated by a hash of the parameters (
uid + token + period + status + type). Repeated calls with the same parameters return the same task's progress, without triggering new executions.
Error responses
| Message | Cause |
|---|---|
| 发票类型字段不能为空 | type missing |
| 月份无效 | month outside 1–12 |
| 必须传 month,或同时传 start_create_time 与 end_create_time | Neither month nor both start_create_time and end_create_time were sent |
| type 为 excel 时 status 不能为空(全部状态传 "all") | status missing while type is "excel" |
| 导出处理出现内部错误,请稍后重试 | Internal processing error; the call may be retried later with the same parameters |
| <task failure reason> | The export task failed (for example, an unsupported type); returned with success: false |
Examples
# sign = md5(token + path + body + timestamp) # Template generated from the endpoint path; replace the placeholders curl -X POST "https://api.tffiscal.com/api/invoice/get_xml" \ -H "Content-Type: application/json" \ -H "token: $TOKEN" \ -H "timestamp: $TIMESTAMP" \ -H "sign: $SIGN" \ -d @body.json
{
"type": "xml",
"status": "Success",
"start_create_time": 1787961600000,
"end_create_time": 1788307200000
}
{
"success": true,
"data": {
"status": "Processing",
"progress_count": 120,
"total_count": 543,
"url": ""
}
}
{
"success": true,
"data": {
"status": "Success",
"progress_count": 543,
"total_count": 543,
"url": "https://storage.../exports/uid/<sn>.zip"
}
}