TF Fiscal
Documentation

Invoice e-mail

Save e-mail template

Creates an integrator e-mail template or overwrites an existing one; validates variables and HTML at save time.

POST/openapi/v2/emails/templates
Requires the token, timestamp and sign signature headers, see Authentication.

Templates belong to the integrator, not to a company: any registered company uses any template. Without templateId it creates; with templateId it replaces the whole template. Subject and body accept {{variables}} filled at send time with the invoice data; the list of names depends on tipoDocumento and is in the enumeration at the bottom of the page. How templates relate to sending is in Invoice e-mail.

Request body

templateId*
required to overwrite
stringTemplate identifier
tipoDocumento*
stringDocument type
idioma*
stringTemplate language
nome*
stringTemplate name
assunto*
stringSubject template
corpoHtml*
stringBody template
padrao
boolDefault template
ativo
boolEnabled

* Required field

200
Template saved, returned in full with the list of variables allowed for the type.
templateId
stringTemplate identifier
tipoDocumento
stringDocument type
idioma
stringTemplate language
nome
stringTemplate name
assunto
stringSubject template
corpoHtml
stringBody template
padrao
boolDefault template
ativo
boolEnabled
variaveisDisponiveis
arrayAllowed variables
criadoEm
stringCreation time
atualizadoEm
stringLast update

A template belongs to the integrator and applies to every company. There may be several per document type, for example one per language; the one with padrao = true is used when the send omits templateId. Saving already validates: a variable outside the list returns 10021003, HTML outside the list returns 10021004, and the message says which.

Minimal template

NF-e in Portuguese: subject with number and issuer, body with greeting, summary and PDF link. Without padrao and ativo: it is enabled and not the default.

json
{
"tipoDocumento": "NFe",
"idioma": "pt",
"nome": "NF-e simples",
"assunto": "Nota fiscal {{numero}} - {{emitente.nome}}",
"corpoHtml": "<p>Olá {{cliente.nome}},</p><p>Segue a nota fiscal {{numero}} emitida por {{emitente.nome}} em {{dataEmissao}}, no valor de R$ {{valorTotal}}.</p><p><a href='{{linkPdf}}'>Baixar DANFE (PDF)</a></p>"
}
tipoDocumento*
stringDocument type
idioma*
stringTemplate language
nome*
stringTemplate name
assunto*
stringSubject template
corpoHtml*
stringBody template

* Required field

Template with logo and buttons

NFS-e in Portuguese marked as default: header with an https image, a table with the NFS-e-only variables and two buttons pointing to {{linkPdf}} and {{linkXml}}. The image can only be a public https address; there is no upload.

json
{
"tipoDocumento": "NFSe",
"idioma": "pt",
"nome": "NFS-e com logotipo",
"assunto": "Nota Fiscal de Serviço nº {{numero}} - {{emitente.nome}}",
"corpoHtml": "<div style='background:#f3f4f6;padding:24px 0;font-family:Arial,Helvetica,sans-serif;color:#1f2937'><div style='max-width:640px;margin:0 auto;background:#ffffff;border-radius:12px;overflow:hidden;border:1px solid #e5e7eb'><div style='padding:20px 28px;border-bottom:1px solid #e5e7eb'><img src='https://v2.tffiscal.com/logo.png' alt='TF Fiscal' width='160' style='display:block;height:auto;border:0'></div><div style='padding:24px 28px'><h2 style='margin:0 0 16px;color:#1a56db;font-size:20px'>Nota Fiscal de Serviço nº {{numero}}</h2><p>Olá <strong>{{cliente.nome}}</strong>,</p><p>Segue a nota fiscal de serviço emitida por <strong>{{emitente.nome}}</strong> (CNPJ {{emitente.cnpj}}) em {{dataEmissao}}.</p><table style='border-collapse:collapse;width:100%;font-size:14px'><tbody><tr><td style='padding:8px;border:1px solid #e5e7eb;background:#f9fafb;width:40%'>Número / Série</td><td style='padding:8px;border:1px solid #e5e7eb'>{{numero}} / {{serie}}</td></tr><tr><td style='padding:8px;border:1px solid #e5e7eb;background:#f9fafb'>Serviço</td><td style='padding:8px;border:1px solid #e5e7eb'>{{descricaoServico}}</td></tr><tr><td style='padding:8px;border:1px solid #e5e7eb;background:#f9fafb'>Valor total</td><td style='padding:8px;border:1px solid #e5e7eb'>R$ {{valorTotal}}</td></tr><tr><td style='padding:8px;border:1px solid #e5e7eb;background:#f9fafb'>ISS</td><td style='padding:8px;border:1px solid #e5e7eb'>R$ {{valorIss}}</td></tr><tr><td style='padding:8px;border:1px solid #e5e7eb;background:#f9fafb'>Município</td><td style='padding:8px;border:1px solid #e5e7eb'>{{municipio}}</td></tr><tr><td style='padding:8px;border:1px solid #e5e7eb;background:#f9fafb'>Chave de acesso</td><td style='padding:8px;border:1px solid #e5e7eb;font-family:monospace;font-size:12px'>{{chaveAcesso}}</td></tr></tbody></table><p style='margin-top:20px'><a href='{{linkPdf}}' style='display:inline-block;padding:10px 18px;background:#1a56db;color:#ffffff;text-decoration:none;border-radius:6px;font-weight:bold'>Baixar DANFSe (PDF)</a>&nbsp;&nbsp;<a href='{{linkXml}}' style='display:inline-block;padding:10px 18px;border:1px solid #1a56db;color:#1a56db;text-decoration:none;border-radius:6px;font-weight:bold'>Baixar XML</a></p></div><div style='padding:16px 28px;background:#f9fafb;color:#6b7280;font-size:12px;border-top:1px solid #e5e7eb'>E-mail automático enviado pela plataforma TF Fiscal. Em caso de dúvidas, responda a este e-mail.</div></div></div>",
"padrao": true
}
tipoDocumento*
stringDocument type
idioma*
stringTemplate language
nome*
stringTemplate name
assunto*
stringSubject template
corpoHtml*
stringBody template
padrao
boolDefault template

* Required field

Type-specific variables

CT-e in English using remetente.nome, destinatario.nome and valorFrete. Those names only exist for CTe; in an NFe template they would be refused with 10021003. With idioma = en, amounts come out as 1,234.56 and dates as yyyy-MM-dd HH:mm.

json
{
"tipoDocumento": "CTe",
"idioma": "en",
"nome": "CT-e english",
"assunto": "Transport document {{numero}} from {{emitente.nome}}",
"corpoHtml": "<p>Hello {{cliente.nome}},</p><p>Transport document {{numero}} issued by {{emitente.nome}} on {{dataEmissao}}.</p><ul><li>Sender: {{remetente.nome}}</li><li>Recipient: {{destinatario.nome}}</li><li>Freight: R$ {{valorFrete}}</li></ul><p><a href='{{linkPdf}}'>Download DACTE (PDF)</a> | <a href='{{linkXml}}'>Download XML</a></p>"
}
tipoDocumento*
stringDocument type
idioma*
stringTemplate language
nome*
stringTemplate name
assunto*
stringSubject template
corpoHtml*
stringBody template

* Required field

Overwrite and disable a template

With templateId, the body replaces the whole template: resend every field. An omitted optional field goes back to its default, so a default template overwritten without padrao = true stops being the default. Here it is also disabled with ativo = false; a disabled template is never the default.

json
{
"templateId": "2103150000000000001",
"tipoDocumento": "NFe",
"idioma": "pt",
"nome": "NF-e simples (antigo)",
"assunto": "Nota fiscal {{numero}} - {{emitente.nome}}",
"corpoHtml": "<p>Olá {{cliente.nome}},</p><p>Segue a nota fiscal {{numero}} emitida por {{emitente.nome}} em {{dataEmissao}}, no valor de R$ {{valorTotal}}.</p><p><a href='{{linkPdf}}'>Baixar DANFE (PDF)</a></p>",
"ativo": false
}
templateId*
stringTemplate identifier
tipoDocumento*
stringDocument type
idioma*
stringTemplate language
nome*
stringTemplate name
assunto*
stringSubject template
corpoHtml*
stringBody template
ativo
boolEnabled

* Required field