/api/invoice/get_danfeGet NF-e DANFE
Returns three URLs for an NF-e DANFE: the full DANFE (PDF), the simplified DANFE PDF (receipt format) and the simplified DANFE as a PNG (label image). PDFs are generated on demand from the authorized XML and cached in the platform file storage. On subsequent calls, if the invoice status has not changed, the existing cache is returned; if the status has changed (e.g. the invoice was cancelled), PDFs are regenerated.
Required headers
tokenstring | string | Issuing company token |
signstring | string | MD5 signature: MD5(token + path + body + timestamp) |
timestampstring | string | Unix timestamp in seconds (5-minute window) |
Body
uuidstring | string | Internal NF-e UUID (returned by /api/invoice/create) |
chavestring | string | NF-e access key (44 digits) |
larguraint | int | Label (simplified DANFE) width in mm. Default: 105 |
alturaint | int | Label (simplified DANFE) height in mm. Default: 140 |
Either uuid or chave is required.
largura and altura are optional and only apply when both are greater than zero. They only affect the simplified DANFE (danfe_simples and danfe_simples_png); the full DANFE is unchanged. With a custom size the label is generated on every call, without cache, and the file gets the suffix _{largura}x{altura}.
Response fields
danfestring | string | URL of the full DANFE PDF (A4 format) |
danfe_string | string | URL of the simplified DANFE PDF (receipt format) |
danfe_string | string | URL of the simplified DANFE PNG (label image) |
Error responses
| Message | Cause |
|---|---|
| uuid/chave不能为空 | Neither uuid nor chave was provided |
| 发票不存在 | Invoice not found for the token user, or authorized XML missing |
| 发票详情不存在 | Invoice detail (with protocol) not found |
| 获取PDF失败:<reason> | Failure generating the PDF from XML |
| 该票文件已按集成商保留策略清理 | The invoice XML and DANFE were deleted under the integrator's file retention policy |
| DANFE 上传失败: <reason> | Upload of the generated file to storage failed; the call can be retried later |
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_danfe" \ -H "Content-Type: application/json" \ -H "token: $TOKEN" \ -H "timestamp: $TIMESTAMP" \ -H "sign: $SIGN" \ -d @body.json
{
"uuid": "4663a257-adf1-4561-971f-6aaffbd30ca8",
"largura": 80,
"altura": 120
}
{
"success": true,
"data": {
"danfe": "https://storage.../uid/dd-MM-yyyy/companyId/<chave>.pdf",
"danfe_simples": "https://storage.../uid/cnpj/dd-MM-yyyy/<chave>_simplie.pdf",
"danfe_simples_png": "https://storage.../uid/cnpj/dd-MM-yyyy/<chave>_simplie.png"
}
}