TF Fiscal

NF-e Invoices

POST/api/invoice/get_danfe

Get 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

tokenstringstringIssuing company token
signstringstringMD5 signature: MD5(token + path + body + timestamp)
timestampstringstringUnix timestamp in seconds (5-minute window)

Body

uuidstringstringInternal NF-e UUID (returned by /api/invoice/create)
chavestringstringNF-e access key (44 digits)
larguraintintLabel (simplified DANFE) width in mm.
alturaintintLabel (simplified DANFE) height in mm.

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

danfestringstringURL of the full DANFE PDF (A4 format)
danfe_simplesstringstringURL of the simplified DANFE PDF (receipt format)
danfe_simples_pngstringstringURL of the simplified DANFE PNG (label image)

Error responses

MessageCause
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