TF Fiscal

NFS-e Service Invoices

POST/api/nfse/create

Issue NFS-e

Required headers

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

Main Fields

ambiente*stringstring"1" = production; any other value (e.g.
idstringstringExternal reference ID of the integrator.
descricao_servico*stringstringService description.
valor_servico*decimaldecimalTotal service value in R$; must be greater than 0
codigo_servicostringstringService code; non-digit characters are removed ("01.07.01" is accepted).
cnaestringstringCNAE; non-digit characters are removed.
aliquota_issdecimaldecimalISS rate in % (e.g.
iss_retidobooleanbooleanfalse = not withheld (default), true = withheld by the service recipient
tributacaostringstringSão Paulo only: RPS taxation type (TributacaoRPS), one of T, F, A, B, M, N, X, V, P; default T (taxed in São Paulo).
valor_deducoesdecimaldecimalDeductions.
desconto_incondicionadodecimaldecimalUnconditional discount.
desconto_condicionadodecimaldecimalConditional discount.
valor_issdecimaldecimalISS amount recorded by the platform.
valor_pisdecimaldecimalPIS amount.
valor_cofinsdecimaldecimalCOFINS amount.
valor_inssdecimaldecimalINSS amount.
valor_irdecimaldecimalIR amount.
valor_cslldecimaldecimalCSLL amount.
tomadorobjectobjectService recipient data.

Service recipient fields (tomador)

cnpjstringstringService recipient CNPJ (digits only).
cpfstringstringService recipient CPF (digits only).
namestringstringName/Company name
emailstringstringService recipient email
telefonestringstringPhone.
inscricao_municipalstringstringMunicipal registration.
inscricao_estadualstringstringState registration (digits only are kept).
tipo_logradourostringstringSão Paulo only: street type abbreviation (e.g.
cepstringstringZip code
enderecostringstringStreet name.
numerostringstringNumber
complementostringstringAddress complement
bairrostringstringNeighborhood
citystringstringCity name.
ufstringstringState abbreviation (2 letters).
codigo_municipiostringstringIBGE city code (7 digits).

Response fields depend on the issuance channel: São Paulo returns _id, tipoEmissao ("paulistana") and danfse (link to the municipal PDF); nfse is the NFS-e number assigned by the municipality (string) and chave equals codigoVerificacao. The national system does not return these three fields; nfse is the DPS number (integer), chave is the 50-digit access key, and the PDF is obtained with /api/nfse/get_danfse. In cancel, get_danfse and get_xml, the chave parameter accepts the value of codigoVerificacao or, for NFS-e of the national system, the 50-digit access key (chave).

Duplicate prevention (per company and ambiente): when id is provided and an authorized NFS-e with that id already exists, the endpoint does not issue a new one and returns that record (fields uuid, status, motivo, nfse, serie, chave, codigoVerificacao, modelo, xml, danfse). Without id, the check uses descricao_servico, the service recipient CPF/CNPJ, valor_servico and the issuance date (calendar day in Brasília time): an authorized NFS-e with the same four values on the same day is returned. Sending a unique id for each NFS-e is recommended: retries can then be resent safely, and several NFS-e with the same value to the same service recipient on the same day are not treated as duplicates.

When issuance fails, success is false and message contains the reason returned by the national system or the municipality, followed by "(HTTP status code)".

Common errors

MessageCause
O campo ambiente e obrigatorioambiente not provided
O campo descricao_servico e obrigatoriodescricao_servico not provided
O campo valor_servico deve ser maior que zerovalor_servico missing or not greater than 0
O campo tributacao deve ser T, F, A, B, M, N, X, V ou Ptributacao outside the allowed values
Empresa nao encontradaThe token does not correspond to a company
A Prefeitura de Sao Paulo nao possui ambiente de homologacao: toda NFS-e enviada tem validade fiscal. Envie ambiente = "1" (producao) para emitir. Nenhuma nota foi enviada.ambiente is not "1" for a company in São Paulo; nothing was sent or issued
<reason> (HTTP 400)The national system or the municipality rejected the request; the first part is the reason it returned
Erro na emissao (Assinatura digital): ...Failure while loading the certificate, signing the XML or communicating; the stage is shown in parentheses

Examples

# sign = md5(token + path + body + timestamp)
# Template generated from the endpoint path; replace the placeholders
curl -X POST "https://api.tffiscal.com/api/nfse/create" \
  -H "Content-Type: application/json" \
  -H "token: $TOKEN" \
  -H "timestamp: $TIMESTAMP" \
  -H "sign: $SIGN" \
  -d @body.json