/api/nfse/createIssue NFS-e
Required headers
tokenstring | string | Company token |
signstring | string | MD5 signature: MD5(token + path + body + timestamp) |
timestampstring | string | Unix timestamp in seconds (5-minute window) |
Main Fields
ambiente*string | string | "1" = production; any other value (e.g."2") = test environment of the national system (produção restrita). São Paulo has no test environment: companies in São Paulo accept only "1"; any other value returns an error, and nothing is sent or issued |
idstring | string | External reference ID of the integrator. When provided, it is used for duplicate prevention: if the company already has an authorized NFS-e with this id in the same ambiente, that record is returned (see duplicate prevention below) |
descricao_*string | string | Service description. Written to xDescServ in the national system and to Discriminacao in São Paulo |
valor_*decimal | decimal | Total service value in R$; must be greater than 0 |
codigo_string | string | Service code; non-digit characters are removed ("01.07.01" is accepted). If empty, the company's codigo_servico_nfse is used. National system: national tax code cTribNac (6 digits); São Paulo: municipal service code (5 digits, left-padded with zeros) |
cnaestring | string | CNAE; non-digit characters are removed. If empty, the company's cnae_nfse is used. Used by the national system only |
aliquota_decimal | decimal | ISS rate in % (e.g. 2.90). When omitted or not greater than 0, the default rate configured for the company is used. São Paulo: written to AliquotaServicos; national system: not written to the DPS, used only to calculate the ISS amount recorded by the platform |
iss_boolean | boolean | false = not withheld (default), true = withheld by the service recipient |
tributacaostring | string | Sã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). Other values return an error; ignored by the national system |
valor_decimal | decimal | Deductions. São Paulo: written to ValorDeducoes; national system: not written to the DPS. Also deducted from the ISS calculation base recorded by the platform |
desconto_decimal | decimal | Unconditional discount. Not written to the DPS or RPS; only deducted from the ISS calculation base recorded by the platform |
desconto_decimal | decimal | Conditional discount. Accepted by the endpoint, but currently neither used in calculations nor sent |
valor_decimal | decimal | ISS amount recorded by the platform. If greater than 0, it is used as is; otherwise it is calculated as (valor_servico − valor_deducoes − desconto_incondicionado) × aliquota_iss ÷ 100, rounded to two decimals. The value is stored by the platform only and is not written to the DPS or RPS |
valor_decimal | decimal | PIS amount. São Paulo only: written to ValorPIS when greater than 0; not written to the DPS of the national system |
valor_decimal | decimal | COFINS amount. São Paulo only: written to ValorCOFINS when greater than 0; not written to the DPS of the national system |
valor_decimal | decimal | INSS amount. São Paulo only: written to ValorINSS when greater than 0; not written to the DPS of the national system |
valor_decimal | decimal | IR amount. São Paulo only: written to ValorIR when greater than 0; not written to the DPS of the national system |
valor_decimal | decimal | CSLL amount. São Paulo only: written to ValorCSLL when greater than 0; not written to the DPS of the national system |
tomadorobject | object | Service recipient data. The endpoint does not validate its content; without a CPF or CNPJ, the DPS of the national system contains no service recipient data and the platform stores no service recipient record |
Service recipient fields (tomador)
cnpjstring | string | Service recipient CNPJ (digits only). Send either cnpj or cpf, not both |
cpfstring | string | Service recipient CPF (digits only). Send either cnpj or cpf, not both |
namestring | string | Name/Company name |
emailstring | string | Service recipient email |
telefonestring | string | Phone. Used by the national system only |
inscricao_string | string | Municipal registration. Used in São Paulo only |
inscricao_string | string | State registration (digits only are kept). Used in São Paulo only |
tipo_string | string | São Paulo only: street type abbreviation (e.g. R, AV, AL, TV), up to 3 characters; longer values are truncated. Default R |
cepstring | string | Zip code |
enderecostring | string | Street name. When empty, the service recipient address is not sent, and numero, complemento, bairro, cep, uf and codigo_municipio are not sent either |
numerostring | string | Number |
complementostring | string | Address complement |
bairrostring | string | Neighborhood |
citystring | string | City name. Stored with the record only; not written to the DPS or RPS |
ufstring | string | State abbreviation (2 letters). Used in São Paulo only; default SP |
codigo_string | string | IBGE city code (7 digits). National system: written to cMun; São Paulo: written to Cidade, default 3550308 |
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
| Message | Cause |
|---|---|
| O campo ambiente e obrigatorio | ambiente not provided |
| O campo descricao_servico e obrigatorio | descricao_servico not provided |
| O campo valor_servico deve ser maior que zero | valor_servico missing or not greater than 0 |
| O campo tributacao deve ser T, F, A, B, M, N, X, V ou P | tributacao outside the allowed values |
| Empresa nao encontrada | The 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
{
"ambiente": "1",
"id": "REF-001",
"descricao_servico": "Desenvolvimento de sistemas",
"valor_servico": 10000.00,
"aliquota_iss": 2.90,
"iss_retido": false,
"codigo_servico": "",
"cnae": "",
"tributacao": "T",
"valor_deducoes": 0,
"desconto_incondicionado": 0,
"desconto_condicionado": 0,
"valor_iss": 0,
"valor_pis": 0,
"valor_cofins": 0,
"valor_inss": 0,
"valor_ir": 0,
"valor_csll": 0,
"tomador": {
"cnpj": "43649380000100",
"cpf": "",
"name": "EMPRESA TOMADORA LTDA",
"email": "contato@empresa.com",
"telefone": "11999999999",
"inscricao_municipal": "",
"inscricao_estadual": "",
"tipo_logradouro": "R",
"cep": "03027020",
"endereco": "Exemplo",
"numero": "86",
"complemento": "Andar 2",
"bairro": "Centro",
"city": "Sao Paulo",
"uf": "SP",
"codigo_municipio": "3550308"
}
}
{
"success": true,
"data": {
"_id": "661234abcdef0123456789ab",
"uuid": "3f2b8c1e-5d4a-4f6b-9c7d-1a2b3c4d5e6f",
"status": "autorizada",
"motivo": "",
"nfse": "48",
"serie": 1,
"chave": "Z685RI9C",
"codigoVerificacao": "Z685RI9C",
"modelo": "nfse",
"tipoEmissao": "paulistana",
"danfse": "https://nfe.prefeitura.sp.gov.br/contribuinte/notaprintpdf.aspx?inscricao=12345678&nf=48&verificacao=Z685RI9C"
}
}
{
"success": true,
"data": {
"uuid": "8a1d6f20-3c4b-4e5f-a6b7-c8d9e0f1a2b3",
"status": "autorizada",
"motivo": "",
"nfse": 15,
"serie": 1,
"chave": "35503082243649380000100000000000015260100000000001",
"codigoVerificacao": "A1B2C3D4",
"modelo": "nfse"
}
}