/api/nfce/returnReturn an NFC-e
Issues a return document for an authorized NFC-e. The return is an inbound NF-e (model 55) that references the access key of the original NFC-e in its XML; the NFC-e itself has no return document. The original is looked up among NFC-e records by uuid or chave, and items and tax fields are carried over from it. /api/invoice/return only searches NF-e records and answers "invoice does not exist" for any NFC-e; use this endpoint instead.
Required headers
tokenstring | string | Issuing company token |
signstring | string | MD5 signature |
timestampstring | string | Unix timestamp in seconds |
Body
| Field | Type | Required | Description |
|---|---|---|---|
| uuid | string | No | uuid of the original NFC-e. Either this or chave |
| chave | string | No | 44-digit access key of the original NFC-e. Either this or uuid |
| cfop | string | Yes | CFOP of the return, typically 1202 within the state and 2202 across states |
| natureza_ | string | No | Nature of the operation. Defaults to Devolução de Mercadoria. The field name nature_of_operation is also accepted |
| cliente | object | No | The recipient, that is, the buyer of the original document. Fields: cpf, cnpj, ie, name, endereco, numero, complemento, bairro, city, uf, cep, email, telefone. Non-empty fields sent override the original; fields omitted or sent as empty strings are taken from it. When the original carries no buyer CPF/CNPJ, cpf or cnpj is required |
The return is an NF-e, and the recipient address is mandatory, whereas an NFC-e usually records no buyer address. When the original XML carries no address, cliente must include endereco, bairro, city, uf and cep; the endpoint lists whichever are missing.
Only an authorized NFC-e can be returned. The environment (production or test) follows the original and is neither required nor accepted as a parameter.
Repeated calls do not issue twice: when a return already exists for the same original in the same environment, that document is returned.
The whole document is returned. Items, quantities and tax fields come from the original; tax fields are resolved through the tax category first and, when the category is missing, copied from the CST and rates in the original XML.
Response fields (data)
uuidstring | string | Identifier of the return document |
statusstring | string | Success authorized, Failed rejected |
motivostring | string | Message returned by the tax authority |
nfeint | int | Number of the return document |
serieint | int | Series of the return document |
chavestring | string | 44-digit access key of the return document |
modelostring | string | Always nfe: the return is an NF-e |
epecboolean | boolean | Whether contingency issuance was used |
xmlstring | string | URL of the return document XML |
Response — error
success is false, the reason is in message and there is no data. When the tax authority rejects the document, success is also false but data is present, with status equal to Failed and the reason in motivo.
{
"success": false,
"message": "A devolução é uma NF-e e exige o endereço do comprador; a NFC-e original não o traz. Informe em cliente: endereco, bairro, city, uf, cep / 退货票是 NF-e,必须有买方地址,原 NFC-e 没有。请在 cliente 里传:endereco、bairro、city、uf、cep"
}Examples
# sign = md5(token + path + body + timestamp) # Template generated from the endpoint path; replace the placeholders curl -X POST "https://api.tffiscal.com/api/nfce/return" \ -H "Content-Type: application/json" \ -H "token: $TOKEN" \ -H "timestamp: $TIMESTAMP" \ -H "sign: $SIGN" \ -d @body.json
{
"chave": "35210112345678901234650010000000051234567890",
"cfop": "1202",
"natureza_operacao": "Devolucao de venda",
"cliente": {
"cpf": "12345678909",
"name": "Cliente Exemplo",
"endereco": "Av. Paulista",
"numero": "1000",
"bairro": "Bela Vista",
"city": "Sao Paulo",
"uf": "SP",
"cep": "01311000"
}
}
{
"success": true,
"message": "成功",
"data": {
"uuid": "8f2d6c1e-4b3a-4c9d-9e7f-1a2b3c4d5e6f",
"status": "Success",
"motivo": "Rejeição 100: Autorizado o uso da NF-e",
"nfe": 31,
"serie": 1,
"chave": "35210112345678901234550010000000311234567891",
"modelo": "nfe",
"epec": false,
"xml": "https://tffiscal-file.tffiscal.com/xml/.../35210112345678901234550010000000311234567891.xml"
}
}