The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Focus NFe - Emiss\u00e3o e Consulta NFe (BH \u2192 Brasil/Mundo)",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "emitir-nfe",
"responseMode": "responseNode",
"options": {}
},
"id": "webhook-trigger",
"name": "Webhook - Receber pedido",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
0,
300
]
},
{
"parameters": {
"jsCode": "// Prepara refer\u00eancia \u00fanica e dados para a Focus NFe\n// Entrada: body do webhook com dados do pedido/destinat\u00e1rio\nconst body = $input.first().json.body || $input.first().json;\nconst ref = body.referencia || body.pedido_id || `NFE-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;\n\n// Dados do emitente (empresa em BH - ajuste com seus dados reais)\nconst emitente = {\n cnpj_emitente: body.cnpj_emitente || process.env.FOCUS_NFE_CNPJ_EMITENTE || \"\",\n nome_emitente: body.nome_emitente || \"SUA EMPRESA LTDA\",\n nome_fantasia_emitente: body.nome_fantasia_emitente || \"SUA EMPRESA\",\n logradouro_emitente: body.logradouro_emitente || \"Rua Exemplo\",\n numero_emitente: body.numero_emitente || \"100\",\n bairro_emitente: body.bairro_emitente || \"Centro\",\n municipio_emitente: body.municipio_emitente || \"Belo Horizonte\",\n uf_emitente: body.uf_emitente || \"MG\",\n cep_emitente: body.cep_emitente || \"30130000\",\n inscricao_estadual_emitente: body.inscricao_estadual_emitente || \"\",\n telefone_emitente: body.telefone_emitente || \"\"\n};\n\n// Destinat\u00e1rio (Brasil ou exterior - vem do pedido)\nconst destinatario = {\n nome_destinatario: body.nome_destinatario,\n cpf_destinatario: body.cpf_destinatario || undefined,\n cnpj_destinatario: body.cnpj_destinatario || undefined,\n inscricao_estadual_destinatario: body.inscricao_estadual_destinatario || \"ISENTO\",\n logradouro_destinatario: body.logradouro_destinatario,\n numero_destinatario: body.numero_destinatario,\n bairro_destinatario: body.bairro_destinatario,\n municipio_destinatario: body.municipio_destinatario,\n uf_destinatario: body.uf_destinatario || \"EX\",\n pais_destinatario: body.pais_destinatario || \"Brasil\",\n cep_destinatario: body.cep_destinatario || \"00000000\",\n telefone_destinatario: body.telefone_destinatario || \"\"\n};\n\n// Data/hora atual em formato Focus NFe\nconst now = new Date().toISOString().slice(0, 19);\n\n// Monta o payload da NFe (campos obrigat\u00f3rios + itens)\nconst nfePayload = {\n data_emissao: body.data_emissao || now,\n data_entrada_saida: body.data_entrada_saida || now,\n natureza_operacao: body.natureza_operacao || \"Venda de mercadoria\",\n forma_pagamento: body.forma_pagamento || \"0\",\n tipo_documento: body.tipo_documento || \"1\",\n finalidade_emissao: body.finalidade_emissao || \"1\",\n ...emitente,\n ...destinatario,\n valor_frete: String(body.valor_frete ?? 0),\n valor_seguro: String(body.valor_seguro ?? 0),\n valor_total: String(body.valor_total),\n valor_produtos: String(body.valor_produtos),\n modalidade_frete: body.modalidade_frete || \"0\",\n items: Array.isArray(body.items) ? body.items.map((item, i) => ({\n numero_item: String(i + 1),\n codigo_produto: item.codigo_produto || String(i + 1),\n descricao: item.descricao,\n cfop: item.cfop || \"5102\",\n unidade_comercial: item.unidade_comercial || \"UN\",\n quantidade_comercial: String(item.quantidade_comercial),\n valor_unitario_comercial: String(item.valor_unitario_comercial),\n valor_unitario_tributavel: String(item.valor_unitario_tributavel || item.valor_unitario_comercial),\n unidade_tributavel: item.unidade_tributavel || \"UN\",\n codigo_ncm: item.codigo_ncm || \"00000000\",\n quantidade_tributavel: String(item.quantidade_tributavel || item.quantidade_comercial),\n valor_bruto: String(item.valor_bruto || (item.quantidade_comercial * item.valor_unitario_comercial)),\n icms_situacao_tributaria: item.icms_situacao_tributaria || \"400\",\n icms_origem: String(item.icms_origem ?? 0),\n pis_situacao_tributaria: item.pis_situacao_tributaria || \"07\",\n cofins_situacao_tributaria: item.cofins_situacao_tributaria || \"07\"\n })) : []\n};\n\nreturn [{ json: { referencia: ref.replace(/[^a-zA-Z0-9_-]/g, \"_\"), ambiente: body.ambiente || \"homologacao\", nfePayload } }];"
},
"id": "preparar-payload",
"name": "Preparar payload NFe",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
220,
300
]
},
{
"parameters": {
"method": "POST",
"url": "=https://{{ $json.ambiente === 'producao' ? 'api' : 'homologacao' }.focusnfe.com.br/v2/nfe?ref={{ $json.referencia }}",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify($json.nfePayload) }}",
"options": {
"response": {
"response": {
"fullResponse": true
}
}
}
},
"id": "http-emitir-nfe",
"name": "Focus NFe - Emitir NFe",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
440,
300
],
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
},
"notesInFlow": true,
"notes": "POST /v2/nfe?ref=REFERENCIA. Ambiente via body.ambiente (homologacao | producao)."
},
{
"parameters": {
"amount": 45,
"unit": "seconds"
},
"id": "wait-processamento",
"name": "Aguardar processamento SEFAZ",
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
660,
300
],
"notesInFlow": true,
"notes": "NFe \u00e9 ass\u00edncrona; normalmente < 1 min. Use webhook Focus NFe para evitar polling."
},
{
"parameters": {
"method": "GET",
"url": "=https://{{ $('Preparar payload NFe').item.json.ambiente === 'producao' ? 'api' : 'homologacao' }.focusnfe.com.br/v2/nfe/{{ $('Preparar payload NFe').item.json.referencia }}",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"options": {
"response": {
"response": {
"fullResponse": false
}
}
}
},
"id": "http-consultar-nfe",
"name": "Focus NFe - Consultar status",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
880,
300
],
"credentials": {
"httpHeaderAuth": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "cond-autorizado",
"leftValue": "={{ $json.status }}",
"rightValue": "autorizado",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "if-status-autorizado",
"name": "Status = autorizado?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
1100,
300
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ { ok: true, mensagem: 'NFe autorizada', referencia: $('Preparar payload NFe').item.json.referencia, status: $json.status, numero: $json.numero, cnpj_emitente: $json.cnpj_emitente, chave_nfe: $json.chave_nfe } }}",
"options": {
"responseCode": 200
}
},
"id": "resposta-sucesso",
"name": "Resposta - NFe autorizada",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1320,
200
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ { ok: false, mensagem: 'NFe n\u00e3o autorizada ou em processamento', referencia: $('Preparar payload NFe').item.json.referencia, status: $json.status || 'erro', mensagem_erro: $json.mensagem || $json.codigo } }}",
"options": {
"responseCode": 422
}
},
"id": "resposta-erro",
"name": "Resposta - Erro / em processamento",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1320,
400
]
}
],
"connections": {
"Webhook - Receber pedido": {
"main": [
[
{
"node": "Preparar payload NFe",
"type": "main",
"index": 0
}
]
]
},
"Preparar payload NFe": {
"main": [
[
{
"node": "Focus NFe - Emitir NFe",
"type": "main",
"index": 0
}
]
]
},
"Focus NFe - Emitir NFe": {
"main": [
[
{
"node": "Aguardar processamento SEFAZ",
"type": "main",
"index": 0
}
]
]
},
"Aguardar processamento SEFAZ": {
"main": [
[
{
"node": "Focus NFe - Consultar status",
"type": "main",
"index": 0
}
]
]
},
"Focus NFe - Consultar status": {
"main": [
[
{
"node": "Status = autorizado?",
"type": "main",
"index": 0
}
]
]
},
"Status = autorizado?": {
"main": [
[
{
"node": "Resposta - NFe autorizada",
"type": "main",
"index": 0
}
],
[
{
"node": "Resposta - Erro / em processamento",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [
{
"name": "Focus NFe"
},
{
"name": "NFe"
},
{
"name": "Fiscal"
}
],
"triggerCount": 1,
"meta": {
"templateCredsSetupCompleted": false
},
"versionId": "1"
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
httpHeaderAuth
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Focus NFe - Emissão e Consulta NFe (BH → Brasil/Mundo). Uses httpRequest. Webhook trigger; 8 nodes.
Source: https://github.com/Travessoni/api-nfe/blob/f2ef5b89db090caf81bbc41e5cdfe5e77830482d/n8n-workflow-focus-nfe-emissao-nfe.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This n8n template provides enterprise-level version control for your workflows using GitHub integration. Stop losing hours to broken workflows and manual exports – get proper commit history, visual di
This flow creates dummy files for every item added in your *Arrs (Radarr/Sonarr) with the tag .
eek-Go v2 (Batch-Then-Review). Uses httpRequest. Webhook trigger; 75 nodes.
This workflow receives webhook requests from a content calendar and uses the X API v2 to publish text posts, threads, image/video posts, and polls, as well as delete existing posts and run a credentia
This workflow acts as a central API gateway for all technical indicator agents in the Binance Spot Market Quant AI system. It listens for incoming webhook requests and dynamically routes them to the c