{"openapi":"3.1.0","jsonSchemaDialect":"https://json-schema.org/draft/2020-12/schema","info":{"title":"MadNotas API","version":"1.0.0","summary":"NF-e e NFC-e por API REST: JSON de domínio, erros com caminho do campo, simulação sem SEFAZ.","description":"Emita NF-e (55) e NFC-e (65) mandando um JSON do seu domínio. O MadNotas normaliza, calcula os tributos, valida (todos os erros de uma vez, com o caminho JSON do campo), numera, assina, transmite e guarda o XML.\n\n**Ambiente pela chave:** `mn_sim_…` simulação (SEFAZ simulada, sem certificado), `mn_hom_…` homologação, `mn_prod_…` produção.\n\n**Idempotência:** mande `ref` no payload e/ou `Idempotency-Key` no cabeçalho. Mesma ref + mesmo payload = a mesma nota.\n\n**Erros:** sempre no envelope `{erro:{tipo,codigo,mensagem,detalhes[]},request_id}`. Rejeição da SEFAZ é o status `rejeitada` do documento (corrija com PUT no mesmo número), não um erro HTTP.\n\n**Limites:** cabeçalhos `RateLimit-*`; 429 com `Retry-After`.","contact":{"name":"Suporte MadNotas","url":"https://madnotas.com.br/ajuda"}},"servers":[{"url":"https://notas.madbuilder.dev/api/v1","description":"Este ambiente. O ambiente fiscal vem da chave (mn_sim_ / mn_hom_ / mn_prod_)."}],"security":[{"chaveApi":[]}],"tags":[{"name":"NF-e","description":"Nota fiscal eletrônica (modelo 55)."},{"name":"NFC-e","description":"Nota fiscal de consumidor (modelo 65)."},{"name":"NFS-e","description":"NFS-e Nacional (Sefin Nacional / ADN): DPS assinada, NFS-e, cancelamento e substituição."},{"name":"DF-e","description":"DF-e de entrada: NF-e emitidas contra os seus CNPJs, baixadas do Ambiente Nacional pela cadência do MadNotas, XML completo e manifestação do destinatário."},{"name":"Inutilização","description":"Faixas de numeração não usadas."},{"name":"Emitentes","description":"Empresas emissoras, certificado A1, CSC e numeração."},{"name":"Webhooks","description":"Avisos de mudança de status no seu sistema."},{"name":"Utilitários","description":"Tabelas fiscais, chave de acesso, rejeições."},{"name":"Conta","description":"Chave, uso, logs e simulação."},{"name":"SEFAZ","description":"Status público dos autorizadores."}],"paths":{"/nfe":{"post":{"tags":["NF-e"],"summary":"Emitir NF-e","description":"Valida, calcula, numera, assina e transmite. 202 + `processando` (acompanhe por GET, webhook ou `?aguardar=`); 201 quando já tem o resultado; 200 + Idempotent-Replayed quando a `ref` já existia com o mesmo payload. Rejeitada: corrija com PUT no MESMO número.","operationId":"emitir_nfe","responses":{"201":{"description":"Resultado final (autorizada, rejeitada, denegada ou contingência).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/Documento"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"202":{"description":"Aceita, processando.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/DocumentoProcessando"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"200":{"description":"Replay da mesma ref/Idempotency-Key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/Documento"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Aguardar"},{"$ref":"#/components/parameters/IdempotencyKey"},{"$ref":"#/components/parameters/Simular"},{"$ref":"#/components/parameters/SimularAtraso"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfe"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfe' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Idempotency-Key: pedido-1001' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"pedido-1001\",\"natureza_operacao\":\"VENDA DE MERCADORIA\",\"destinatario\":{\"cnpj\":\"12ABC34501DE35\",\"nome\":\"COMERCIO FICTICIO LTDA\",\"inscricao_estadual\":\"110042490114\",\"email\":\"compras@cliente.test\",\"endereco\":{\"logradouro\":\"RUA DO CLIENTE\",\"numero\":\"55\",\"bairro\":\"CENTRO\",\"codigo_municipio\":\"3550308\",\"municipio\":\"SAO PAULO\",\"uf\":\"SP\",\"cep\":\"01001000\"}},\"itens\":[{\"codigo\":\"P001\",\"descricao\":\"PRODUTO FICTICIO\",\"ncm\":\"21069090\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"3\",\"valor_unitario\":\"33.3333\",\"valor_bruto\":\"100.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"pix\",\"valor\":\"100.00\"}]}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfe', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n        'Idempotency-Key' => 'pedido-1001',\n    ],\n    'json' => json_decode('{\"ref\":\"pedido-1001\",\"natureza_operacao\":\"VENDA DE MERCADORIA\",\"destinatario\":{\"cnpj\":\"12ABC34501DE35\",\"nome\":\"COMERCIO FICTICIO LTDA\",\"inscricao_estadual\":\"110042490114\",\"email\":\"compras@cliente.test\",\"endereco\":{\"logradouro\":\"RUA DO CLIENTE\",\"numero\":\"55\",\"bairro\":\"CENTRO\",\"codigo_municipio\":\"3550308\",\"municipio\":\"SAO PAULO\",\"uf\":\"SP\",\"cep\":\"01001000\"}},\"itens\":[{\"codigo\":\"P001\",\"descricao\":\"PRODUTO FICTICIO\",\"ncm\":\"21069090\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"3\",\"valor_unitario\":\"33.3333\",\"valor_bruto\":\"100.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"pix\",\"valor\":\"100.00\"}]}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfe', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json', 'Idempotency-Key': 'pedido-1001' },\n  body: JSON.stringify({\n      \"ref\": \"pedido-1001\",\n      \"natureza_operacao\": \"VENDA DE MERCADORIA\",\n      \"destinatario\": {\n          \"cnpj\": \"12ABC34501DE35\",\n          \"nome\": \"COMERCIO FICTICIO LTDA\",\n          \"inscricao_estadual\": \"110042490114\",\n          \"email\": \"compras@cliente.test\",\n          \"endereco\": {\n              \"logradouro\": \"RUA DO CLIENTE\",\n              \"numero\": \"55\",\n              \"bairro\": \"CENTRO\",\n              \"codigo_municipio\": \"3550308\",\n              \"municipio\": \"SAO PAULO\",\n              \"uf\": \"SP\",\n              \"cep\": \"01001000\"\n          }\n      },\n      \"itens\": [\n          {\n              \"codigo\": \"P001\",\n              \"descricao\": \"PRODUTO FICTICIO\",\n              \"ncm\": \"21069090\",\n              \"cfop\": \"5102\",\n              \"unidade\": \"UN\",\n              \"quantidade\": \"3\",\n              \"valor_unitario\": \"33.3333\",\n              \"valor_bruto\": \"100.00\",\n              \"icms\": {\n                  \"origem\": \"0\",\n                  \"csosn\": \"102\"\n              },\n              \"pis\": {\n                  \"cst\": \"07\"\n              },\n              \"cofins\": {\n                  \"cst\": \"07\"\n              }\n          }\n      ],\n      \"pagamentos\": [\n          {\n              \"forma\": \"pix\",\n              \"valor\": \"100.00\"\n          }\n      ]\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfe',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\", 'Idempotency-Key': 'pedido-1001'},\n    json={\n        \"ref\": \"pedido-1001\",\n        \"natureza_operacao\": \"VENDA DE MERCADORIA\",\n        \"destinatario\": {\n            \"cnpj\": \"12ABC34501DE35\",\n            \"nome\": \"COMERCIO FICTICIO LTDA\",\n            \"inscricao_estadual\": \"110042490114\",\n            \"email\": \"compras@cliente.test\",\n            \"endereco\": {\n                \"logradouro\": \"RUA DO CLIENTE\",\n                \"numero\": \"55\",\n                \"bairro\": \"CENTRO\",\n                \"codigo_municipio\": \"3550308\",\n                \"municipio\": \"SAO PAULO\",\n                \"uf\": \"SP\",\n                \"cep\": \"01001000\"\n            }\n        },\n        \"itens\": [\n            {\n                \"codigo\": \"P001\",\n                \"descricao\": \"PRODUTO FICTICIO\",\n                \"ncm\": \"21069090\",\n                \"cfop\": \"5102\",\n                \"unidade\": \"UN\",\n                \"quantidade\": \"3\",\n                \"valor_unitario\": \"33.3333\",\n                \"valor_bruto\": \"100.00\",\n                \"icms\": {\n                    \"origem\": \"0\",\n                    \"csosn\": \"102\"\n                },\n                \"pis\": {\n                    \"cst\": \"07\"\n                },\n                \"cofins\": {\n                    \"cst\": \"07\"\n                }\n            }\n        ],\n        \"pagamentos\": [\n            {\n                \"forma\": \"pix\",\n                \"valor\": \"100.00\"\n            }\n        ]\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfe\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Headers.Add(\"Idempotency-Key\", \"pedido-1001\");\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"pedido-1001\"\",\"\"natureza_operacao\"\":\"\"VENDA DE MERCADORIA\"\",\"\"destinatario\"\":{\"\"cnpj\"\":\"\"12ABC34501DE35\"\",\"\"nome\"\":\"\"COMERCIO FICTICIO LTDA\"\",\"\"inscricao_estadual\"\":\"\"110042490114\"\",\"\"email\"\":\"\"compras@cliente.test\"\",\"\"endereco\"\":{\"\"logradouro\"\":\"\"RUA DO CLIENTE\"\",\"\"numero\"\":\"\"55\"\",\"\"bairro\"\":\"\"CENTRO\"\",\"\"codigo_municipio\"\":\"\"3550308\"\",\"\"municipio\"\":\"\"SAO PAULO\"\",\"\"uf\"\":\"\"SP\"\",\"\"cep\"\":\"\"01001000\"\"}},\"\"itens\"\":[{\"\"codigo\"\":\"\"P001\"\",\"\"descricao\"\":\"\"PRODUTO FICTICIO\"\",\"\"ncm\"\":\"\"21069090\"\",\"\"cfop\"\":\"\"5102\"\",\"\"unidade\"\":\"\"UN\"\",\"\"quantidade\"\":\"\"3\"\",\"\"valor_unitario\"\":\"\"33.3333\"\",\"\"valor_bruto\"\":\"\"100.00\"\",\"\"icms\"\":{\"\"origem\"\":\"\"0\"\",\"\"csosn\"\":\"\"102\"\"},\"\"pis\"\":{\"\"cst\"\":\"\"07\"\"},\"\"cofins\"\":{\"\"cst\"\":\"\"07\"\"}}],\"\"pagamentos\"\":[{\"\"forma\"\":\"\"pix\"\",\"\"valor\"\":\"\"100.00\"\"}]}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.CustomHeaders['Idempotency-Key'] := 'pedido-1001';\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"pedido-1001\",\"natureza_operacao\":\"VENDA DE MERCADORIA\",\"destinatario\":{\"cnpj\":\"12ABC34501DE35\",\"nome\":\"COMERCIO FICTICIO LTDA\",\"inscricao_estadual\":\"110042490114\",\"email\":\"compras@cliente.test\",\"endereco\":{\"logradouro\":\"RUA DO CLIENTE\",\"numero\":\"55\",\"bairro\":\"CENTRO\",\"codigo_municipio\":\"3550308\",\"municipio\":\"SAO PAULO\",\"uf\":\"SP\",\"cep\":\"01001000\"}},\"itens\":[{\"codigo\":\"P001\",\"descricao\":\"PRODUTO FICTICIO\",\"ncm\":\"21069090\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"3\",\"valor_unitario\":\"33.3333\",\"valor_bruto\":\"100.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"pix\",\"valor\":\"100.00\"}]}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfe', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]},"get":{"tags":["NF-e"],"summary":"Listar NF-e","description":"Filtros: status, emitente_id, ref, chave, serie, numero, desde, ate. Paginação por cursor.","operationId":"listar_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListaDocumentos"}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string"}},{"name":"emitente_id","in":"query","required":false,"schema":{"type":"string"}},{"name":"ref","in":"query","required":false,"schema":{"type":"string"}},{"name":"chave","in":"query","required":false,"schema":{"type":"string"}},{"name":"serie","in":"query","required":false,"schema":{"type":"string"}},{"name":"numero","in":"query","required":false,"schema":{"type":"string"}},{"name":"desde","in":"query","required":false,"schema":{"type":"string"}},{"name":"ate","in":"query","required":false,"schema":{"type":"string"}},{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/nfe/validar":{"post":{"tags":["NF-e"],"summary":"Validar NF-e (sem emitir)","description":"Roda normalização, cálculo e validação SEM reservar número nem transmitir. Sempre 200 com `valido`.","operationId":"validar_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Validacao"}}}},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfe"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfe/validar' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"pedido-1001\",\"natureza_operacao\":\"VENDA DE MERCADORIA\",\"destinatario\":{\"cnpj\":\"12ABC34501DE35\",\"nome\":\"COMERCIO FICTICIO LTDA\",\"inscricao_estadual\":\"110042490114\",\"email\":\"compras@cliente.test\",\"endereco\":{\"logradouro\":\"RUA DO CLIENTE\",\"numero\":\"55\",\"bairro\":\"CENTRO\",\"codigo_municipio\":\"3550308\",\"municipio\":\"SAO PAULO\",\"uf\":\"SP\",\"cep\":\"01001000\"}},\"itens\":[{\"codigo\":\"P001\",\"descricao\":\"PRODUTO FICTICIO\",\"ncm\":\"21069090\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"3\",\"valor_unitario\":\"33.3333\",\"valor_bruto\":\"100.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"pix\",\"valor\":\"100.00\"}]}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfe/validar', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"ref\":\"pedido-1001\",\"natureza_operacao\":\"VENDA DE MERCADORIA\",\"destinatario\":{\"cnpj\":\"12ABC34501DE35\",\"nome\":\"COMERCIO FICTICIO LTDA\",\"inscricao_estadual\":\"110042490114\",\"email\":\"compras@cliente.test\",\"endereco\":{\"logradouro\":\"RUA DO CLIENTE\",\"numero\":\"55\",\"bairro\":\"CENTRO\",\"codigo_municipio\":\"3550308\",\"municipio\":\"SAO PAULO\",\"uf\":\"SP\",\"cep\":\"01001000\"}},\"itens\":[{\"codigo\":\"P001\",\"descricao\":\"PRODUTO FICTICIO\",\"ncm\":\"21069090\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"3\",\"valor_unitario\":\"33.3333\",\"valor_bruto\":\"100.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"pix\",\"valor\":\"100.00\"}]}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfe/validar', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"ref\": \"pedido-1001\",\n      \"natureza_operacao\": \"VENDA DE MERCADORIA\",\n      \"destinatario\": {\n          \"cnpj\": \"12ABC34501DE35\",\n          \"nome\": \"COMERCIO FICTICIO LTDA\",\n          \"inscricao_estadual\": \"110042490114\",\n          \"email\": \"compras@cliente.test\",\n          \"endereco\": {\n              \"logradouro\": \"RUA DO CLIENTE\",\n              \"numero\": \"55\",\n              \"bairro\": \"CENTRO\",\n              \"codigo_municipio\": \"3550308\",\n              \"municipio\": \"SAO PAULO\",\n              \"uf\": \"SP\",\n              \"cep\": \"01001000\"\n          }\n      },\n      \"itens\": [\n          {\n              \"codigo\": \"P001\",\n              \"descricao\": \"PRODUTO FICTICIO\",\n              \"ncm\": \"21069090\",\n              \"cfop\": \"5102\",\n              \"unidade\": \"UN\",\n              \"quantidade\": \"3\",\n              \"valor_unitario\": \"33.3333\",\n              \"valor_bruto\": \"100.00\",\n              \"icms\": {\n                  \"origem\": \"0\",\n                  \"csosn\": \"102\"\n              },\n              \"pis\": {\n                  \"cst\": \"07\"\n              },\n              \"cofins\": {\n                  \"cst\": \"07\"\n              }\n          }\n      ],\n      \"pagamentos\": [\n          {\n              \"forma\": \"pix\",\n              \"valor\": \"100.00\"\n          }\n      ]\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfe/validar',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"ref\": \"pedido-1001\",\n        \"natureza_operacao\": \"VENDA DE MERCADORIA\",\n        \"destinatario\": {\n            \"cnpj\": \"12ABC34501DE35\",\n            \"nome\": \"COMERCIO FICTICIO LTDA\",\n            \"inscricao_estadual\": \"110042490114\",\n            \"email\": \"compras@cliente.test\",\n            \"endereco\": {\n                \"logradouro\": \"RUA DO CLIENTE\",\n                \"numero\": \"55\",\n                \"bairro\": \"CENTRO\",\n                \"codigo_municipio\": \"3550308\",\n                \"municipio\": \"SAO PAULO\",\n                \"uf\": \"SP\",\n                \"cep\": \"01001000\"\n            }\n        },\n        \"itens\": [\n            {\n                \"codigo\": \"P001\",\n                \"descricao\": \"PRODUTO FICTICIO\",\n                \"ncm\": \"21069090\",\n                \"cfop\": \"5102\",\n                \"unidade\": \"UN\",\n                \"quantidade\": \"3\",\n                \"valor_unitario\": \"33.3333\",\n                \"valor_bruto\": \"100.00\",\n                \"icms\": {\n                    \"origem\": \"0\",\n                    \"csosn\": \"102\"\n                },\n                \"pis\": {\n                    \"cst\": \"07\"\n                },\n                \"cofins\": {\n                    \"cst\": \"07\"\n                }\n            }\n        ],\n        \"pagamentos\": [\n            {\n                \"forma\": \"pix\",\n                \"valor\": \"100.00\"\n            }\n        ]\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfe/validar\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"pedido-1001\"\",\"\"natureza_operacao\"\":\"\"VENDA DE MERCADORIA\"\",\"\"destinatario\"\":{\"\"cnpj\"\":\"\"12ABC34501DE35\"\",\"\"nome\"\":\"\"COMERCIO FICTICIO LTDA\"\",\"\"inscricao_estadual\"\":\"\"110042490114\"\",\"\"email\"\":\"\"compras@cliente.test\"\",\"\"endereco\"\":{\"\"logradouro\"\":\"\"RUA DO CLIENTE\"\",\"\"numero\"\":\"\"55\"\",\"\"bairro\"\":\"\"CENTRO\"\",\"\"codigo_municipio\"\":\"\"3550308\"\",\"\"municipio\"\":\"\"SAO PAULO\"\",\"\"uf\"\":\"\"SP\"\",\"\"cep\"\":\"\"01001000\"\"}},\"\"itens\"\":[{\"\"codigo\"\":\"\"P001\"\",\"\"descricao\"\":\"\"PRODUTO FICTICIO\"\",\"\"ncm\"\":\"\"21069090\"\",\"\"cfop\"\":\"\"5102\"\",\"\"unidade\"\":\"\"UN\"\",\"\"quantidade\"\":\"\"3\"\",\"\"valor_unitario\"\":\"\"33.3333\"\",\"\"valor_bruto\"\":\"\"100.00\"\",\"\"icms\"\":{\"\"origem\"\":\"\"0\"\",\"\"csosn\"\":\"\"102\"\"},\"\"pis\"\":{\"\"cst\"\":\"\"07\"\"},\"\"cofins\"\":{\"\"cst\"\":\"\"07\"\"}}],\"\"pagamentos\"\":[{\"\"forma\"\":\"\"pix\"\",\"\"valor\"\":\"\"100.00\"\"}]}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"pedido-1001\",\"natureza_operacao\":\"VENDA DE MERCADORIA\",\"destinatario\":{\"cnpj\":\"12ABC34501DE35\",\"nome\":\"COMERCIO FICTICIO LTDA\",\"inscricao_estadual\":\"110042490114\",\"email\":\"compras@cliente.test\",\"endereco\":{\"logradouro\":\"RUA DO CLIENTE\",\"numero\":\"55\",\"bairro\":\"CENTRO\",\"codigo_municipio\":\"3550308\",\"municipio\":\"SAO PAULO\",\"uf\":\"SP\",\"cep\":\"01001000\"}},\"itens\":[{\"codigo\":\"P001\",\"descricao\":\"PRODUTO FICTICIO\",\"ncm\":\"21069090\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"3\",\"valor_unitario\":\"33.3333\",\"valor_bruto\":\"100.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"pix\",\"valor\":\"100.00\"}]}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfe/validar', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfe/previa":{"post":{"tags":["NF-e"],"summary":"Prévia do DANFE (PDF)","description":"PDF com tarja de prévia, sem número reservado.","operationId":"previa_nfe","responses":{"200":{"description":"PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfe"}}}}}}},"/nfe/{id}":{"get":{"tags":["NF-e"],"summary":"Consultar NF-e","description":"Estado atual. `?aguardar=N` (0 a 25 s) segura a resposta até o resultado de nota em processamento ou em contingência (só em simulação: vencido o atraso, transmite na hora; em homologação e produção o GET só lê, quem transmite é o reconciliador). `?incluir=payload` traz o payload enviado.","operationId":"consultar_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/Documento"}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Aguardar"},{"name":"incluir","in":"query","required":false,"schema":{"type":"string","enum":["payload"]}}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]},"put":{"tags":["NF-e"],"summary":"Corrigir NF-e rejeitada","description":"Reenvia com o MESMO número (rejeição não consome número). Só em `rejeitada`.","operationId":"corrigir_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Aguardar"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfe"}}}}}},"delete":{"tags":["NF-e"],"summary":"Descartar NF-e rejeitada","description":"Desiste da nota rejeitada. O número volta para o pool e é reaproveitado.","operationId":"descartar_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfe/{id}/xml":{"get":{"tags":["NF-e"],"summary":"Baixar XML","description":"XML autorizado (nfeProc) em streaming.","operationId":"xml_nfe","responses":{"200":{"description":"XML","content":{"application/xml":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfe/{id}/danfe":{"get":{"tags":["NF-e"],"summary":"Baixar DANFE (PDF)","description":"PDF em streaming.","operationId":"danfe_nfe","responses":{"200":{"description":"PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfe/{id}/cancelamento":{"post":{"tags":["NF-e"],"summary":"Cancelar NF-e","description":"Evento 110111. Prazo: 24 h (NF-e) / 30 min (NFC-e).","operationId":"cancelar_nfe","responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Evento"}}}},"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Evento"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cancelamento"},"example":{"justificativa":"Pedido cancelado pelo cliente antes do envio."}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"justificativa\":\"Pedido cancelado pelo cliente antes do envio.\"}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"justificativa\":\"Pedido cancelado pelo cliente antes do envio.\"}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"justificativa\": \"Pedido cancelado pelo cliente antes do envio.\"\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"justificativa\": \"Pedido cancelado pelo cliente antes do envio.\"\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"justificativa\"\":\"\"Pedido cancelado pelo cliente antes do envio.\"\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"justificativa\":\"Pedido cancelado pelo cliente antes do envio.\"}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfe/{id}/eventos":{"get":{"tags":["NF-e"],"summary":"Listar eventos","description":"Cancelamento, carta de correção, substituição.","operationId":"eventos_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Evento"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/nfe/{id}/consulta":{"post":{"tags":["NF-e"],"summary":"Reconsultar na SEFAZ","description":"Pergunta de novo à SEFAZ (útil depois de queda).","operationId":"reconsultar_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfe/{id}/email":{"post":{"tags":["NF-e"],"summary":"Enviar por e-mail","description":"XML + PDF para o destinatário da nota e as cópias do emitente, ou para `destinatarios` (1 a 10; `emails` também é aceito).","operationId":"email_nfe","responses":{"202":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"enviado":{"type":"boolean"},"destinatarios":{"type":"array","items":{"type":"string"}}}}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"destinatarios":{"type":"array","items":{"type":"string","format":"email"},"minItems":1,"maxItems":10}}}}}}}},"/nfe/{id}/explicar":{"post":{"tags":["NF-e"],"summary":"Explicar a rejeição","description":"Explicação em português, campo do seu payload e como corrigir.","operationId":"explicar_nfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"explicacao":{"type":"string"},"itens":{"type":"array","items":{"$ref":"#/components/schemas/ErroCampo"}}},"additionalProperties":true}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfe/{id}/carta-correcao":{"post":{"tags":["NF-e"],"summary":"Carta de correção","description":"Evento 110110 (até 20 por nota; vale a última). A 21ª dá 409 limite_cartas.","operationId":"carta_correcao_nfe","responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Evento"}}}},"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Evento"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"409":{"$ref":"#/components/responses/409"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CartaCorrecao"},"example":{"texto":"Onde se lê volume 2 caixas, leia-se 3 caixas."}}}}}},"/nfce":{"post":{"tags":["NFC-e"],"summary":"Emitir NFC-e","description":"Valida, calcula, numera, assina e transmite. 202 + `processando` (acompanhe por GET, webhook ou `?aguardar=`); 201 quando já tem o resultado; 200 + Idempotent-Replayed quando a `ref` já existia com o mesmo payload. A NFC-e responde síncrona por padrão (aguardar=20): em geral o 201 já vem autorizado. Rejeitada: corrija com PUT no MESMO número.","operationId":"emitir_nfce","responses":{"201":{"description":"Resultado final (autorizada, rejeitada, denegada ou contingência).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/Documento"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"202":{"description":"Aceita, processando.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/DocumentoProcessando"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"200":{"description":"Replay da mesma ref/Idempotency-Key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/Documento"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Aguardar"},{"$ref":"#/components/parameters/IdempotencyKey"},{"$ref":"#/components/parameters/Simular"},{"$ref":"#/components/parameters/SimularAtraso"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfce"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfce' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Idempotency-Key: pedido-1001' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"caixa-3-cupom-88\",\"itens\":[{\"codigo\":\"CAFE01\",\"descricao\":\"CAFE ESPRESSO\",\"ncm\":\"21011110\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"2\",\"valor_unitario\":\"6.50\",\"valor_bruto\":\"13.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"dinheiro\",\"valor\":\"20.00\"}],\"troco\":\"7.00\"}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfce', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n        'Idempotency-Key' => 'pedido-1001',\n    ],\n    'json' => json_decode('{\"ref\":\"caixa-3-cupom-88\",\"itens\":[{\"codigo\":\"CAFE01\",\"descricao\":\"CAFE ESPRESSO\",\"ncm\":\"21011110\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"2\",\"valor_unitario\":\"6.50\",\"valor_bruto\":\"13.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"dinheiro\",\"valor\":\"20.00\"}],\"troco\":\"7.00\"}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfce', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json', 'Idempotency-Key': 'pedido-1001' },\n  body: JSON.stringify({\n      \"ref\": \"caixa-3-cupom-88\",\n      \"itens\": [\n          {\n              \"codigo\": \"CAFE01\",\n              \"descricao\": \"CAFE ESPRESSO\",\n              \"ncm\": \"21011110\",\n              \"cfop\": \"5102\",\n              \"unidade\": \"UN\",\n              \"quantidade\": \"2\",\n              \"valor_unitario\": \"6.50\",\n              \"valor_bruto\": \"13.00\",\n              \"icms\": {\n                  \"origem\": \"0\",\n                  \"csosn\": \"102\"\n              },\n              \"pis\": {\n                  \"cst\": \"07\"\n              },\n              \"cofins\": {\n                  \"cst\": \"07\"\n              }\n          }\n      ],\n      \"pagamentos\": [\n          {\n              \"forma\": \"dinheiro\",\n              \"valor\": \"20.00\"\n          }\n      ],\n      \"troco\": \"7.00\"\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfce',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\", 'Idempotency-Key': 'pedido-1001'},\n    json={\n        \"ref\": \"caixa-3-cupom-88\",\n        \"itens\": [\n            {\n                \"codigo\": \"CAFE01\",\n                \"descricao\": \"CAFE ESPRESSO\",\n                \"ncm\": \"21011110\",\n                \"cfop\": \"5102\",\n                \"unidade\": \"UN\",\n                \"quantidade\": \"2\",\n                \"valor_unitario\": \"6.50\",\n                \"valor_bruto\": \"13.00\",\n                \"icms\": {\n                    \"origem\": \"0\",\n                    \"csosn\": \"102\"\n                },\n                \"pis\": {\n                    \"cst\": \"07\"\n                },\n                \"cofins\": {\n                    \"cst\": \"07\"\n                }\n            }\n        ],\n        \"pagamentos\": [\n            {\n                \"forma\": \"dinheiro\",\n                \"valor\": \"20.00\"\n            }\n        ],\n        \"troco\": \"7.00\"\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfce\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Headers.Add(\"Idempotency-Key\", \"pedido-1001\");\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"caixa-3-cupom-88\"\",\"\"itens\"\":[{\"\"codigo\"\":\"\"CAFE01\"\",\"\"descricao\"\":\"\"CAFE ESPRESSO\"\",\"\"ncm\"\":\"\"21011110\"\",\"\"cfop\"\":\"\"5102\"\",\"\"unidade\"\":\"\"UN\"\",\"\"quantidade\"\":\"\"2\"\",\"\"valor_unitario\"\":\"\"6.50\"\",\"\"valor_bruto\"\":\"\"13.00\"\",\"\"icms\"\":{\"\"origem\"\":\"\"0\"\",\"\"csosn\"\":\"\"102\"\"},\"\"pis\"\":{\"\"cst\"\":\"\"07\"\"},\"\"cofins\"\":{\"\"cst\"\":\"\"07\"\"}}],\"\"pagamentos\"\":[{\"\"forma\"\":\"\"dinheiro\"\",\"\"valor\"\":\"\"20.00\"\"}],\"\"troco\"\":\"\"7.00\"\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.CustomHeaders['Idempotency-Key'] := 'pedido-1001';\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"caixa-3-cupom-88\",\"itens\":[{\"codigo\":\"CAFE01\",\"descricao\":\"CAFE ESPRESSO\",\"ncm\":\"21011110\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"2\",\"valor_unitario\":\"6.50\",\"valor_bruto\":\"13.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"dinheiro\",\"valor\":\"20.00\"}],\"troco\":\"7.00\"}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfce', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]},"get":{"tags":["NFC-e"],"summary":"Listar NFC-e","description":"Filtros: status, emitente_id, ref, chave, serie, numero, desde, ate. Paginação por cursor.","operationId":"listar_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListaDocumentos"}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string"}},{"name":"emitente_id","in":"query","required":false,"schema":{"type":"string"}},{"name":"ref","in":"query","required":false,"schema":{"type":"string"}},{"name":"chave","in":"query","required":false,"schema":{"type":"string"}},{"name":"serie","in":"query","required":false,"schema":{"type":"string"}},{"name":"numero","in":"query","required":false,"schema":{"type":"string"}},{"name":"desde","in":"query","required":false,"schema":{"type":"string"}},{"name":"ate","in":"query","required":false,"schema":{"type":"string"}},{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/nfce/validar":{"post":{"tags":["NFC-e"],"summary":"Validar NFC-e (sem emitir)","description":"Roda normalização, cálculo e validação SEM reservar número nem transmitir. Sempre 200 com `valido`.","operationId":"validar_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Validacao"}}}},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfce"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfce/validar' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"caixa-3-cupom-88\",\"itens\":[{\"codigo\":\"CAFE01\",\"descricao\":\"CAFE ESPRESSO\",\"ncm\":\"21011110\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"2\",\"valor_unitario\":\"6.50\",\"valor_bruto\":\"13.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"dinheiro\",\"valor\":\"20.00\"}],\"troco\":\"7.00\"}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfce/validar', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"ref\":\"caixa-3-cupom-88\",\"itens\":[{\"codigo\":\"CAFE01\",\"descricao\":\"CAFE ESPRESSO\",\"ncm\":\"21011110\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"2\",\"valor_unitario\":\"6.50\",\"valor_bruto\":\"13.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"dinheiro\",\"valor\":\"20.00\"}],\"troco\":\"7.00\"}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfce/validar', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"ref\": \"caixa-3-cupom-88\",\n      \"itens\": [\n          {\n              \"codigo\": \"CAFE01\",\n              \"descricao\": \"CAFE ESPRESSO\",\n              \"ncm\": \"21011110\",\n              \"cfop\": \"5102\",\n              \"unidade\": \"UN\",\n              \"quantidade\": \"2\",\n              \"valor_unitario\": \"6.50\",\n              \"valor_bruto\": \"13.00\",\n              \"icms\": {\n                  \"origem\": \"0\",\n                  \"csosn\": \"102\"\n              },\n              \"pis\": {\n                  \"cst\": \"07\"\n              },\n              \"cofins\": {\n                  \"cst\": \"07\"\n              }\n          }\n      ],\n      \"pagamentos\": [\n          {\n              \"forma\": \"dinheiro\",\n              \"valor\": \"20.00\"\n          }\n      ],\n      \"troco\": \"7.00\"\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfce/validar',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"ref\": \"caixa-3-cupom-88\",\n        \"itens\": [\n            {\n                \"codigo\": \"CAFE01\",\n                \"descricao\": \"CAFE ESPRESSO\",\n                \"ncm\": \"21011110\",\n                \"cfop\": \"5102\",\n                \"unidade\": \"UN\",\n                \"quantidade\": \"2\",\n                \"valor_unitario\": \"6.50\",\n                \"valor_bruto\": \"13.00\",\n                \"icms\": {\n                    \"origem\": \"0\",\n                    \"csosn\": \"102\"\n                },\n                \"pis\": {\n                    \"cst\": \"07\"\n                },\n                \"cofins\": {\n                    \"cst\": \"07\"\n                }\n            }\n        ],\n        \"pagamentos\": [\n            {\n                \"forma\": \"dinheiro\",\n                \"valor\": \"20.00\"\n            }\n        ],\n        \"troco\": \"7.00\"\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfce/validar\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"caixa-3-cupom-88\"\",\"\"itens\"\":[{\"\"codigo\"\":\"\"CAFE01\"\",\"\"descricao\"\":\"\"CAFE ESPRESSO\"\",\"\"ncm\"\":\"\"21011110\"\",\"\"cfop\"\":\"\"5102\"\",\"\"unidade\"\":\"\"UN\"\",\"\"quantidade\"\":\"\"2\"\",\"\"valor_unitario\"\":\"\"6.50\"\",\"\"valor_bruto\"\":\"\"13.00\"\",\"\"icms\"\":{\"\"origem\"\":\"\"0\"\",\"\"csosn\"\":\"\"102\"\"},\"\"pis\"\":{\"\"cst\"\":\"\"07\"\"},\"\"cofins\"\":{\"\"cst\"\":\"\"07\"\"}}],\"\"pagamentos\"\":[{\"\"forma\"\":\"\"dinheiro\"\",\"\"valor\"\":\"\"20.00\"\"}],\"\"troco\"\":\"\"7.00\"\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"caixa-3-cupom-88\",\"itens\":[{\"codigo\":\"CAFE01\",\"descricao\":\"CAFE ESPRESSO\",\"ncm\":\"21011110\",\"cfop\":\"5102\",\"unidade\":\"UN\",\"quantidade\":\"2\",\"valor_unitario\":\"6.50\",\"valor_bruto\":\"13.00\",\"icms\":{\"origem\":\"0\",\"csosn\":\"102\"},\"pis\":{\"cst\":\"07\"},\"cofins\":{\"cst\":\"07\"}}],\"pagamentos\":[{\"forma\":\"dinheiro\",\"valor\":\"20.00\"}],\"troco\":\"7.00\"}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfce/validar', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfce/previa":{"post":{"tags":["NFC-e"],"summary":"Prévia do DANFCE (PDF)","description":"PDF com tarja de prévia, sem número reservado.","operationId":"previa_nfce","responses":{"200":{"description":"PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfce"}}}}}}},"/nfce/{id}":{"get":{"tags":["NFC-e"],"summary":"Consultar NFC-e","description":"Estado atual. `?aguardar=N` (0 a 25 s) segura a resposta até o resultado de nota em processamento ou em contingência (só em simulação: vencido o atraso, transmite na hora; em homologação e produção o GET só lê, quem transmite é o reconciliador). `?incluir=payload` traz o payload enviado.","operationId":"consultar_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"},"examples":{"exemplo":{"$ref":"#/components/examples/Documento"}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Aguardar"},{"name":"incluir","in":"query","required":false,"schema":{"type":"string","enum":["payload"]}}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]},"put":{"tags":["NFC-e"],"summary":"Corrigir NFC-e rejeitada","description":"Reenvia com o MESMO número (rejeição não consome número). Só em `rejeitada`.","operationId":"corrigir_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Aguardar"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfe"},"examples":{"exemplo":{"$ref":"#/components/examples/PayloadNfce"}}}}}},"delete":{"tags":["NFC-e"],"summary":"Descartar NFC-e rejeitada","description":"Desiste da nota rejeitada. O número volta para o pool e é reaproveitado.","operationId":"descartar_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfce/{id}/xml":{"get":{"tags":["NFC-e"],"summary":"Baixar XML","description":"XML autorizado (nfeProc) em streaming.","operationId":"xml_nfce","responses":{"200":{"description":"XML","content":{"application/xml":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfce/{id}/danfce":{"get":{"tags":["NFC-e"],"summary":"Baixar DANFCE (PDF)","description":"PDF em streaming. `?largura=58|80`.","operationId":"danfce_nfce","responses":{"200":{"description":"PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"name":"largura","in":"query","required":false,"schema":{"type":"integer","enum":[58,80]}}]}},"/nfce/{id}/cancelamento":{"post":{"tags":["NFC-e"],"summary":"Cancelar NFC-e","description":"Evento 110111. Prazo: 24 h (NF-e) / 30 min (NFC-e).","operationId":"cancelar_nfce","responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Evento"}}}},"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Evento"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Cancelamento"},"example":{"justificativa":"Pedido cancelado pelo cliente antes do envio."}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"justificativa\":\"Pedido cancelado pelo cliente antes do envio.\"}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"justificativa\":\"Pedido cancelado pelo cliente antes do envio.\"}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"justificativa\": \"Pedido cancelado pelo cliente antes do envio.\"\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"justificativa\": \"Pedido cancelado pelo cliente antes do envio.\"\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"justificativa\"\":\"\"Pedido cancelado pelo cliente antes do envio.\"\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"justificativa\":\"Pedido cancelado pelo cliente antes do envio.\"}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfce/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/cancelamento', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfce/{id}/eventos":{"get":{"tags":["NFC-e"],"summary":"Listar eventos","description":"Cancelamento, carta de correção, substituição.","operationId":"eventos_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Evento"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/nfce/{id}/consulta":{"post":{"tags":["NFC-e"],"summary":"Reconsultar na SEFAZ","description":"Pergunta de novo à SEFAZ (útil depois de queda).","operationId":"reconsultar_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Documento"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfce/{id}/email":{"post":{"tags":["NFC-e"],"summary":"Enviar por e-mail","description":"XML + PDF para o destinatário da nota e as cópias do emitente, ou para `destinatarios` (1 a 10; `emails` também é aceito).","operationId":"email_nfce","responses":{"202":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"enviado":{"type":"boolean"},"destinatarios":{"type":"array","items":{"type":"string"}}}}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"destinatarios":{"type":"array","items":{"type":"string","format":"email"},"minItems":1,"maxItems":10}}}}}}}},"/nfce/{id}/explicar":{"post":{"tags":["NFC-e"],"summary":"Explicar a rejeição","description":"Explicação em português, campo do seu payload e como corrigir.","operationId":"explicar_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"explicacao":{"type":"string"},"itens":{"type":"array","items":{"$ref":"#/components/schemas/ErroCampo"}}},"additionalProperties":true}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/nfce/{id}/escpos":{"get":{"tags":["NFC-e"],"summary":"Cupom ESC/POS","description":"Bytes ESC/POS em base64 para impressora térmica.","operationId":"escpos_nfce","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"largura":{"type":"integer"},"formato":{"type":"string","const":"escpos"},"conteudo_base64":{"type":"string","contentEncoding":"base64"}}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"name":"largura","in":"query","required":false,"schema":{"type":"integer","enum":[58,80]}}]}},"/inutilizacoes":{"post":{"tags":["Inutilização"],"summary":"Inutilizar faixa de números","description":"Faixa de números que nunca foi usada (pulou numeração).","operationId":"inutilizar","responses":{"200":{"description":"Mesma faixa já pedida: devolve o pedido existente com Idempotent-Replayed: true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inutilizacao"}}}},"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inutilizacao"}}}},"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inutilizacao"}}}},"422":{"$ref":"#/components/responses/422"},"409":{"$ref":"#/components/responses/409"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InutilizacaoEntrada"},"example":{"modelo":"55","serie":1,"numero_inicial":120,"numero_final":125,"justificativa":"Falha no sistema pulou a numeração desta série."}}}}},"get":{"tags":["Inutilização"],"summary":"Listar inutilizações","description":"","operationId":"listar_inutilizacoes","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Inutilizacao"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/inutilizacoes/{id}":{"get":{"tags":["Inutilização"],"summary":"Consultar inutilização","description":"","operationId":"consultar_inutilizacao","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Inutilizacao"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/emitentes":{"get":{"tags":["Emitentes"],"summary":"Listar emitentes","description":"Empresas que emitem nesta conta (revenda: várias).","operationId":"listar_emitentes","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Emitente"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]},"post":{"tags":["Emitentes"],"summary":"Cadastrar emitente","description":"Cria o emitente e as séries 1 de NF-e e NFC-e.","operationId":"criar_emitente","responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Emitente"}}}},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmitenteEntrada"}}}}}},"/emitentes/{id}":{"get":{"tags":["Emitentes"],"summary":"Consultar emitente","description":"","operationId":"consultar_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Emitente"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}]},"put":{"tags":["Emitentes"],"summary":"Atualizar emitente","description":"Campos omitidos não mudam.","operationId":"atualizar_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Emitente"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmitenteEntrada"}}}}},"delete":{"tags":["Emitentes"],"summary":"Desativar emitente","description":"Inativa o emitente (ativo: false): as notas emitidas continuam consultáveis e nova emissão dá 422 emitente_inativo. Reative com PUT {\"ativo\": true}.","operationId":"excluir_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Emitente"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}]}},"/emitentes/{id}/certificado":{"put":{"tags":["Emitentes"],"summary":"Enviar certificado A1","description":"O .pfx e a senha são selados; nunca voltam em resposta nem aparecem em log.","operationId":"certificado_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Certificado"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CertificadoEntrada"}}}}}},"/emitentes/{id}/csc":{"put":{"tags":["Emitentes"],"summary":"Cadastrar CSC (NFC-e)","description":"Opcional: o QR Code v3 não precisa de CSC.","operationId":"csc_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ambiente":{"type":"string"},"id_token":{"type":"string"},"ativo":{"type":"boolean"}},"additionalProperties":true}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ambiente":{"type":"string","enum":["homologacao","producao"]},"id_token":{"type":"string"},"csc":{"type":"string","format":"password"}},"required":["ambiente","id_token","csc"]}}}}}},"/emitentes/{id}/numeracao":{"put":{"tags":["Emitentes"],"summary":"Ajustar numeração","description":"Define o próximo número da série (só para frente).","operationId":"numeracao_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"modelo":{"type":"string","enum":["55","65","nfse"],"description":"NFS-e: série da DPS 1..89999, nDPS 1..999999999."},"serie":{"type":"integer"},"proximo_numero":{"type":"integer"}},"required":["modelo","serie","proximo_numero"]}}}}}},"/emitentes/{id}/testar-conexao":{"post":{"tags":["Emitentes"],"summary":"Testar conexão","description":"Prontidão + certificado/assinatura + status da SEFAZ (55 e 65).","operationId":"testar_conexao_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Prontidao"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}]}},"/emitentes/{id}/prontidao":{"get":{"tags":["Emitentes"],"summary":"Prontidão para emitir","description":"O que falta para emitir neste ambiente. Com modelo=55|65 a IE é erro; com modelo=nfse ela não entra.","operationId":"prontidao_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Prontidao"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"},{"name":"modelo","in":"query","required":false,"schema":{"type":"string","enum":["55","65","nfse"]}}]}},"/webhooks/eventos":{"get":{"tags":["Webhooks"],"summary":"Catálogo de eventos","description":"","operationId":"catalogo_webhooks","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/webhooks":{"get":{"tags":["Webhooks"],"summary":"Listar webhooks","description":"","operationId":"listar_webhooks","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]},"post":{"tags":["Webhooks"],"summary":"Criar webhook","description":"Devolve o segredo whsec_… UMA vez.","operationId":"criar_webhook","responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCriado"}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"eventos":{"type":"array","items":{"type":"string"}}},"required":["url"]},"example":{"url":"https://seu-sistema.test/madnotas","eventos":["nfe.autorizada","nfe.rejeitada"]}}}}}},"/webhooks/{id}":{"get":{"tags":["Webhooks"],"summary":"Consultar webhook","description":"","operationId":"consultar_webhook","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]},"put":{"tags":["Webhooks"],"summary":"Atualizar webhook","description":"","operationId":"atualizar_webhook","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Webhook"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"eventos":{"type":"array","items":{"type":"string"}},"ativo":{"type":"boolean"}}}}}}},"delete":{"tags":["Webhooks"],"summary":"Excluir webhook","description":"Para de entregar eventos a este endpoint.","operationId":"excluir_webhook","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"excluido":{"type":"boolean"}}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/webhooks/{id}/teste":{"post":{"tags":["Webhooks"],"summary":"Enviar evento de teste","description":"","operationId":"testar_webhook","responses":{"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Entrega"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/webhooks/{id}/rotacionar-segredo":{"post":{"tags":["Webhooks"],"summary":"Rotacionar segredo","description":"Novo whsec_…; o antigo vale por 24 h.","operationId":"rotacionar_segredo_webhook","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCriado"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"}]}},"/webhooks/{id}/entregas":{"get":{"tags":["Webhooks"],"summary":"Entregas do webhook","description":"","operationId":"entregas_webhook","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Entrega"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/webhooks/{id}/entregas/{entrega}":{"get":{"tags":["Webhooks"],"summary":"Detalhe da entrega","description":"Corpo enviado e, por tentativa, requisição e resposta do seu servidor.","operationId":"detalhe_entrega","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EntregaDetalhe"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Id"},{"name":"entrega","in":"path","required":true,"schema":{"type":"string"}}]}},"/webhooks/entregas":{"get":{"tags":["Webhooks"],"summary":"Todas as entregas","description":"","operationId":"entregas","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Entrega"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/webhooks/entregas/{entrega}/reenviar":{"post":{"tags":["Webhooks"],"summary":"Reenviar entrega","description":"","operationId":"reenviar_entrega","responses":{"202":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Entrega"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"entrega","in":"path","required":true,"schema":{"type":"string"}}]}},"/utilitarios/chave/{chave}":{"get":{"tags":["Utilitários"],"summary":"Decodificar chave de acesso","description":"Confere o DV e mostra UF, CNPJ, modelo, série, número.","operationId":"decodificar_chave","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChaveAcesso"}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"chave","in":"path","required":true,"schema":{"type":"string"}}]}},"/utilitarios/ibscbs/calcular":{"post":{"tags":["Utilitários"],"summary":"Calcular IBS/CBS de um item","description":"Reforma tributária: alíquotas vigentes por UF/município.","operationId":"calcular_ibscbs","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}}},"/utilitarios/{tabela}":{"get":{"tags":["Utilitários"],"summary":"Buscar em tabela de referência","description":"NCM, CFOP, CEST, municípios IBGE, cClassTrib.","operationId":"buscar_referencia","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Referencia"}}}}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"tabela","in":"path","required":true,"schema":{"type":"string","enum":["ncm","cfop","cest","municipios","cclasstrib","ctribnac","nbs"]}},{"name":"q","in":"query","required":false,"schema":{"type":"string"}},{"$ref":"#/components/parameters/Limite"}]}},"/rejeicoes/{cstat}":{"get":{"tags":["Utilitários"],"summary":"Explicar código de rejeição","description":"Base de rejeições comentada.","operationId":"rejeicao","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Rejeicao"}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"cstat","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d{3}$"}}]}},"/ping":{"get":{"tags":["Conta"],"summary":"Testar a chave","description":"Responde com o ambiente e a empresa da chave.","operationId":"ping","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/ping' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/ping', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/ping', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/ping',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/ping\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/ping');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/conta/uso":{"get":{"tags":["Conta"],"summary":"Uso do mês","description":"Notas emitidas, franquia e excedente.","operationId":"uso","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Uso"}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}}}},"/logs":{"get":{"tags":["Conta"],"summary":"Logs da API","description":"Suas requisições (segredos sempre removidos).","operationId":"logs","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"type":"object","additionalProperties":true}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}}}}}},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}]}},"/simulacao/sefaz":{"post":{"tags":["Conta"],"summary":"Simular queda da SEFAZ","description":"Só com chave de simulação: põe um autorizador fora/lento por N minutos.","operationId":"simular_sefaz","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"uf":{"type":"string"},"modelo":{"type":"string","enum":["55","65"]},"estado":{"type":"string","enum":["fora","lento","normal"]},"minutos":{"type":"integer","minimum":1,"maximum":240}},"required":["uf","estado"]},{"type":"object","properties":{"autoridade":{"type":"string","const":"sefin_nacional"},"situacao":{"type":"string","enum":["fora","lento","normal"]},"minutos":{"type":"integer","minimum":1,"maximum":240}},"required":["autoridade","situacao"],"description":"NFS-e: derruba a Sefin Nacional simulada desta empresa.","additionalProperties":true}]}}}}}},"/sefaz/status":{"get":{"tags":["SEFAZ"],"summary":"Status dos autorizadores","description":"Público, sem chave. Atualizado a cada minuto.","operationId":"sefaz_status","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SefazStatus"}}}}},"security":[]}},"/sefaz/status/{uf}":{"get":{"tags":["SEFAZ"],"summary":"Status de uma UF","description":"Público, sem chave.","operationId":"sefaz_status_uf","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SefazStatus"}}}}},"parameters":[{"name":"uf","in":"path","required":true,"schema":{"type":"string","pattern":"^[A-Za-z]{2}$"}}],"security":[]}},"/openapi.json":{"get":{"tags":["SEFAZ"],"summary":"Este documento","description":"OpenAPI 3.1 (público, CORS liberado).","operationId":"openapi","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object"}}}}},"security":[]}},"/nfse":{"post":{"tags":["NFS-e"],"summary":"Emitir NFS-e","description":"Valida, calcula, numera a DPS, assina e transmite à Sefin Nacional. 201 com o resultado (autorizada ou rejeitada); 202 + processando (acompanhe por GET ?aguardar=, webhook nfse.*); 200 + Idempotent-Replayed quando a `ref` já existe com o mesmo payload. Rejeitada: corrija com PUT no MESMO id e nDPS. 422 não consome nDPS.","operationId":"emitir_nfse","responses":{"201":{"description":"Resultado final.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"},"examples":{"autorizada":{"$ref":"#/components/examples/Nfse"},"rejeitada":{"$ref":"#/components/examples/NfseRejeitada"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"202":{"description":"Aceita, processando.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"},"examples":{"processando":{"$ref":"#/components/examples/NfseProcessando"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"200":{"description":"Replay da mesma ref/Idempotency-Key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"},"examples":{"autorizada":{"$ref":"#/components/examples/Nfse"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}}},"400":{"$ref":"#/components/responses/400"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"503":{"$ref":"#/components/responses/503"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/AguardarNfse"},{"$ref":"#/components/parameters/IdempotencyKey"},{"$ref":"#/components/parameters/SimularNfse"},{"$ref":"#/components/parameters/SimularAtraso"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfse"},"examples":{"completo":{"$ref":"#/components/examples/PayloadNfse"},"minimo":{"$ref":"#/components/examples/PayloadNfseMinimo"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfse' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Idempotency-Key: nfse-venda-1234-1' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"nfse-venda-1234-1\",\"emitente_id\":12,\"data_competencia\":\"2026-10-30\",\"calcular\":true,\"municipio_prestacao\":\"3550308\",\"servicos\":[{\"codigo\":\"SUP-MENSAL\",\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"quantidade\":\"1\",\"valor_unitario\":\"1500.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\",\"codigo_tributacao_municipal\":null},{\"descricao\":\"Visita técnica extra (2 h)\",\"quantidade\":\"2\",\"valor_unitario\":\"150.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\"}],\"informacoes_complementares\":null,\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\",\"inscricao_municipal\":null,\"email\":\"fiscal@horizonte.example\",\"telefone\":\"1133334444\",\"endereco\":{\"codigo_municipio\":\"3550308\",\"cep\":\"01001000\",\"logradouro\":\"Praça da Sé\",\"numero\":\"100\",\"complemento\":\"sala 5\",\"bairro\":\"Sé\"}},\"valores\":{\"desconto_incondicionado\":\"0.00\",\"desconto_condicionado\":\"0.00\",\"ajuste_base_iss\":null},\"iss\":{\"tributacao\":\"tributavel\",\"aliquota\":\"2.0000\",\"retido\":true,\"tipo_imunidade\":null},\"retencoes\":{\"irrf\":{\"aliquota\":\"1.5000\"},\"csll\":{\"aliquota\":\"1.0000\"},\"inss\":{\"aliquota\":\"11.0000\"},\"pis\":{\"retido\":true},\"cofins\":{\"retido\":true}},\"tributos_federais\":{\"pis_cofins\":{\"cst\":\"01\",\"aliquota_pis\":\"0.6500\",\"aliquota_cofins\":\"3.0000\"}},\"ibscbs\":null,\"obra\":null,\"totais\":{\"valor_servicos\":\"1800.00\",\"valor_liquido\":\"1455.30\"}}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfse', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n        'Idempotency-Key' => 'nfse-venda-1234-1',\n    ],\n    'json' => json_decode('{\"ref\":\"nfse-venda-1234-1\",\"emitente_id\":12,\"data_competencia\":\"2026-10-30\",\"calcular\":true,\"municipio_prestacao\":\"3550308\",\"servicos\":[{\"codigo\":\"SUP-MENSAL\",\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"quantidade\":\"1\",\"valor_unitario\":\"1500.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\",\"codigo_tributacao_municipal\":null},{\"descricao\":\"Visita técnica extra (2 h)\",\"quantidade\":\"2\",\"valor_unitario\":\"150.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\"}],\"informacoes_complementares\":null,\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\",\"inscricao_municipal\":null,\"email\":\"fiscal@horizonte.example\",\"telefone\":\"1133334444\",\"endereco\":{\"codigo_municipio\":\"3550308\",\"cep\":\"01001000\",\"logradouro\":\"Praça da Sé\",\"numero\":\"100\",\"complemento\":\"sala 5\",\"bairro\":\"Sé\"}},\"valores\":{\"desconto_incondicionado\":\"0.00\",\"desconto_condicionado\":\"0.00\",\"ajuste_base_iss\":null},\"iss\":{\"tributacao\":\"tributavel\",\"aliquota\":\"2.0000\",\"retido\":true,\"tipo_imunidade\":null},\"retencoes\":{\"irrf\":{\"aliquota\":\"1.5000\"},\"csll\":{\"aliquota\":\"1.0000\"},\"inss\":{\"aliquota\":\"11.0000\"},\"pis\":{\"retido\":true},\"cofins\":{\"retido\":true}},\"tributos_federais\":{\"pis_cofins\":{\"cst\":\"01\",\"aliquota_pis\":\"0.6500\",\"aliquota_cofins\":\"3.0000\"}},\"ibscbs\":null,\"obra\":null,\"totais\":{\"valor_servicos\":\"1800.00\",\"valor_liquido\":\"1455.30\"}}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json', 'Idempotency-Key': 'nfse-venda-1234-1' },\n  body: JSON.stringify({\n      \"ref\": \"nfse-venda-1234-1\",\n      \"emitente_id\": 12,\n      \"data_competencia\": \"2026-10-30\",\n      \"calcular\": true,\n      \"municipio_prestacao\": \"3550308\",\n      \"servicos\": [\n          {\n              \"codigo\": \"SUP-MENSAL\",\n              \"descricao\": \"Suporte técnico em informática — outubro/2026\",\n              \"quantidade\": \"1\",\n              \"valor_unitario\": \"1500.00\",\n              \"codigo_tributacao_nacional\": \"010701\",\n              \"codigo_nbs\": \"115013000\",\n              \"codigo_tributacao_municipal\": null\n          },\n          {\n              \"descricao\": \"Visita técnica extra (2 h)\",\n              \"quantidade\": \"2\",\n              \"valor_unitario\": \"150.00\",\n              \"codigo_tributacao_nacional\": \"010701\",\n              \"codigo_nbs\": \"115013000\"\n          }\n      ],\n      \"informacoes_complementares\": null,\n      \"tomador\": {\n          \"documento\": \"72619438000163\",\n          \"nome\": \"Comercial Horizonte Ltda\",\n          \"inscricao_municipal\": null,\n          \"email\": \"fiscal@horizonte.example\",\n          \"telefone\": \"1133334444\",\n          \"endereco\": {\n              \"codigo_municipio\": \"3550308\",\n              \"cep\": \"01001000\",\n              \"logradouro\": \"Praça da Sé\",\n              \"numero\": \"100\",\n              \"complemento\": \"sala 5\",\n              \"bairro\": \"Sé\"\n          }\n      },\n      \"valores\": {\n          \"desconto_incondicionado\": \"0.00\",\n          \"desconto_condicionado\": \"0.00\",\n          \"ajuste_base_iss\": null\n      },\n      \"iss\": {\n          \"tributacao\": \"tributavel\",\n          \"aliquota\": \"2.0000\",\n          \"retido\": true,\n          \"tipo_imunidade\": null\n      },\n      \"retencoes\": {\n          \"irrf\": {\n              \"aliquota\": \"1.5000\"\n          },\n          \"csll\": {\n              \"aliquota\": \"1.0000\"\n          },\n          \"inss\": {\n              \"aliquota\": \"11.0000\"\n          },\n          \"pis\": {\n              \"retido\": true\n          },\n          \"cofins\": {\n              \"retido\": true\n          }\n      },\n      \"tributos_federais\": {\n          \"pis_cofins\": {\n              \"cst\": \"01\",\n              \"aliquota_pis\": \"0.6500\",\n              \"aliquota_cofins\": \"3.0000\"\n          }\n      },\n      \"ibscbs\": null,\n      \"obra\": null,\n      \"totais\": {\n          \"valor_servicos\": \"1800.00\",\n          \"valor_liquido\": \"1455.30\"\n      }\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfse',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\", 'Idempotency-Key': 'nfse-venda-1234-1'},\n    json={\n        \"ref\": \"nfse-venda-1234-1\",\n        \"emitente_id\": 12,\n        \"data_competencia\": \"2026-10-30\",\n        \"calcular\": True,\n        \"municipio_prestacao\": \"3550308\",\n        \"servicos\": [\n            {\n                \"codigo\": \"SUP-MENSAL\",\n                \"descricao\": \"Suporte técnico em informática — outubro/2026\",\n                \"quantidade\": \"1\",\n                \"valor_unitario\": \"1500.00\",\n                \"codigo_tributacao_nacional\": \"010701\",\n                \"codigo_nbs\": \"115013000\",\n                \"codigo_tributacao_municipal\": None\n            },\n            {\n                \"descricao\": \"Visita técnica extra (2 h)\",\n                \"quantidade\": \"2\",\n                \"valor_unitario\": \"150.00\",\n                \"codigo_tributacao_nacional\": \"010701\",\n                \"codigo_nbs\": \"115013000\"\n            }\n        ],\n        \"informacoes_complementares\": None,\n        \"tomador\": {\n            \"documento\": \"72619438000163\",\n            \"nome\": \"Comercial Horizonte Ltda\",\n            \"inscricao_municipal\": None,\n            \"email\": \"fiscal@horizonte.example\",\n            \"telefone\": \"1133334444\",\n            \"endereco\": {\n                \"codigo_municipio\": \"3550308\",\n                \"cep\": \"01001000\",\n                \"logradouro\": \"Praça da Sé\",\n                \"numero\": \"100\",\n                \"complemento\": \"sala 5\",\n                \"bairro\": \"Sé\"\n            }\n        },\n        \"valores\": {\n            \"desconto_incondicionado\": \"0.00\",\n            \"desconto_condicionado\": \"0.00\",\n            \"ajuste_base_iss\": None\n        },\n        \"iss\": {\n            \"tributacao\": \"tributavel\",\n            \"aliquota\": \"2.0000\",\n            \"retido\": True,\n            \"tipo_imunidade\": None\n        },\n        \"retencoes\": {\n            \"irrf\": {\n                \"aliquota\": \"1.5000\"\n            },\n            \"csll\": {\n                \"aliquota\": \"1.0000\"\n            },\n            \"inss\": {\n                \"aliquota\": \"11.0000\"\n            },\n            \"pis\": {\n                \"retido\": True\n            },\n            \"cofins\": {\n                \"retido\": True\n            }\n        },\n        \"tributos_federais\": {\n            \"pis_cofins\": {\n                \"cst\": \"01\",\n                \"aliquota_pis\": \"0.6500\",\n                \"aliquota_cofins\": \"3.0000\"\n            }\n        },\n        \"ibscbs\": None,\n        \"obra\": None,\n        \"totais\": {\n            \"valor_servicos\": \"1800.00\",\n            \"valor_liquido\": \"1455.30\"\n        }\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfse\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Headers.Add(\"Idempotency-Key\", \"nfse-venda-1234-1\");\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"nfse-venda-1234-1\"\",\"\"emitente_id\"\":12,\"\"data_competencia\"\":\"\"2026-10-30\"\",\"\"calcular\"\":true,\"\"municipio_prestacao\"\":\"\"3550308\"\",\"\"servicos\"\":[{\"\"codigo\"\":\"\"SUP-MENSAL\"\",\"\"descricao\"\":\"\"Suporte técnico em informática — outubro/2026\"\",\"\"quantidade\"\":\"\"1\"\",\"\"valor_unitario\"\":\"\"1500.00\"\",\"\"codigo_tributacao_nacional\"\":\"\"010701\"\",\"\"codigo_nbs\"\":\"\"115013000\"\",\"\"codigo_tributacao_municipal\"\":null},{\"\"descricao\"\":\"\"Visita técnica extra (2 h)\"\",\"\"quantidade\"\":\"\"2\"\",\"\"valor_unitario\"\":\"\"150.00\"\",\"\"codigo_tributacao_nacional\"\":\"\"010701\"\",\"\"codigo_nbs\"\":\"\"115013000\"\"}],\"\"informacoes_complementares\"\":null,\"\"tomador\"\":{\"\"documento\"\":\"\"72619438000163\"\",\"\"nome\"\":\"\"Comercial Horizonte Ltda\"\",\"\"inscricao_municipal\"\":null,\"\"email\"\":\"\"fiscal@horizonte.example\"\",\"\"telefone\"\":\"\"1133334444\"\",\"\"endereco\"\":{\"\"codigo_municipio\"\":\"\"3550308\"\",\"\"cep\"\":\"\"01001000\"\",\"\"logradouro\"\":\"\"Praça da Sé\"\",\"\"numero\"\":\"\"100\"\",\"\"complemento\"\":\"\"sala 5\"\",\"\"bairro\"\":\"\"Sé\"\"}},\"\"valores\"\":{\"\"desconto_incondicionado\"\":\"\"0.00\"\",\"\"desconto_condicionado\"\":\"\"0.00\"\",\"\"ajuste_base_iss\"\":null},\"\"iss\"\":{\"\"tributacao\"\":\"\"tributavel\"\",\"\"aliquota\"\":\"\"2.0000\"\",\"\"retido\"\":true,\"\"tipo_imunidade\"\":null},\"\"retencoes\"\":{\"\"irrf\"\":{\"\"aliquota\"\":\"\"1.5000\"\"},\"\"csll\"\":{\"\"aliquota\"\":\"\"1.0000\"\"},\"\"inss\"\":{\"\"aliquota\"\":\"\"11.0000\"\"},\"\"pis\"\":{\"\"retido\"\":true},\"\"cofins\"\":{\"\"retido\"\":true}},\"\"tributos_federais\"\":{\"\"pis_cofins\"\":{\"\"cst\"\":\"\"01\"\",\"\"aliquota_pis\"\":\"\"0.6500\"\",\"\"aliquota_cofins\"\":\"\"3.0000\"\"}},\"\"ibscbs\"\":null,\"\"obra\"\":null,\"\"totais\"\":{\"\"valor_servicos\"\":\"\"1800.00\"\",\"\"valor_liquido\"\":\"\"1455.30\"\"}}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.CustomHeaders['Idempotency-Key'] := 'nfse-venda-1234-1';\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"nfse-venda-1234-1\",\"emitente_id\":12,\"data_competencia\":\"2026-10-30\",\"calcular\":true,\"municipio_prestacao\":\"3550308\",\"servicos\":[{\"codigo\":\"SUP-MENSAL\",\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"quantidade\":\"1\",\"valor_unitario\":\"1500.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\",\"codigo_tributacao_municipal\":null},{\"descricao\":\"Visita técnica extra (2 h)\",\"quantidade\":\"2\",\"valor_unitario\":\"150.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\"}],\"informacoes_complementares\":null,\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\",\"inscricao_municipal\":null,\"email\":\"fiscal@horizonte.example\",\"telefone\":\"1133334444\",\"endereco\":{\"codigo_municipio\":\"3550308\",\"cep\":\"01001000\",\"logradouro\":\"Praça da Sé\",\"numero\":\"100\",\"complemento\":\"sala 5\",\"bairro\":\"Sé\"}},\"valores\":{\"desconto_incondicionado\":\"0.00\",\"desconto_condicionado\":\"0.00\",\"ajuste_base_iss\":null},\"iss\":{\"tributacao\":\"tributavel\",\"aliquota\":\"2.0000\",\"retido\":true,\"tipo_imunidade\":null},\"retencoes\":{\"irrf\":{\"aliquota\":\"1.5000\"},\"csll\":{\"aliquota\":\"1.0000\"},\"inss\":{\"aliquota\":\"11.0000\"},\"pis\":{\"retido\":true},\"cofins\":{\"retido\":true}},\"tributos_federais\":{\"pis_cofins\":{\"cst\":\"01\",\"aliquota_pis\":\"0.6500\",\"aliquota_cofins\":\"3.0000\"}},\"ibscbs\":null,\"obra\":null,\"totais\":{\"valor_servicos\":\"1800.00\",\"valor_liquido\":\"1455.30\"}}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfse', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]},"get":{"tags":["NFS-e"],"summary":"Listar NFS-e","description":"Mais nova primeiro. Paginação por cursor.","operationId":"listar_nfse","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListaNfse"}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"status","in":"query","required":false,"schema":{"type":"string"},"description":"Vírgula, até 7: processando, autorizada, rejeitada, cancelada, substituida, descartada."},{"name":"emitente_id","in":"query","required":false,"schema":{"type":"integer"}},{"name":"ref","in":"query","required":false,"schema":{"type":"string"}},{"name":"chave","in":"query","required":false,"schema":{"type":"string"}},{"name":"numero_nfse","in":"query","required":false,"schema":{"type":"string"}},{"name":"serie_dps","in":"query","required":false,"schema":{"type":"integer"}},{"name":"numero_dps","in":"query","required":false,"schema":{"type":"integer"}},{"name":"tomador_documento","in":"query","required":false,"schema":{"type":"string"}},{"name":"competencia","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"}},{"name":"desde","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"ate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"$ref":"#/components/parameters/Limite"},{"$ref":"#/components/parameters/Cursor"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/nfse?status=autorizada&competencia=2026-10' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/nfse?status=autorizada&competencia=2026-10', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse?status=autorizada&competencia=2026-10', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/nfse?status=autorizada&competencia=2026-10',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/nfse?status=autorizada&competencia=2026-10\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/nfse?status=autorizada&competencia=2026-10');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/validar":{"post":{"tags":["NFS-e"],"summary":"Validar NFS-e (sem emitir)","description":"Mesmos passos da emissão (normalizar, calcular, validar, montar, assinar, XSD) sem reservar nDPS nem transmitir. Sempre 200 com `valido`.","operationId":"validar_nfse","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidacaoNfse"},"examples":{"valida":{"$ref":"#/components/examples/ValidacaoNfse"},"invalida":{"$ref":"#/components/examples/ValidacaoNfseInvalida"}}}}},"400":{"$ref":"#/components/responses/400"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/SimularNfse"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfse"},"examples":{"completo":{"$ref":"#/components/examples/PayloadNfse"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfse/validar' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"nfse-venda-1234-1\",\"emitente_id\":12,\"data_competencia\":\"2026-10-30\",\"calcular\":true,\"municipio_prestacao\":\"3550308\",\"servicos\":[{\"codigo\":\"SUP-MENSAL\",\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"quantidade\":\"1\",\"valor_unitario\":\"1500.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\",\"codigo_tributacao_municipal\":null},{\"descricao\":\"Visita técnica extra (2 h)\",\"quantidade\":\"2\",\"valor_unitario\":\"150.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\"}],\"informacoes_complementares\":null,\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\",\"inscricao_municipal\":null,\"email\":\"fiscal@horizonte.example\",\"telefone\":\"1133334444\",\"endereco\":{\"codigo_municipio\":\"3550308\",\"cep\":\"01001000\",\"logradouro\":\"Praça da Sé\",\"numero\":\"100\",\"complemento\":\"sala 5\",\"bairro\":\"Sé\"}},\"valores\":{\"desconto_incondicionado\":\"0.00\",\"desconto_condicionado\":\"0.00\",\"ajuste_base_iss\":null},\"iss\":{\"tributacao\":\"tributavel\",\"aliquota\":\"2.0000\",\"retido\":true,\"tipo_imunidade\":null},\"retencoes\":{\"irrf\":{\"aliquota\":\"1.5000\"},\"csll\":{\"aliquota\":\"1.0000\"},\"inss\":{\"aliquota\":\"11.0000\"},\"pis\":{\"retido\":true},\"cofins\":{\"retido\":true}},\"tributos_federais\":{\"pis_cofins\":{\"cst\":\"01\",\"aliquota_pis\":\"0.6500\",\"aliquota_cofins\":\"3.0000\"}},\"ibscbs\":null,\"obra\":null,\"totais\":{\"valor_servicos\":\"1800.00\",\"valor_liquido\":\"1455.30\"}}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfse/validar', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"ref\":\"nfse-venda-1234-1\",\"emitente_id\":12,\"data_competencia\":\"2026-10-30\",\"calcular\":true,\"municipio_prestacao\":\"3550308\",\"servicos\":[{\"codigo\":\"SUP-MENSAL\",\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"quantidade\":\"1\",\"valor_unitario\":\"1500.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\",\"codigo_tributacao_municipal\":null},{\"descricao\":\"Visita técnica extra (2 h)\",\"quantidade\":\"2\",\"valor_unitario\":\"150.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\"}],\"informacoes_complementares\":null,\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\",\"inscricao_municipal\":null,\"email\":\"fiscal@horizonte.example\",\"telefone\":\"1133334444\",\"endereco\":{\"codigo_municipio\":\"3550308\",\"cep\":\"01001000\",\"logradouro\":\"Praça da Sé\",\"numero\":\"100\",\"complemento\":\"sala 5\",\"bairro\":\"Sé\"}},\"valores\":{\"desconto_incondicionado\":\"0.00\",\"desconto_condicionado\":\"0.00\",\"ajuste_base_iss\":null},\"iss\":{\"tributacao\":\"tributavel\",\"aliquota\":\"2.0000\",\"retido\":true,\"tipo_imunidade\":null},\"retencoes\":{\"irrf\":{\"aliquota\":\"1.5000\"},\"csll\":{\"aliquota\":\"1.0000\"},\"inss\":{\"aliquota\":\"11.0000\"},\"pis\":{\"retido\":true},\"cofins\":{\"retido\":true}},\"tributos_federais\":{\"pis_cofins\":{\"cst\":\"01\",\"aliquota_pis\":\"0.6500\",\"aliquota_cofins\":\"3.0000\"}},\"ibscbs\":null,\"obra\":null,\"totais\":{\"valor_servicos\":\"1800.00\",\"valor_liquido\":\"1455.30\"}}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/validar', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"ref\": \"nfse-venda-1234-1\",\n      \"emitente_id\": 12,\n      \"data_competencia\": \"2026-10-30\",\n      \"calcular\": true,\n      \"municipio_prestacao\": \"3550308\",\n      \"servicos\": [\n          {\n              \"codigo\": \"SUP-MENSAL\",\n              \"descricao\": \"Suporte técnico em informática — outubro/2026\",\n              \"quantidade\": \"1\",\n              \"valor_unitario\": \"1500.00\",\n              \"codigo_tributacao_nacional\": \"010701\",\n              \"codigo_nbs\": \"115013000\",\n              \"codigo_tributacao_municipal\": null\n          },\n          {\n              \"descricao\": \"Visita técnica extra (2 h)\",\n              \"quantidade\": \"2\",\n              \"valor_unitario\": \"150.00\",\n              \"codigo_tributacao_nacional\": \"010701\",\n              \"codigo_nbs\": \"115013000\"\n          }\n      ],\n      \"informacoes_complementares\": null,\n      \"tomador\": {\n          \"documento\": \"72619438000163\",\n          \"nome\": \"Comercial Horizonte Ltda\",\n          \"inscricao_municipal\": null,\n          \"email\": \"fiscal@horizonte.example\",\n          \"telefone\": \"1133334444\",\n          \"endereco\": {\n              \"codigo_municipio\": \"3550308\",\n              \"cep\": \"01001000\",\n              \"logradouro\": \"Praça da Sé\",\n              \"numero\": \"100\",\n              \"complemento\": \"sala 5\",\n              \"bairro\": \"Sé\"\n          }\n      },\n      \"valores\": {\n          \"desconto_incondicionado\": \"0.00\",\n          \"desconto_condicionado\": \"0.00\",\n          \"ajuste_base_iss\": null\n      },\n      \"iss\": {\n          \"tributacao\": \"tributavel\",\n          \"aliquota\": \"2.0000\",\n          \"retido\": true,\n          \"tipo_imunidade\": null\n      },\n      \"retencoes\": {\n          \"irrf\": {\n              \"aliquota\": \"1.5000\"\n          },\n          \"csll\": {\n              \"aliquota\": \"1.0000\"\n          },\n          \"inss\": {\n              \"aliquota\": \"11.0000\"\n          },\n          \"pis\": {\n              \"retido\": true\n          },\n          \"cofins\": {\n              \"retido\": true\n          }\n      },\n      \"tributos_federais\": {\n          \"pis_cofins\": {\n              \"cst\": \"01\",\n              \"aliquota_pis\": \"0.6500\",\n              \"aliquota_cofins\": \"3.0000\"\n          }\n      },\n      \"ibscbs\": null,\n      \"obra\": null,\n      \"totais\": {\n          \"valor_servicos\": \"1800.00\",\n          \"valor_liquido\": \"1455.30\"\n      }\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfse/validar',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"ref\": \"nfse-venda-1234-1\",\n        \"emitente_id\": 12,\n        \"data_competencia\": \"2026-10-30\",\n        \"calcular\": True,\n        \"municipio_prestacao\": \"3550308\",\n        \"servicos\": [\n            {\n                \"codigo\": \"SUP-MENSAL\",\n                \"descricao\": \"Suporte técnico em informática — outubro/2026\",\n                \"quantidade\": \"1\",\n                \"valor_unitario\": \"1500.00\",\n                \"codigo_tributacao_nacional\": \"010701\",\n                \"codigo_nbs\": \"115013000\",\n                \"codigo_tributacao_municipal\": None\n            },\n            {\n                \"descricao\": \"Visita técnica extra (2 h)\",\n                \"quantidade\": \"2\",\n                \"valor_unitario\": \"150.00\",\n                \"codigo_tributacao_nacional\": \"010701\",\n                \"codigo_nbs\": \"115013000\"\n            }\n        ],\n        \"informacoes_complementares\": None,\n        \"tomador\": {\n            \"documento\": \"72619438000163\",\n            \"nome\": \"Comercial Horizonte Ltda\",\n            \"inscricao_municipal\": None,\n            \"email\": \"fiscal@horizonte.example\",\n            \"telefone\": \"1133334444\",\n            \"endereco\": {\n                \"codigo_municipio\": \"3550308\",\n                \"cep\": \"01001000\",\n                \"logradouro\": \"Praça da Sé\",\n                \"numero\": \"100\",\n                \"complemento\": \"sala 5\",\n                \"bairro\": \"Sé\"\n            }\n        },\n        \"valores\": {\n            \"desconto_incondicionado\": \"0.00\",\n            \"desconto_condicionado\": \"0.00\",\n            \"ajuste_base_iss\": None\n        },\n        \"iss\": {\n            \"tributacao\": \"tributavel\",\n            \"aliquota\": \"2.0000\",\n            \"retido\": True,\n            \"tipo_imunidade\": None\n        },\n        \"retencoes\": {\n            \"irrf\": {\n                \"aliquota\": \"1.5000\"\n            },\n            \"csll\": {\n                \"aliquota\": \"1.0000\"\n            },\n            \"inss\": {\n                \"aliquota\": \"11.0000\"\n            },\n            \"pis\": {\n                \"retido\": True\n            },\n            \"cofins\": {\n                \"retido\": True\n            }\n        },\n        \"tributos_federais\": {\n            \"pis_cofins\": {\n                \"cst\": \"01\",\n                \"aliquota_pis\": \"0.6500\",\n                \"aliquota_cofins\": \"3.0000\"\n            }\n        },\n        \"ibscbs\": None,\n        \"obra\": None,\n        \"totais\": {\n            \"valor_servicos\": \"1800.00\",\n            \"valor_liquido\": \"1455.30\"\n        }\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfse/validar\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"nfse-venda-1234-1\"\",\"\"emitente_id\"\":12,\"\"data_competencia\"\":\"\"2026-10-30\"\",\"\"calcular\"\":true,\"\"municipio_prestacao\"\":\"\"3550308\"\",\"\"servicos\"\":[{\"\"codigo\"\":\"\"SUP-MENSAL\"\",\"\"descricao\"\":\"\"Suporte técnico em informática — outubro/2026\"\",\"\"quantidade\"\":\"\"1\"\",\"\"valor_unitario\"\":\"\"1500.00\"\",\"\"codigo_tributacao_nacional\"\":\"\"010701\"\",\"\"codigo_nbs\"\":\"\"115013000\"\",\"\"codigo_tributacao_municipal\"\":null},{\"\"descricao\"\":\"\"Visita técnica extra (2 h)\"\",\"\"quantidade\"\":\"\"2\"\",\"\"valor_unitario\"\":\"\"150.00\"\",\"\"codigo_tributacao_nacional\"\":\"\"010701\"\",\"\"codigo_nbs\"\":\"\"115013000\"\"}],\"\"informacoes_complementares\"\":null,\"\"tomador\"\":{\"\"documento\"\":\"\"72619438000163\"\",\"\"nome\"\":\"\"Comercial Horizonte Ltda\"\",\"\"inscricao_municipal\"\":null,\"\"email\"\":\"\"fiscal@horizonte.example\"\",\"\"telefone\"\":\"\"1133334444\"\",\"\"endereco\"\":{\"\"codigo_municipio\"\":\"\"3550308\"\",\"\"cep\"\":\"\"01001000\"\",\"\"logradouro\"\":\"\"Praça da Sé\"\",\"\"numero\"\":\"\"100\"\",\"\"complemento\"\":\"\"sala 5\"\",\"\"bairro\"\":\"\"Sé\"\"}},\"\"valores\"\":{\"\"desconto_incondicionado\"\":\"\"0.00\"\",\"\"desconto_condicionado\"\":\"\"0.00\"\",\"\"ajuste_base_iss\"\":null},\"\"iss\"\":{\"\"tributacao\"\":\"\"tributavel\"\",\"\"aliquota\"\":\"\"2.0000\"\",\"\"retido\"\":true,\"\"tipo_imunidade\"\":null},\"\"retencoes\"\":{\"\"irrf\"\":{\"\"aliquota\"\":\"\"1.5000\"\"},\"\"csll\"\":{\"\"aliquota\"\":\"\"1.0000\"\"},\"\"inss\"\":{\"\"aliquota\"\":\"\"11.0000\"\"},\"\"pis\"\":{\"\"retido\"\":true},\"\"cofins\"\":{\"\"retido\"\":true}},\"\"tributos_federais\"\":{\"\"pis_cofins\"\":{\"\"cst\"\":\"\"01\"\",\"\"aliquota_pis\"\":\"\"0.6500\"\",\"\"aliquota_cofins\"\":\"\"3.0000\"\"}},\"\"ibscbs\"\":null,\"\"obra\"\":null,\"\"totais\"\":{\"\"valor_servicos\"\":\"\"1800.00\"\",\"\"valor_liquido\"\":\"\"1455.30\"\"}}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"nfse-venda-1234-1\",\"emitente_id\":12,\"data_competencia\":\"2026-10-30\",\"calcular\":true,\"municipio_prestacao\":\"3550308\",\"servicos\":[{\"codigo\":\"SUP-MENSAL\",\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"quantidade\":\"1\",\"valor_unitario\":\"1500.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\",\"codigo_tributacao_municipal\":null},{\"descricao\":\"Visita técnica extra (2 h)\",\"quantidade\":\"2\",\"valor_unitario\":\"150.00\",\"codigo_tributacao_nacional\":\"010701\",\"codigo_nbs\":\"115013000\"}],\"informacoes_complementares\":null,\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\",\"inscricao_municipal\":null,\"email\":\"fiscal@horizonte.example\",\"telefone\":\"1133334444\",\"endereco\":{\"codigo_municipio\":\"3550308\",\"cep\":\"01001000\",\"logradouro\":\"Praça da Sé\",\"numero\":\"100\",\"complemento\":\"sala 5\",\"bairro\":\"Sé\"}},\"valores\":{\"desconto_incondicionado\":\"0.00\",\"desconto_condicionado\":\"0.00\",\"ajuste_base_iss\":null},\"iss\":{\"tributacao\":\"tributavel\",\"aliquota\":\"2.0000\",\"retido\":true,\"tipo_imunidade\":null},\"retencoes\":{\"irrf\":{\"aliquota\":\"1.5000\"},\"csll\":{\"aliquota\":\"1.0000\"},\"inss\":{\"aliquota\":\"11.0000\"},\"pis\":{\"retido\":true},\"cofins\":{\"retido\":true}},\"tributos_federais\":{\"pis_cofins\":{\"cst\":\"01\",\"aliquota_pis\":\"0.6500\",\"aliquota_cofins\":\"3.0000\"}},\"ibscbs\":null,\"obra\":null,\"totais\":{\"valor_servicos\":\"1800.00\",\"valor_liquido\":\"1455.30\"}}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfse/validar', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/{id}":{"get":{"tags":["NFS-e"],"summary":"Consultar NFS-e","description":"Com `aguardar`, espera sair de processando. `incluir=payload` devolve o payload gravado.","operationId":"consultar_nfse","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"},"examples":{"autorizada":{"$ref":"#/components/examples/Nfse"}}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"},{"name":"aguardar","in":"query","required":false,"schema":{"type":"integer","minimum":0,"maximum":25}},{"name":"incluir","in":"query","required":false,"schema":{"type":"string","enum":["payload"]}}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]},"put":{"tags":["NFS-e"],"summary":"Corrigir NFS-e rejeitada","description":"Payload completo novo; mesmo id, mesmo nDPS (rejeição não consome número). Só em rejeitada; senão 409 documento_nao_corrigivel. A `ref`, se vier, não pode mudar.","operationId":"corrigir_nfse","responses":{"200":{"description":"Resultado final.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"},"examples":{"autorizada":{"$ref":"#/components/examples/Nfse"}}}}},"202":{"description":"Processando.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"},{"$ref":"#/components/parameters/AguardarNfse"},{"$ref":"#/components/parameters/SimularNfse"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfse"},"examples":{"minimo":{"$ref":"#/components/examples/PayloadNfseMinimo"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X PUT 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"nfse-os-778-1\",\"servicos\":[{\"descricao\":\"Manutenção preventiva de impressora\",\"valor_unitario\":\"350.00\"}],\"tomador\":{\"documento\":\"38461592719\",\"nome\":\"Maria Fictícia da Silva\"}}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('PUT', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"ref\":\"nfse-os-778-1\",\"servicos\":[{\"descricao\":\"Manutenção preventiva de impressora\",\"valor_unitario\":\"350.00\"}],\"tomador\":{\"documento\":\"38461592719\",\"nome\":\"Maria Fictícia da Silva\"}}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk', {\n  method: 'PUT',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"ref\": \"nfse-os-778-1\",\n      \"servicos\": [\n          {\n              \"descricao\": \"Manutenção preventiva de impressora\",\n              \"valor_unitario\": \"350.00\"\n          }\n      ],\n      \"tomador\": {\n          \"documento\": \"38461592719\",\n          \"nome\": \"Maria Fictícia da Silva\"\n      }\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'PUT', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"ref\": \"nfse-os-778-1\",\n        \"servicos\": [\n            {\n                \"descricao\": \"Manutenção preventiva de impressora\",\n                \"valor_unitario\": \"350.00\"\n            }\n        ],\n        \"tomador\": {\n            \"documento\": \"38461592719\",\n            \"nome\": \"Maria Fictícia da Silva\"\n        }\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"PUT\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"nfse-os-778-1\"\",\"\"servicos\"\":[{\"\"descricao\"\":\"\"Manutenção preventiva de impressora\"\",\"\"valor_unitario\"\":\"\"350.00\"\"}],\"\"tomador\"\":{\"\"documento\"\":\"\"38461592719\"\",\"\"nome\"\":\"\"Maria Fictícia da Silva\"\"}}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"nfse-os-778-1\",\"servicos\":[{\"descricao\":\"Manutenção preventiva de impressora\",\"valor_unitario\":\"350.00\"}],\"tomador\":{\"documento\":\"38461592719\",\"nome\":\"Maria Fictícia da Silva\"}}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('PUT', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]},"delete":{"tags":["NFS-e"],"summary":"Descartar NFS-e rejeitada","description":"Vira `descartada` e o nDPS volta para a fila de livres. Em outro estado: 409 documento_nao_descartavel.","operationId":"descartar_nfse","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X DELETE 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('DELETE', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk', {\n  method: 'DELETE',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'DELETE', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"DELETE\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('DELETE', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/{id}/xml":{"get":{"tags":["NFS-e"],"summary":"Baixar XML","description":"Autorizada, cancelada ou substituída: o XML da NFS-e da Sefin ({chave}-nfse.xml). Outros estados ou ?tipo=dps: a DPS assinada ({id_dps}-dps.xml). Sem XML ainda: 404 xml_indisponivel.","operationId":"xml_nfse","responses":{"200":{"description":"XML","content":{"application/xml":{"schema":{"type":"string"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"},{"name":"tipo","in":"query","required":false,"schema":{"type":"string","enum":["nfse","dps"]}}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/xml' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/xml', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/xml', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/xml',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/xml\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/xml');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/{id}/danfse":{"get":{"tags":["NFS-e"],"summary":"Baixar DANFSe (PDF)","description":"Gerado pelo MadNotas (cabeçalho MadNotas-Danfse-Origem: local). Só autorizada, cancelada ou substituída (com tarja); antes, 409 documento_nao_autorizado.","operationId":"danfse_nfse","responses":{"200":{"description":"PDF","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}},"headers":{"MadNotas-Danfse-Origem":{"schema":{"type":"string","enum":["local"]}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/danfse' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/danfse', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/danfse', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/danfse',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/danfse\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/danfse');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/{id}/cancelamento":{"post":{"tags":["NFS-e"],"summary":"Cancelar NFS-e","description":"Evento 101101. Cancelamento recusado pela Sefin = evento `rejeitado` e a nota segue autorizada (webhook nfse.evento_rejeitado). Fora de autorizada: 409 documento_nao_cancelavel.","operationId":"cancelar_nfse","responses":{"201":{"description":"Evento final.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventoNfse"},"examples":{"registrado":{"$ref":"#/components/examples/EventoNfse"}}}}},"202":{"description":"Processando.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventoNfse"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelamentoNfse"},"examples":{"cancelar":{"$ref":"#/components/examples/CancelamentoNfse"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/cancelamento' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"codigo_motivo\":\"1\",\"justificativa\":\"Valor do serviço digitado errado na emissão\"}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/cancelamento', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"codigo_motivo\":\"1\",\"justificativa\":\"Valor do serviço digitado errado na emissão\"}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/cancelamento', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"codigo_motivo\": \"1\",\n      \"justificativa\": \"Valor do serviço digitado errado na emissão\"\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/cancelamento',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"codigo_motivo\": \"1\",\n        \"justificativa\": \"Valor do serviço digitado errado na emissão\"\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/cancelamento\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"codigo_motivo\"\":\"\"1\"\",\"\"justificativa\"\":\"\"Valor do serviço digitado errado na emissão\"\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"codigo_motivo\":\"1\",\"justificativa\":\"Valor do serviço digitado errado na emissão\"}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/cancelamento', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/{id}/substituicao":{"post":{"tags":["NFS-e"],"summary":"Substituir NFS-e","description":"Payload completo da nova + `substituicao`. A resposta é a NFS-e NOVA (id novo, `substitui` = antiga, Location da nova). Autorizada a nova, a antiga vira `substituida`. Nova rejeitada: a antiga segue autorizada; corrija a nova com PUT. Já há substituta aberta: 409 substituicao_em_andamento. Mesma ref da antiga: 409 ref_em_uso.","operationId":"substituir_nfse","responses":{"201":{"description":"Nova NFS-e, resultado final.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"},"examples":{"substituta":{"$ref":"#/components/examples/NfseSubstituta"}}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"202":{"description":"Nova NFS-e, processando.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}}},"200":{"description":"Replay.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Nfse"}}},"headers":{"Location":{"$ref":"#/components/headers/Location"},"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"},{"$ref":"#/components/parameters/AguardarNfse"},{"$ref":"#/components/parameters/IdempotencyKey"},{"$ref":"#/components/parameters/SimularNfse"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayloadNfse"},"examples":{"substituir":{"$ref":"#/components/examples/SubstituicaoNfse"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/substituicao' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"ref\":\"nfse-venda-1234-2\",\"substituicao\":{\"codigo_motivo\":\"99\",\"motivo\":\"Correção da descrição e do valor do serviço prestado\"},\"servicos\":[{\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"valor_unitario\":\"1650.00\"}],\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\"}}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/substituicao', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"ref\":\"nfse-venda-1234-2\",\"substituicao\":{\"codigo_motivo\":\"99\",\"motivo\":\"Correção da descrição e do valor do serviço prestado\"},\"servicos\":[{\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"valor_unitario\":\"1650.00\"}],\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\"}}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/substituicao', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"ref\": \"nfse-venda-1234-2\",\n      \"substituicao\": {\n          \"codigo_motivo\": \"99\",\n          \"motivo\": \"Correção da descrição e do valor do serviço prestado\"\n      },\n      \"servicos\": [\n          {\n              \"descricao\": \"Suporte técnico em informática — outubro/2026\",\n              \"valor_unitario\": \"1650.00\"\n          }\n      ],\n      \"tomador\": {\n          \"documento\": \"72619438000163\",\n          \"nome\": \"Comercial Horizonte Ltda\"\n      }\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/substituicao',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"ref\": \"nfse-venda-1234-2\",\n        \"substituicao\": {\n            \"codigo_motivo\": \"99\",\n            \"motivo\": \"Correção da descrição e do valor do serviço prestado\"\n        },\n        \"servicos\": [\n            {\n                \"descricao\": \"Suporte técnico em informática — outubro/2026\",\n                \"valor_unitario\": \"1650.00\"\n            }\n        ],\n        \"tomador\": {\n            \"documento\": \"72619438000163\",\n            \"nome\": \"Comercial Horizonte Ltda\"\n        }\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/substituicao\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"ref\"\":\"\"nfse-venda-1234-2\"\",\"\"substituicao\"\":{\"\"codigo_motivo\"\":\"\"99\"\",\"\"motivo\"\":\"\"Correção da descrição e do valor do serviço prestado\"\"},\"\"servicos\"\":[{\"\"descricao\"\":\"\"Suporte técnico em informática — outubro/2026\"\",\"\"valor_unitario\"\":\"\"1650.00\"\"}],\"\"tomador\"\":{\"\"documento\"\":\"\"72619438000163\"\",\"\"nome\"\":\"\"Comercial Horizonte Ltda\"\"}}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"ref\":\"nfse-venda-1234-2\",\"substituicao\":{\"codigo_motivo\":\"99\",\"motivo\":\"Correção da descrição e do valor do serviço prestado\"},\"servicos\":[{\"descricao\":\"Suporte técnico em informática — outubro/2026\",\"valor_unitario\":\"1650.00\"}],\"tomador\":{\"documento\":\"72619438000163\",\"nome\":\"Comercial Horizonte Ltda\"}}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/substituicao', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/{id}/eventos":{"get":{"tags":["NFS-e"],"summary":"Listar eventos","description":"cancelamento, cancelamento_substituicao, cancelamento_externo.","operationId":"eventos_nfse","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/EventoNfse"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}},"additionalProperties":true}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"},{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/eventos' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/eventos', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/eventos', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/eventos',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/eventos\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/eventos');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/nfse/{id}/email":{"post":{"tags":["NFS-e"],"summary":"Enviar por e-mail","description":"XML da NFS-e + DANFSe para `destinatarios` (1 a 10) ou, com corpo vazio, para o e-mail do tomador e as cópias do emitente.","operationId":"email_nfse","responses":{"202":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"enviado":{"type":"boolean"},"destinatarios":{"type":"array","items":{"type":"string"}}},"additionalProperties":true}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNfse"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"destinatarios":{"type":"array","items":{"type":"string","format":"email"},"minItems":1,"maxItems":10}},"additionalProperties":true}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/email' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"destinatarios\":[\"fiscal@horizonte.example\"]}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/email', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"destinatarios\":[\"fiscal@horizonte.example\"]}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/email', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"destinatarios\": [\n          \"fiscal@horizonte.example\"\n      ]\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/email',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"destinatarios\": [\n            \"fiscal@horizonte.example\"\n        ]\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/email\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"destinatarios\"\":[\"\"fiscal@horizonte.example\"\"]}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"destinatarios\":[\"fiscal@horizonte.example\"]}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/nfse/nfse_01m69da95efbm1p87w1gy7z5bk/email', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/emitentes/{id}/nfse":{"put":{"tags":["Emitentes"],"summary":"Configurar a NFS-e do emitente","description":"Regime e padrões da DPS (§4.1). Todos os erros de uma vez (422 payload_invalido) e nada muda. Volta o bloco nfse (§4.3).","operationId":"nfse_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NfseEmitente"},"examples":{"bloco":{"$ref":"#/components/examples/NfseEmitente"}}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NfseEmitenteEntrada"},"examples":{"me_epp":{"$ref":"#/components/examples/NfseEmitenteEntrada"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X PUT 'https://notas.madbuilder.dev/api/v1/emitentes/12/nfse' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"habilitada\":true,\"opcao_simples\":\"me_epp\",\"regime_apuracao_simples\":\"tudo_no_simples\",\"regime_especial\":\"nenhum\",\"municipio_prestacao_padrao\":\"3550308\",\"tributacao_iss_padrao\":\"tributavel\",\"aliquota_iss_padrao\":\"2.0000\",\"codigo_tributacao_nacional_padrao\":\"010701\",\"codigo_nbs_padrao\":\"115013000\",\"codigo_tributacao_municipal_padrao\":null,\"percentual_tributos_simples\":\"6.0000\",\"ibscbs\":{\"habilitado\":false,\"cst\":\"000\",\"classificacao_tributaria\":\"000001\",\"indicador_operacao\":\"100301\"}}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('PUT', 'https://notas.madbuilder.dev/api/v1/emitentes/12/nfse', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"habilitada\":true,\"opcao_simples\":\"me_epp\",\"regime_apuracao_simples\":\"tudo_no_simples\",\"regime_especial\":\"nenhum\",\"municipio_prestacao_padrao\":\"3550308\",\"tributacao_iss_padrao\":\"tributavel\",\"aliquota_iss_padrao\":\"2.0000\",\"codigo_tributacao_nacional_padrao\":\"010701\",\"codigo_nbs_padrao\":\"115013000\",\"codigo_tributacao_municipal_padrao\":null,\"percentual_tributos_simples\":\"6.0000\",\"ibscbs\":{\"habilitado\":false,\"cst\":\"000\",\"classificacao_tributaria\":\"000001\",\"indicador_operacao\":\"100301\"}}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/emitentes/12/nfse', {\n  method: 'PUT',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"habilitada\": true,\n      \"opcao_simples\": \"me_epp\",\n      \"regime_apuracao_simples\": \"tudo_no_simples\",\n      \"regime_especial\": \"nenhum\",\n      \"municipio_prestacao_padrao\": \"3550308\",\n      \"tributacao_iss_padrao\": \"tributavel\",\n      \"aliquota_iss_padrao\": \"2.0000\",\n      \"codigo_tributacao_nacional_padrao\": \"010701\",\n      \"codigo_nbs_padrao\": \"115013000\",\n      \"codigo_tributacao_municipal_padrao\": null,\n      \"percentual_tributos_simples\": \"6.0000\",\n      \"ibscbs\": {\n          \"habilitado\": false,\n          \"cst\": \"000\",\n          \"classificacao_tributaria\": \"000001\",\n          \"indicador_operacao\": \"100301\"\n      }\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'PUT', 'https://notas.madbuilder.dev/api/v1/emitentes/12/nfse',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"habilitada\": True,\n        \"opcao_simples\": \"me_epp\",\n        \"regime_apuracao_simples\": \"tudo_no_simples\",\n        \"regime_especial\": \"nenhum\",\n        \"municipio_prestacao_padrao\": \"3550308\",\n        \"tributacao_iss_padrao\": \"tributavel\",\n        \"aliquota_iss_padrao\": \"2.0000\",\n        \"codigo_tributacao_nacional_padrao\": \"010701\",\n        \"codigo_nbs_padrao\": \"115013000\",\n        \"codigo_tributacao_municipal_padrao\": None,\n        \"percentual_tributos_simples\": \"6.0000\",\n        \"ibscbs\": {\n            \"habilitado\": False,\n            \"cst\": \"000\",\n            \"classificacao_tributaria\": \"000001\",\n            \"indicador_operacao\": \"100301\"\n        }\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"PUT\"), \"https://notas.madbuilder.dev/api/v1/emitentes/12/nfse\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"habilitada\"\":true,\"\"opcao_simples\"\":\"\"me_epp\"\",\"\"regime_apuracao_simples\"\":\"\"tudo_no_simples\"\",\"\"regime_especial\"\":\"\"nenhum\"\",\"\"municipio_prestacao_padrao\"\":\"\"3550308\"\",\"\"tributacao_iss_padrao\"\":\"\"tributavel\"\",\"\"aliquota_iss_padrao\"\":\"\"2.0000\"\",\"\"codigo_tributacao_nacional_padrao\"\":\"\"010701\"\",\"\"codigo_nbs_padrao\"\":\"\"115013000\"\",\"\"codigo_tributacao_municipal_padrao\"\":null,\"\"percentual_tributos_simples\"\":\"\"6.0000\"\",\"\"ibscbs\"\":{\"\"habilitado\"\":false,\"\"cst\"\":\"\"000\"\",\"\"classificacao_tributaria\"\":\"\"000001\"\",\"\"indicador_operacao\"\":\"\"100301\"\"}}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"habilitada\":true,\"opcao_simples\":\"me_epp\",\"regime_apuracao_simples\":\"tudo_no_simples\",\"regime_especial\":\"nenhum\",\"municipio_prestacao_padrao\":\"3550308\",\"tributacao_iss_padrao\":\"tributavel\",\"aliquota_iss_padrao\":\"2.0000\",\"codigo_tributacao_nacional_padrao\":\"010701\",\"codigo_nbs_padrao\":\"115013000\",\"codigo_tributacao_municipal_padrao\":null,\"percentual_tributos_simples\":\"6.0000\",\"ibscbs\":{\"habilitado\":false,\"cst\":\"000\",\"classificacao_tributaria\":\"000001\",\"indicador_operacao\":\"100301\"}}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('PUT', 'https://notas.madbuilder.dev/api/v1/emitentes/12/nfse', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/utilitarios/municipios/{ibge}/nfse":{"get":{"tags":["Utilitários"],"summary":"Convênio do município com a NFS-e Nacional","description":"No ambiente da chave; em simulação, nao_conferido.","operationId":"municipio_nfse","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MunicipioNfse"},"examples":{"sp":{"$ref":"#/components/examples/MunicipioNfse"}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"402":{"$ref":"#/components/responses/402"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"ibge","in":"path","required":true,"schema":{"type":"string","pattern":"^\\d{7}$"}}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/utilitarios/municipios/3550308/nfse' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/utilitarios/municipios/3550308/nfse', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/utilitarios/municipios/3550308/nfse', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/utilitarios/municipios/3550308/nfse',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/utilitarios/municipios/3550308/nfse\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/utilitarios/municipios/3550308/nfse');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/dfe":{"get":{"tags":["DF-e"],"summary":"Listar notas recebidas","description":"NF-e emitidas contra o CNPJ do emitente, do banco do MadNotas (nunca dispara consulta à SEFAZ), em ordem CRESCENTE de NSU. Para acompanhar: guarde o maior `nsu` lido e peça `?nsu=<ele>`. Sem `emitente_id`: todos os emitentes da chave.","operationId":"listar_dfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListaDfe"},"examples":{"pagina":{"$ref":"#/components/examples/ListaDfe"}}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"emitente_id","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Só deste emitente."},{"name":"nsu","in":"query","required":false,"schema":{"type":"string","pattern":"^\\d{1,15}$"},"description":"Só os com NSU maior que este (o último que você já leu)."},{"name":"situacao","in":"query","required":false,"schema":{"type":"string"},"description":"autorizada, cancelada, denegada (vários separados por vírgula)."},{"name":"manifestacao","in":"query","required":false,"schema":{"type":"string"},"description":"ciencia, confirmacao, desconhecimento, nao_realizada ou nenhuma (sem manifestação); vírgula para vários."},{"name":"tipo","in":"query","required":false,"schema":{"type":"string","enum":["entrada","saida"]},"description":"Tipo da operação na nota do fornecedor (tpNF)."},{"name":"modelo","in":"query","required":false,"schema":{"type":"string","enum":["55","nfse"]},"description":"55 (padrão). \"nfse\" reservado: hoje não traz nada (§22)."},{"name":"chave","in":"query","required":false,"schema":{"type":"string","pattern":"^[0-9]{6}[0-9A-Z]{12}[0-9]{26}$"},"description":"Chave de acesso da NF-e. Posições 7–18 = raiz e ordem do CNPJ do emitente (pode ter letra MAIÚSCULA, CNPJ alfanumérico); o DV do CNPJ e o resto só dígitos. Minúscula = 422."},{"name":"desde","in":"query","required":false,"schema":{"type":"string"},"description":"Data de emissão a partir de (AAAA-MM-DD ou ISO 8601)."},{"name":"ate","in":"query","required":false,"schema":{"type":"string"},"description":"Data de emissão até."},{"$ref":"#/components/parameters/Limite"},{"$ref":"#/components/parameters/Cursor"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/dfe?emitente_id=12&nsu=1530' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/dfe?emitente_id=12&nsu=1530', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/dfe?emitente_id=12&nsu=1530', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/dfe?emitente_id=12&nsu=1530',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/dfe?emitente_id=12&nsu=1530\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/dfe?emitente_id=12&nsu=1530');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/dfe/situacao":{"get":{"tags":["DF-e"],"summary":"Situação da distribuição","description":"Cursor do emitente no ambiente da chave: último NSU, maxNSU, última e próxima consulta e estado (em_dia, baixando, aguardando, bloqueado, sem_certificado). Emitente com o DF-e desligado: 422 dfe_nao_habilitado.","operationId":"situacao_dfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SituacaoDfe"},"examples":{"em_dia":{"$ref":"#/components/examples/SituacaoDfe"}}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"name":"emitente_id","in":"query","required":false,"schema":{"type":"integer","minimum":1},"description":"Emitente (obrigatório se a conta tem mais de um emitente ativo)."}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/dfe/situacao?emitente_id=12' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/dfe/situacao?emitente_id=12', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/dfe/situacao?emitente_id=12', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/dfe/situacao?emitente_id=12',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/dfe/situacao?emitente_id=12\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/dfe/situacao?emitente_id=12');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/dfe/sincronizar":{"post":{"tags":["DF-e"],"summary":"Pedir uma consulta","description":"PEDE uma consulta ao Ambiente Nacional. O MadNotas só consulta quando a cadência deixa (§21): depois de 137 ou em dia, só daqui a 1 h; bloqueado (656), só depois do bloqueio. Pedido repetido não adianta nem dá erro: devolve a mesma proxima_consulta_em. Em homologação/produção sem A1 válido: 422 certificado_indisponivel. Emitente com o DF-e desligado: 422 dfe_nao_habilitado.","operationId":"sincronizar_dfe","responses":{"202":{"description":"Pedido aceito; veja proxima_consulta_em.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SituacaoDfe"},"examples":{"em_dia":{"$ref":"#/components/examples/SituacaoDfe"}}}}},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SincronizarDfe"},"examples":{"pedir":{"$ref":"#/components/examples/SincronizarDfe"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/dfe/sincronizar' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"emitente_id\":12}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/dfe/sincronizar', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"emitente_id\":12}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/dfe/sincronizar', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"emitente_id\": 12\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/dfe/sincronizar',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"emitente_id\": 12\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/dfe/sincronizar\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"emitente_id\"\":12}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"emitente_id\":12}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/dfe/sincronizar', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/dfe/{id}":{"get":{"tags":["DF-e"],"summary":"Consultar nota recebida","description":"Um documento (§18).","operationId":"mostrar_dfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Dfe"},"examples":{"resumo":{"$ref":"#/components/examples/Dfe"},"completo":{"$ref":"#/components/examples/DfeCompleto"},"cancelada":{"$ref":"#/components/examples/DfeCancelada"}}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdDfe"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/dfe/{id}/xml":{"get":{"tags":["DF-e"],"summary":"XML da nota recebida","description":"procNFe completo quando já chegou (`xml_completo:true`); senão o resNFe (resumo). Cabeçalho MadNotas-Xml-Tipo: procNFe | resNFe.","operationId":"xml_dfe","responses":{"200":{"description":"XML","content":{"application/xml":{"schema":{"type":"string"}}},"headers":{"MadNotas-Xml-Tipo":{"schema":{"type":"string","enum":["procNFe","resNFe"]}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdDfe"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/xml' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/xml', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/xml', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/xml',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/xml\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/xml');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/dfe/{id}/manifestacao":{"post":{"tags":["DF-e"],"summary":"Manifestar","description":"Evento do destinatário (§19): ciencia 210210 (libera o XML completo na consulta seguinte), confirmacao 210200, desconhecimento 210220, nao_realizada 210240 (justificativa 15–255). Prazos e ordem são da SEFAZ: fora deles o evento sai `rejeitado` com o cStat (201), nunca 4xx. 4xx só para estado local: 409 manifestacao_em_andamento e 422 justificativa_invalida. Emitente com o DF-e desligado: 422 dfe_nao_habilitado.","operationId":"manifestar_dfe","responses":{"201":{"description":"Evento final (registrado ou rejeitado) + o documento.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManifestacaoDfeResposta"},"examples":{"registrado":{"$ref":"#/components/examples/ManifestacaoDfeResposta"},"rejeitado":{"$ref":"#/components/examples/ManifestacaoDfeRejeitada"}}}}},"202":{"description":"Processando (sem resposta do AN ainda).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManifestacaoDfeResposta"}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdDfe"},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManifestacaoDfe"},"examples":{"ciencia":{"$ref":"#/components/examples/ManifestacaoDfe"},"nao_realizada":{"$ref":"#/components/examples/ManifestacaoDfeNaoRealizada"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/manifestacao' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"tipo\":\"ciencia\"}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/manifestacao', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"tipo\":\"ciencia\"}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/manifestacao', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"tipo\": \"ciencia\"\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/manifestacao',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"tipo\": \"ciencia\"\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/manifestacao\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"tipo\"\":\"\"ciencia\"\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"tipo\":\"ciencia\"}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/manifestacao', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/dfe/{id}/eventos":{"get":{"tags":["DF-e"],"summary":"Eventos da nota recebida","description":"Manifestações enviadas + eventos do emissor (cancelamento, CC-e) que chegaram pela distribuição.","operationId":"eventos_dfe","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/EventoDfe"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}},"additionalProperties":true}}}},"404":{"$ref":"#/components/responses/404"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdDfe"},{"$ref":"#/components/parameters/Cursor"},{"$ref":"#/components/parameters/Limite"}],"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X GET 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/eventos' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/eventos', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/eventos', {\n  method: 'GET',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}` },\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/eventos',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"GET\"), \"https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/eventos\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Resp := Http.Execute('GET', 'https://notas.madbuilder.dev/api/v1/dfe/dfe_000000a1c3e9b2f4/eventos');\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/emitentes/{id}/dfe":{"put":{"tags":["Emitentes"],"summary":"Ligar/desligar o DF-e do emitente","description":"Liga a distribuição para o emitente (o MadNotas começa a consultar pela cadência dele). Em homologação/produção exige A1 válido do próprio CNPJ (422 certificado_indisponivel). Volta o emitente com o bloco dfe.","operationId":"dfe_emitente","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Emitente"}}}},"404":{"$ref":"#/components/responses/404"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"parameters":[{"$ref":"#/components/parameters/IdNumero"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DfeEmitenteEntrada"},"examples":{"ligar":{"$ref":"#/components/examples/DfeEmitenteEntrada"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X PUT 'https://notas.madbuilder.dev/api/v1/emitentes/12/dfe' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"habilitado\":true}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('PUT', 'https://notas.madbuilder.dev/api/v1/emitentes/12/dfe', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"habilitado\":true}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/emitentes/12/dfe', {\n  method: 'PUT',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"habilitado\": true\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'PUT', 'https://notas.madbuilder.dev/api/v1/emitentes/12/dfe',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"habilitado\": True\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"PUT\"), \"https://notas.madbuilder.dev/api/v1/emitentes/12/dfe\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"habilitado\"\":true}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"habilitado\":true}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('PUT', 'https://notas.madbuilder.dev/api/v1/emitentes/12/dfe', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}},"/simulacao/dfe":{"post":{"tags":["Conta"],"summary":"Simular notas recebidas","description":"Só chave de simulação (mn_sim_; senão 403 somente_simulacao): cria no AN simulado NF-e de entrada fictícias para o emitente (fornecedores fictícios com DV válido) e já consulta. Na manifestação, SIM-REJ-<cStat> na justificativa rejeita. `cancelamento_posterior` + `chave`: o fornecedor cancela uma nota já entregue (404 nao_encontrado se a chave não é deste emitente; 409 documento_nao_cancelavel se ela já está cancelada). Emitente com o DF-e desligado: 422 dfe_nao_habilitado.","operationId":"simular_dfe","responses":{"201":{"description":"Criadas.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimulacaoDfeResposta"},"examples":{"normal":{"$ref":"#/components/examples/SimulacaoDfeResposta"},"cancelamento_posterior":{"$ref":"#/components/examples/SimulacaoDfeRespostaCancelamentoPosterior"}}}}},"404":{"$ref":"#/components/responses/404"},"409":{"$ref":"#/components/responses/409"},"422":{"$ref":"#/components/responses/422"},"401":{"$ref":"#/components/responses/401"},"403":{"$ref":"#/components/responses/403"},"429":{"$ref":"#/components/responses/429"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimulacaoDfe"},"examples":{"normal":{"$ref":"#/components/examples/SimulacaoDfe"},"cancelamento_posterior":{"$ref":"#/components/examples/SimulacaoDfeCancelamentoPosterior"}}}}},"x-codeSamples":[{"lang":"curl","label":"cURL","source":"curl -X POST 'https://notas.madbuilder.dev/api/v1/simulacao/dfe' \\\n  -H 'Authorization: Bearer $MADNOTAS_CHAVE' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"emitente_id\":12,\"quantidade\":3,\"cenario\":\"normal\"}'"},{"lang":"php","label":"PHP (Guzzle)","source":"<?php\n$resp = (new GuzzleHttp\\Client())->request('POST', 'https://notas.madbuilder.dev/api/v1/simulacao/dfe', [\n    'headers' => [\n        'Authorization' => 'Bearer ' . getenv('MADNOTAS_CHAVE'),\n    ],\n    'json' => json_decode('{\"emitente_id\":12,\"quantidade\":3,\"cenario\":\"normal\"}', true),\n    'http_errors' => false,\n]);\n$nota = json_decode((string) $resp->getBody(), true);"},{"lang":"javascript","label":"JavaScript (fetch)","source":"const resp = await fetch('https://notas.madbuilder.dev/api/v1/simulacao/dfe', {\n  method: 'POST',\n  headers: { Authorization: `Bearer ${process.env.MADNOTAS_CHAVE}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({\n      \"emitente_id\": 12,\n      \"quantidade\": 3,\n      \"cenario\": \"normal\"\n  }),\n});\nconst nota = await resp.json();"},{"lang":"python","label":"Python (requests)","source":"import os, requests\n\nresp = requests.request(\n    'POST', 'https://notas.madbuilder.dev/api/v1/simulacao/dfe',\n    headers={'Authorization': f\"Bearer {os.environ['MADNOTAS_CHAVE']}\"},\n    json={\n        \"emitente_id\": 12,\n        \"quantidade\": 3,\n        \"cenario\": \"normal\"\n    },\n    timeout=30,\n)\nnota = resp.json()"},{"lang":"csharp","label":"C# (HttpClient)","source":"using var http = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://notas.madbuilder.dev/api/v1/simulacao/dfe\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + Environment.GetEnvironmentVariable(\"MADNOTAS_CHAVE\"));\nreq.Content = new StringContent(@\"{\"\"emitente_id\"\":12,\"\"quantidade\"\":3,\"\"cenario\"\":\"\"normal\"\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await http.SendAsync(req);\nvar nota = await resp.Content.ReadAsStringAsync();"},{"lang":"delphi","label":"Delphi (THTTPClient)","source":"// Delphi 10.4+ — System.Net.HttpClient\nvar\n  Http: THTTPClient;\n  Corpo: TStringStream;\n  Resp: IHTTPResponse;\nbegin\n  Http := THTTPClient.Create;\n  try\n    Http.CustomHeaders['Authorization'] := 'Bearer ' + GetEnvironmentVariable('MADNOTAS_CHAVE');\n    Http.ContentType := 'application/json';\n    Corpo := TStringStream.Create('{\"emitente_id\":12,\"quantidade\":3,\"cenario\":\"normal\"}', TEncoding.UTF8);\n    try\n      Resp := Http.Execute('POST', 'https://notas.madbuilder.dev/api/v1/simulacao/dfe', Corpo);\n    finally\n      Corpo.Free;\n    end;\n    Writeln(Resp.StatusCode, ' ', Resp.ContentAsString(TEncoding.UTF8));\n  finally\n    Http.Free;\n  end;\nend;"}]}}},"components":{"securitySchemes":{"chaveApi":{"type":"http","scheme":"bearer","bearerFormat":"mn_sim_… | mn_hom_… | mn_prod_…","description":"Authorization: Bearer <chave>. Chave de produção é recusada nesta documentação interativa."}},"schemas":{"Erro":{"type":"object","properties":{"erro":{"type":"object","properties":{"tipo":{"type":"string","enum":["autenticacao","permissao","validacao","conflito","nao_encontrado","limite","conta","idempotencia","requisicao","indisponivel","interno"]},"codigo":{"type":"string","description":"Código estável, para o seu código tratar (ex.: payload_invalido, chave_invalida, limite_excedido)."},"mensagem":{"type":"string","description":"Texto em português para mostrar a uma pessoa."},"detalhes":{"type":"array","items":{"$ref":"#/components/schemas/ErroCampo"}}},"required":["tipo","codigo","mensagem","detalhes"]},"request_id":{"type":"string","description":"Mande este id ao suporte. Também vem no cabeçalho X-Request-Id."}},"required":["erro","request_id"],"description":"Envelope único de erro. Rejeição da SEFAZ NÃO é erro HTTP: é o status `rejeitada` do documento."},"ErroCampo":{"type":"object","properties":{"campo":{"type":["string","null"],"description":"Caminho JSON do campo no SEU payload (ex.: itens[2].ncm)."},"codigo":{"type":"string"},"mensagem":{"type":"string"},"severidade":{"type":"string","enum":["erro","aviso"]},"sefaz":{"type":["object","null"],"properties":{"cstat":{"type":"string"},"xmotivo":{"type":"string"}},"description":"Rejeição da SEFAZ que este erro evita."},"dica":{"type":["string","null"]},"documentacao":{"type":["string","null"],"format":"uri"}},"required":["codigo","mensagem"]},"Aviso":{"type":"object","properties":{"campo":{"type":["string","null"]},"codigo":{"type":"string","description":"Código do aviso. Do cálculo do DIFAL (calcular: true): difal_divergente_do_calculado = o DIFAL enviado em itens[].difal (base_calculo, valor_destino, valor_fcp) foi mantido na nota e difere do calculado pelo MadNotas (a mensagem traz os dois valores); difal_confirmar_contador = o MadNotas calculou o DIFAL pela regra pesquisada da UF de destino (base única ou dupla), que ainda pede confirmação do contador (não contribuinte: MG, MS, TO, PA, PB, PI; contribuinte: RJ)."},"mensagem":{"type":"string"},"em":{"type":["string","null"],"format":"date-time"}},"required":["codigo","mensagem"]},"EmitenteResumo":{"type":"object","properties":{"id":{"type":"integer"},"cnpj":{"type":"string","pattern":"^[0-9A-Z]{12}[0-9]{2}$","description":"CNPJ (aceita o formato alfanumérico de 2026), só letras maiúsculas e dígitos."},"razao_social":{"type":"string"}}},"Sefaz":{"type":"object","properties":{"cstat":{"type":["string","null"]},"motivo":{"type":["string","null"]},"protocolo":{"type":["string","null"]},"recibo":{"type":["string","null"]}}},"Documento":{"type":"object","properties":{"id":{"type":"string","description":"Id público (nfe_… / nfce_…). Use em todas as rotas do documento."},"objeto":{"type":"string","enum":["nfe","nfce"]},"ambiente":{"type":"string","enum":["simulacao","homologacao","producao"],"description":"Vem da chave de API (mn_sim_ / mn_hom_ / mn_prod_)."},"modelo":{"type":"string","enum":["55","65"]},"ref":{"type":["string","null"],"description":"Sua referência. Mesma ref + mesmo payload = a mesma nota (replay)."},"status":{"type":"string","enum":["processando","autorizada","rejeitada","denegada","contingencia","cancelada","descartada"]},"etapa":{"type":"string","enum":["na_fila","enviando","aguardando_recibo","verificando","aguardando_sefaz","concluido"]},"emitente":{"$ref":"#/components/schemas/EmitenteResumo"},"serie":{"type":["integer","null"]},"numero":{"type":["integer","null"]},"chave":{"type":["string","null"],"pattern":"^[0-9A-Z]{44}$"},"tipo_emissao":{"type":"integer","description":"tpEmis: 1 normal, 6/7 SVC, 9 contingência offline NFC-e."},"contingencia":{"type":"boolean"},"data_emissao":{"type":["string","null"],"format":"date-time"},"valor_total":{"type":["string","null"],"pattern":"^-?\\d+(\\.\\d+)?$","description":"Decimal em string com ponto (ex.: \"130.00\"). Nunca float."},"destinatario":{"type":["object","null"],"properties":{"documento":{"type":["string","null"]},"nome":{"type":["string","null"]}}},"sefaz":{"$ref":"#/components/schemas/Sefaz"},"autorizada_em":{"type":["string","null"],"format":"date-time"},"cancelada_em":{"type":["string","null"],"format":"date-time"},"erros":{"type":"array","items":{"$ref":"#/components/schemas/ErroCampo"},"description":"Na rejeição: o que a SEFAZ recusou, com o campo do seu payload e a correção."},"avisos":{"type":"array","items":{"$ref":"#/components/schemas/Aviso"}},"tentativas":{"type":"integer"},"proxima_tentativa_em":{"type":["string","null"],"format":"date-time"},"origem":{"type":"string","enum":["api","painel","playground","agente"]},"substitui":{"type":["string","null"]},"substituida_por":{"type":["string","null"]},"criado_em":{"type":["string","null"],"format":"date-time"},"atualizado_em":{"type":["string","null"],"format":"date-time"},"links":{"type":"object","properties":{"self":{"type":"string","format":"uri"},"xml":{"type":"string","format":"uri"},"danfe":{"type":"string","format":"uri"},"eventos":{"type":"string","format":"uri"}}},"payload":{"description":"Só em GET /{id}?incluir=payload."}},"required":["id","objeto","ambiente","modelo","status","etapa","links"],"examples":[{"id":"nfe_01jbx3k9q8m2s7t4v6w8y0z1a2","objeto":"nfe","ambiente":"simulacao","modelo":"55","ref":"pedido-1001","status":"autorizada","etapa":"concluido","emitente":{"id":9,"cnpj":"99999999000191","razao_social":"Empresa de Demonstração Ltda"},"serie":1,"numero":1532,"chave":"35261099999999000191550010000015321123456780","tipo_emissao":1,"contingencia":false,"data_emissao":"2026-10-29T16:05:12-03:00","valor_total":"100.00","destinatario":{"documento":"12ABC34501DE35","nome":"COMERCIO FICTICIO LTDA"},"sefaz":{"cstat":"100","motivo":"Autorizado o uso da NF-e","protocolo":"135260000012345","recibo":null},"autorizada_em":"2026-10-29T16:05:14-03:00","cancelada_em":null,"erros":[],"avisos":[],"tentativas":1,"proxima_tentativa_em":null,"origem":"api","substitui":null,"substituida_por":null,"criado_em":"2026-10-29T16:05:12-03:00","atualizado_em":"2026-10-29T16:05:14-03:00","links":{"self":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2","xml":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/xml","danfe":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/danfe","eventos":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/eventos"}}]},"ListaDocumentos":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Documento"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}},"required":["dados"]},"Validacao":{"type":"object","properties":{"valido":{"type":"boolean"},"erros":{"type":"array","items":{"$ref":"#/components/schemas/ErroCampo"}},"avisos":{"type":"array","items":{"$ref":"#/components/schemas/Aviso"}},"chave_prevista":{"type":["string","null"],"pattern":"^[0-9A-Z]{43}[0-9]$","description":"Chave que a nota teria com o próximo número (não reservado)."},"serie":{"type":["integer","null"]},"numero_previsto":{"type":["integer","null"],"description":"Próximo número da série. Não é reservado: outra emissão pode usá-lo antes."},"xml":{"type":["string","null"],"description":"XML montado e assinado, sem transmitir (só quando valido=true)."},"totais":{"type":["object","null"],"description":"Totais calculados (ICMS, IBS/CBS, vNF); null quando o payload não passou da forma."}},"required":["valido","erros","avisos","chave_prevista","serie","numero_previsto","xml","totais"]},"Evento":{"type":"object","properties":{"id":{"type":"string"},"objeto":{"type":"string","const":"evento"},"tipo":{"type":"string","enum":["cancelamento","carta_correcao","cancelamento_substituicao","cancelamento_externo"]},"codigo_evento":{"type":"string"},"sequencia":{"type":"integer"},"texto":{"type":["string","null"]},"status":{"type":"string","enum":["processando","registrado","rejeitado"]},"sefaz":{"type":"object","properties":{"cstat":{"type":["string","null"]},"motivo":{"type":["string","null"]},"protocolo":{"type":["string","null"]}}},"registrado_em":{"type":["string","null"],"format":"date-time"},"criado_em":{"type":["string","null"],"format":"date-time"},"documento":{"$ref":"#/components/schemas/Documento"},"codigo_motivo":{"type":["string","null"],"description":"NFS-e: 1, 2 ou 9."}},"required":["id","objeto","tipo","status"]},"Inutilizacao":{"type":"object","properties":{"id":{"type":"string"},"objeto":{"type":"string","const":"inutilizacao"},"ambiente":{"type":"string"},"modelo":{"type":"string","enum":["55","65"]},"emitente":{"$ref":"#/components/schemas/EmitenteResumo"},"serie":{"type":"integer"},"numero_inicial":{"type":"integer"},"numero_final":{"type":"integer"},"ano":{"type":"integer"},"justificativa":{"type":"string"},"status":{"type":"string"},"sefaz":{"type":"object","properties":{"cstat":{"type":["string","null"]},"motivo":{"type":["string","null"]},"protocolo":{"type":["string","null"]}}},"origem":{"type":"string"},"registrada_em":{"type":["string","null"],"format":"date-time"},"criado_em":{"type":["string","null"],"format":"date-time"}},"required":["id","objeto","status"]},"Endereco":{"type":"object","properties":{"logradouro":{"type":"string"},"numero":{"type":"string"},"complemento":{"type":["string","null"]},"bairro":{"type":"string"},"codigo_municipio":{"type":"string","pattern":"^\\d{7}$","description":"Código IBGE do município."},"municipio":{"type":["string","null"]},"uf":{"type":"string","pattern":"^[A-Z]{2}$"},"cep":{"type":"string","pattern":"^\\d{8}$"}}},"Certificado":{"type":"object","properties":{"titular":{"type":["string","null"]},"cnpj":{"type":["string","null"]},"serial":{"type":["string","null"]},"valido_de":{"type":["string","null"],"format":"date-time"},"valido_ate":{"type":["string","null"],"format":"date-time"},"dias_para_vencer":{"type":["integer","null"]},"ativo":{"type":"boolean"}},"description":"Só dados públicos do A1. O arquivo e a senha nunca voltam."},"Emitente":{"type":"object","properties":{"id":{"type":"integer"},"objeto":{"type":"string","const":"emitente"},"cnpj":{"type":"string","pattern":"^[0-9A-Z]{12}[0-9]{2}$","description":"CNPJ (aceita o formato alfanumérico de 2026), só letras maiúsculas e dígitos."},"razao_social":{"type":"string"},"nome_fantasia":{"type":["string","null"]},"inscricao_estadual":{"type":["string","null"]},"inscricao_municipal":{"type":["string","null"]},"cnae":{"type":["string","null"]},"crt":{"type":"integer","enum":[1,2,3,4],"description":"1 Simples · 2 Simples excesso · 3 normal · 4 MEI."},"endereco":{"$ref":"#/components/schemas/Endereco"},"certificado":{"oneOf":[{"$ref":"#/components/schemas/Certificado"},{"type":"null"}]},"avisos":{"type":"array","items":{"$ref":"#/components/schemas/Aviso"}},"nfse":{"$ref":"#/components/schemas/NfseEmitente"},"dfe":{"$ref":"#/components/schemas/DfeEmitente"}},"required":["id","cnpj","razao_social"]},"EmitenteEntrada":{"type":"object","properties":{"cnpj":{"type":"string","pattern":"^[0-9A-Z]{12}[0-9]{2}$","description":"CNPJ (aceita o formato alfanumérico de 2026), só letras maiúsculas e dígitos."},"razao_social":{"type":"string"},"nome_fantasia":{"type":"string"},"inscricao_estadual":{"type":["string","null"],"description":"Opcional. Ausente, null, \"\" ou \"ISENTO\" = sem IE (\"ISENTO\" é gravado como null e volta o aviso ie_isento_tratado_como_ausente). Obrigatória só para emitir NF-e/NFC-e: sem ela, 422 emitente_sem_ie."},"inscricao_municipal":{"type":"string"},"cnae":{"type":"string"},"crt":{"type":"integer","enum":[1,2,3,4]},"telefone":{"type":"string"},"email":{"type":"string","format":"email"},"endereco":{"$ref":"#/components/schemas/Endereco"}},"required":["cnpj","razao_social","crt","endereco"]},"CertificadoEntrada":{"type":"object","properties":{"pfx_base64":{"type":"string","contentEncoding":"base64","description":"Arquivo .pfx/.p12 (A1) em base64, até 200 KB. Alias: arquivo_base64."},"senha":{"type":"string","format":"password"}},"required":["pfx_base64","senha"]},"Prontidao":{"type":"object","properties":{"pronto":{"type":"boolean"},"itens":{"type":"array","items":{"type":"object","properties":{"item":{"type":"string"},"ok":{"type":"boolean"},"nivel":{"type":"string","enum":["ok","aviso","erro"]},"mensagem":{"type":"string"}}}}}},"Webhook":{"type":"object","properties":{"id":{"type":"string"},"objeto":{"type":"string","const":"webhook"},"url":{"type":"string","format":"uri"},"eventos":{"type":"array","items":{"type":"string"}},"ativo":{"type":"boolean"},"criado_em":{"type":["string","null"],"format":"date-time"}},"additionalProperties":true},"WebhookCriado":{"allOf":[{"$ref":"#/components/schemas/Webhook"},{"type":"object","properties":{"segredo":{"type":"string","description":"whsec_… — aparece UMA vez. Use para validar a assinatura MadNotas-Assinatura."}}}]},"Entrega":{"type":"object","properties":{"id":{"type":"integer"},"evento":{"type":"string"},"evento_id":{"type":"string"},"endpoint":{"type":["string","null"]},"documento_id":{"type":["integer","null"]},"status":{"type":"string"},"tentativas":{"type":"integer"},"proxima_tentativa_em":{"type":["string","null"],"format":"date-time"},"ultimo_status_http":{"type":["integer","null"]},"ultimo_erro":{"type":["string","null"]},"ultima_latencia_ms":{"type":["integer","null"]},"entregue_em":{"type":["string","null"],"format":"date-time"},"criado_em":{"type":["string","null"],"format":"date-time"}},"additionalProperties":true},"EntregaDetalhe":{"allOf":[{"$ref":"#/components/schemas/Entrega"},{"type":"object","properties":{"corpo":{"type":["object","null"],"description":"JSON enviado ao seu endpoint."},"historico":{"type":"array","items":{"type":"object","properties":{"numero":{"type":"integer"},"enviado_em":{"type":["string","null"],"format":"date-time"},"latencia_ms":{"type":["integer","null"]},"resultado":{"type":"string","enum":["sucesso","falha"]},"erro":{"type":["string","null"]},"requisicao":{"type":"object","properties":{"url":{"type":"string"},"cabecalhos":{"type":"object","additionalProperties":{"type":"string"}},"corpo_sha256":{"type":"string"}}},"resposta":{"type":["object","null"],"properties":{"status":{"type":["integer","null"]},"cabecalhos":{"type":"object","additionalProperties":{"type":"string"}},"corpo":{"type":["string","null"]},"truncado":{"type":"boolean"}}}},"additionalProperties":true}}},"additionalProperties":true}],"description":"Detalhe da entrega: o corpo JSON enviado e, por tentativa (mais nova primeiro), a requisição (URL, cabeçalhos com MadNotas-Assinatura e MadNotas-Evento-Id, sha256 do corpo; nunca o segredo) e a resposta do seu servidor (status, cabeçalhos e até 4 KB do corpo; `truncado` = cortou). Guardado por 30 dias."},"Uso":{"type":"object","properties":{"periodo":{"type":"string"},"emitidas":{"type":"integer"},"franquia":{"type":["integer","null"]},"excedente":{"type":"integer"},"por_modelo":{"type":"object","description":"Produção: nfe, nfce e nfse.","additionalProperties":{"type":"object","properties":{"usadas":{"type":"integer"},"autorizadas":{"type":"integer"},"denegadas":{"type":"integer"},"rejeitadas":{"type":"integer"},"canceladas":{"type":"integer"}},"additionalProperties":true}}},"additionalProperties":true},"SefazStatus":{"type":"object","properties":{"atualizado_em":{"type":["string","null"],"format":"date-time"},"autorizadores":{"type":"array","items":{"type":"object","properties":{"autorizador":{"type":"string"},"modelo":{"type":"string"},"ambiente":{"type":"string"},"status":{"type":"string","enum":["operacional","lento","instavel","fora","sem_sonda","desconhecido"]},"cstat":{"type":["string","null"]},"xmotivo":{"type":["string","null"]},"p50_ms":{"type":["integer","null"]},"p95_ms":{"type":["integer","null"]},"verificado_em":{"type":["string","null"],"format":"date-time"},"ufs":{"type":"array","items":{"type":"string"}}}}},"incidentes":{"type":"array","items":{"type":"object","additionalProperties":true}}}},"Rejeicao":{"type":"object","properties":{"cstat":{"type":"string"},"mensagem":{"type":"string"},"explicacao":{"type":["string","null"]},"dica":{"type":["string","null"]},"como_corrigir":{"type":["string","null"]},"campo":{"type":["string","null"]},"documentacao":{"type":["string","null"],"format":"uri"},"regra":{"type":["string","null"]},"transiente":{"type":"boolean"},"consome_numero":{"type":"boolean"},"acao":{"type":["string","null"]}}},"ChaveAcesso":{"type":"object","properties":{"chave":{"type":"string"},"valida":{"type":"boolean"},"uf":{"type":["string","null"]},"ano_mes":{"type":["string","null"]},"cnpj":{"type":["string","null"]},"modelo":{"type":["string","null"]},"serie":{"type":["integer","null"]},"numero":{"type":["integer","null"]},"tipo_emissao":{"type":["integer","null"]},"codigo_numerico":{"type":["string","null"]},"dv":{"type":["string","null"]}},"additionalProperties":true},"Referencia":{"type":"object","properties":{"codigo":{"type":"string"},"descricao":{"type":"string"}},"additionalProperties":true},"PayloadNfe":{"title":"Payload de emissão NF-e / NFC-e (MadNotas API v1)","description":"Corpo de POST /api/v1/nfe e /api/v1/nfce. Gerado de NfePayloadNormalizer::MAPA (contrato em NfeNormalizado.md).","type":"object","properties":{"ref":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[A-Za-z0-9_.:/-]+$","description":"Sua referência única do documento (idempotência por empresa + ambiente + modelo): até 100 caracteres sem acento (ASCII) de letras, números, ponto, dois-pontos, barra, hífen e sublinhado. Vazia, só espaços ou não texto = 422 ref_invalida; omita para não usar."},"serie":{"type":"integer","minimum":0,"maximum":999,"description":"Série (opcional; padrão da série ativa do emitente)."},"natureza_operacao":{"type":"string","description":"XML: natOp","minLength":1,"maxLength":60},"tipo":{"type":"string","enum":["entrada","saida","0","1"],"description":"XML: tpNF"},"finalidade":{"type":"string","enum":["normal","complementar","ajuste","devolucao","credito","debito","1","2","3","4","5","6"],"description":"XML: finNFe"},"consumidor_final":{"type":"boolean","description":"XML: indFinal"},"presenca":{"type":"string","enum":["nao_se_aplica","presencial","internet","telefone","entrega_domicilio","presencial_fora","outros","0","1","2","3","4","5","9"],"description":"XML: indPres"},"local_destino":{"type":"string","enum":["interna","interestadual","exterior","1","2","3"],"description":"XML: idDest"},"formato_danfe":{"type":"string","enum":["sem_danfe","retrato","paisagem","simplificado","nfce","nfce_mensagem","0","1","2","3","4","5"],"description":"XML: tpImp"},"data_saida":{"type":"string","format":"date-time","description":"XML: dhSaiEnt"},"data_prevista_entrega":{"type":"string","format":"date","description":"XML: dPrevEntrega"},"municipio_fato_gerador":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMunFG"},"municipio_fato_gerador_ibs":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMunFGIBS"},"tipo_nota_debito":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: tpNFDebito"},"tipo_nota_credito":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: tpNFCredito"},"notas_referenciadas":{"type":"array","items":{"type":"object","properties":{"chave":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: refNFe"},"chave_cte":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: refCTe"},"nf":{"type":"object","properties":{"uf":{"type":"string","pattern":"^([A-Z]{2}|[0-9]{2})$","description":"XML: cUF"},"ano_mes":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: AAMM"},"cnpj":{"type":"string","description":"XML: CNPJ"},"modelo":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: mod"},"serie":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: serie"},"numero":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nNF"}},"additionalProperties":false},"produtor":{"type":"object","properties":{"uf":{"type":"string","pattern":"^([A-Z]{2}|[0-9]{2})$","description":"XML: cUF"},"ano_mes":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: AAMM"},"cnpj":{"type":"string","description":"XML: CNPJ"},"cpf":{"type":"string","description":"XML: CPF"},"inscricao_estadual":{"type":"string","description":"XML: IE"},"modelo":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: mod"},"serie":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: serie"},"numero":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nNF"}},"additionalProperties":false},"ecf":{"type":"object","properties":{"modelo":{"type":"string","description":"XML: mod"},"numero_ecf":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nECF"},"coo":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nCOO"}},"additionalProperties":false}},"additionalProperties":false}},"compra_governamental":{"type":"object","properties":{"tipo_ente":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: tpEnteGov"},"percentual_reducao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pRedutor"},"tipo_operacao":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: tpOperGov"}},"additionalProperties":false},"emitente":{"type":"object","properties":{"nome_fantasia":{"type":"string","description":"XML: xFant","minLength":1,"maxLength":60},"inscricao_estadual_st":{"type":"string","description":"XML: IEST"}},"additionalProperties":false},"destinatario":{"type":"object","properties":{"cnpj":{"type":"string","description":"XML: CNPJ"},"cpf":{"type":"string","description":"XML: CPF"},"id_estrangeiro":{"type":"string","description":"XML: idEstrangeiro"},"nome":{"type":"string","description":"XML: xNome","minLength":2,"maxLength":60},"indicador_ie":{"type":"string","enum":["contribuinte","isento","nao_contribuinte","1","2","9"],"description":"XML: indIEDest"},"inscricao_estadual":{"type":"string","description":"XML: IE"},"inscricao_suframa":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: ISUF"},"inscricao_municipal":{"type":"string","description":"XML: IM","minLength":1,"maxLength":15},"email":{"type":"string","description":"XML: email","minLength":1,"maxLength":60},"endereco":{"type":"object","properties":{"logradouro":{"type":"string","description":"XML: xLgr","minLength":2,"maxLength":60},"numero":{"type":"string","description":"XML: nro","minLength":1,"maxLength":60},"complemento":{"type":"string","description":"XML: xCpl","minLength":1,"maxLength":60},"bairro":{"type":"string","description":"XML: xBairro","minLength":2,"maxLength":60},"codigo_municipio":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMun"},"municipio":{"type":"string","description":"XML: xMun","minLength":2,"maxLength":60},"uf":{"type":"string","description":"XML: UF"},"cep":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CEP"},"codigo_pais":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cPais"},"pais":{"type":"string","description":"XML: xPais","minLength":2,"maxLength":60},"telefone":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: fone"}},"additionalProperties":false}},"additionalProperties":false,"description":"Destinatário. Na NFC-e é opcional (CPF/CNPJ do consumidor)."},"retirada":{"type":"object","properties":{"cnpj":{"type":"string","description":"XML: CNPJ"},"cpf":{"type":"string","description":"XML: CPF"},"nome":{"type":"string","description":"XML: xNome","minLength":2,"maxLength":60},"endereco":{"type":"object","properties":{"logradouro":{"type":"string","description":"XML: xLgr","minLength":2,"maxLength":60},"numero":{"type":"string","description":"XML: nro","minLength":1,"maxLength":60},"complemento":{"type":"string","description":"XML: xCpl","minLength":1,"maxLength":60},"bairro":{"type":"string","description":"XML: xBairro","minLength":2,"maxLength":60},"codigo_municipio":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMun"},"municipio":{"type":"string","description":"XML: xMun","minLength":2,"maxLength":60},"uf":{"type":"string","description":"XML: UF"},"cep":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CEP"}},"additionalProperties":false},"inscricao_estadual":{"type":"string","description":"XML: IE"}},"additionalProperties":false},"entrega":{"type":"object","properties":{"cnpj":{"type":"string","description":"XML: CNPJ"},"cpf":{"type":"string","description":"XML: CPF"},"nome":{"type":"string","description":"XML: xNome","minLength":2,"maxLength":60},"endereco":{"type":"object","properties":{"logradouro":{"type":"string","description":"XML: xLgr","minLength":2,"maxLength":60},"numero":{"type":"string","description":"XML: nro","minLength":1,"maxLength":60},"complemento":{"type":"string","description":"XML: xCpl","minLength":1,"maxLength":60},"bairro":{"type":"string","description":"XML: xBairro","minLength":2,"maxLength":60},"codigo_municipio":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMun"},"municipio":{"type":"string","description":"XML: xMun","minLength":2,"maxLength":60},"uf":{"type":"string","description":"XML: UF"},"cep":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CEP"}},"additionalProperties":false},"inscricao_estadual":{"type":"string","description":"XML: IE"}},"additionalProperties":false},"autorizados_xml":{"type":"array","items":{"type":"string","description":"XML: *"}},"itens":{"type":"array","items":{"type":"object","properties":{"codigo":{"type":"string","description":"XML: cProd","minLength":1,"maxLength":60},"gtin":{"type":"string","description":"XML: cEAN"},"codigo_barras":{"type":"string","description":"XML: cBarra","minLength":3,"maxLength":30},"descricao":{"type":"string","description":"XML: xProd","minLength":1,"maxLength":120},"ncm":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: NCM"},"nve":{"type":"array","items":{"type":"string"},"description":"XML: NVE"},"cest":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CEST"},"escala_relevante":{"type":"boolean","description":"XML: indEscala"},"cnpj_fabricante":{"type":"string","description":"XML: CNPJFab"},"beneficio_fiscal":{"type":"string","description":"XML: cBenef"},"ex_tipi":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: EXTIPI"},"cfop":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CFOP"},"unidade":{"type":"string","description":"XML: uCom","minLength":1,"maxLength":6},"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qCom"},"valor_unitario":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vUnCom"},"valor_bruto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vProd"},"gtin_tributavel":{"type":"string","description":"XML: cEANTrib"},"codigo_barras_tributavel":{"type":"string","description":"XML: cBarraTrib","minLength":3,"maxLength":30},"unidade_tributavel":{"type":"string","description":"XML: uTrib","minLength":1,"maxLength":6},"quantidade_tributavel":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qTrib"},"valor_unitario_tributavel":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vUnTrib"},"frete":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFrete"},"seguro":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vSeg"},"desconto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDesc"},"outras_despesas":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vOutro"},"compoe_total":{"type":"boolean","description":"XML: indTot"},"pedido":{"type":"object","properties":{"numero":{"type":"string","description":"XML: xPed","minLength":1,"maxLength":15},"item":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nItemPed"}},"additionalProperties":false},"fci":{"type":"string","description":"XML: nFCI"},"exportacoes":{"type":"array","items":{"type":"object","properties":{"drawback":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nDraw"},"registro_exportacao":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nRE"},"chave_nfe":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: chNFe"},"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qExport"}},"additionalProperties":false}},"rastreabilidade":{"type":"array","items":{"type":"object","properties":{"lote":{"type":"string","description":"XML: nLote","minLength":1,"maxLength":20},"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qLote"},"fabricacao":{"type":"string","format":"date","description":"XML: dFab"},"validade":{"type":"string","format":"date","description":"XML: dVal"},"agregacao":{"type":"string","description":"XML: cAgreg","minLength":1,"maxLength":20}},"additionalProperties":false}},"medicamento":{"type":"object","properties":{"codigo_anvisa":{"type":"string","description":"XML: cProdANVISA"},"motivo_isencao":{"type":"string","description":"XML: xMotivoIsencao","minLength":1,"maxLength":255},"preco_maximo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vPMC"}},"additionalProperties":false},"combustivel":{"type":"object","properties":{"codigo_anp":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cProdANP"},"descricao_anp":{"type":"string","description":"XML: descANP","minLength":2,"maxLength":95},"uf_consumo":{"type":"string","description":"XML: UFCons"},"percentual_glp":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pGLP"},"percentual_gas_nacional":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pGNn"},"percentual_gas_importado":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pGNi"},"valor_partida":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vPart"},"codif":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CODIF"},"quantidade_temperatura_ambiente":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qTemp"},"cide":{"type":"object","properties":{"base_quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qBCProd"},"aliquota_valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vAliqProd"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vCIDE"}},"additionalProperties":false},"encerrante":{"type":"object","properties":{"bico":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nBico"},"bomba":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nBomba"},"tanque":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nTanque"},"inicial":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vEncIni"},"final":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vEncFin"}},"additionalProperties":false},"percentual_biodiesel":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pBio"},"origens":{"type":"array","items":{"type":"object","properties":{"importado":{"type":"boolean","description":"XML: indImport"},"uf":{"type":"string","pattern":"^([A-Z]{2}|[0-9]{2})$","description":"XML: cUFOrig"},"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pOrig"}},"additionalProperties":false}}},"additionalProperties":false},"veiculo":{"type":"object","properties":{"tipo_operacao":{"type":"string","enum":["venda_concessionaria","faturamento_direto","venda_direta","outros","0","1","2","3"],"description":"XML: tpOp"},"chassi":{"type":"string","description":"XML: chassi","minLength":17,"maxLength":17},"codigo_cor":{"type":"string","description":"XML: cCor","minLength":1,"maxLength":4},"cor":{"type":"string","description":"XML: xCor","minLength":1,"maxLength":40},"potencia":{"type":"string","description":"XML: pot","minLength":1,"maxLength":4},"cilindradas":{"type":"string","description":"XML: cilin","minLength":1,"maxLength":4},"peso_liquido":{"type":"string","description":"XML: pesoL","minLength":1,"maxLength":9},"peso_bruto":{"type":"string","description":"XML: pesoB","minLength":1,"maxLength":9},"numero_serie":{"type":"string","description":"XML: nSerie","minLength":1,"maxLength":9},"tipo_combustivel":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: tpComb"},"numero_motor":{"type":"string","description":"XML: nMotor","minLength":1,"maxLength":21},"cmt":{"type":"string","description":"XML: CMT","minLength":1,"maxLength":9},"distancia_eixos":{"type":"string","description":"XML: dist","minLength":1,"maxLength":4},"ano_modelo":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: anoMod"},"ano_fabricacao":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: anoFab"},"tipo_pintura":{"type":"string","description":"XML: tpPint","minLength":1,"maxLength":1},"tipo_veiculo":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: tpVeic"},"especie":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: espVeic"},"vin":{"type":"string","enum":["remarcado","normal","R","N"],"description":"XML: VIN"},"condicao":{"type":"string","enum":["acabado","inacabado","semiacabado","1","2","3"],"description":"XML: condVeic"},"codigo_modelo":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMod"},"cor_denatran":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cCorDENATRAN"},"lotacao":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: lota"},"restricao":{"type":"string","enum":["nenhuma","alienacao_fiduciaria","arrendamento_mercantil","reserva_dominio","penhor","outras","0","1","2","3","4","9"],"description":"XML: tpRest"}},"additionalProperties":false},"armas":{"type":"array","items":{"type":"object","properties":{"tipo":{"type":"string","enum":["uso_permitido","uso_restrito","0","1"],"description":"XML: tpArma"},"numero_serie":{"type":"string","description":"XML: nSerie","minLength":1,"maxLength":15},"numero_cano":{"type":"string","description":"XML: nCano","minLength":1,"maxLength":15},"descricao":{"type":"string","description":"XML: descr","minLength":1,"maxLength":256}},"additionalProperties":false}},"recopi":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nRECOPI"},"importacoes":{"type":"array","items":{"type":"object","properties":{"numero":{"type":"string","description":"XML: nDI","minLength":1,"maxLength":15},"data":{"type":"string","format":"date","description":"XML: dDI"},"local_desembaraco":{"type":"string","description":"XML: xLocDesemb","minLength":1,"maxLength":60},"uf_desembaraco":{"type":"string","description":"XML: UFDesemb"},"data_desembaraco":{"type":"string","format":"date","description":"XML: dDesemb"},"via_transporte":{"type":"string","enum":["maritima","fluvial","lacustre","aerea","postal","ferroviaria","rodoviaria","conduto","meios_proprios","entrada_saida_ficta","courier","em_maos","reboque","1","2","3","4","5","6","7","8","9","10","11","12","13"],"description":"XML: tpViaTransp"},"afrmm":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vAFRMM"},"intermediacao":{"type":"string","enum":["conta_propria","conta_e_ordem","encomenda","1","2","3"],"description":"XML: tpIntermedio"},"cnpj_adquirente":{"type":"string","description":"XML: CNPJ"},"cpf_adquirente":{"type":"string","description":"XML: CPF"},"uf_adquirente":{"type":"string","description":"XML: UFTerceiro"},"codigo_exportador":{"type":"string","description":"XML: cExportador","minLength":1,"maxLength":60},"adicoes":{"type":"array","items":{"type":"object","properties":{"numero":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nAdicao"},"sequencia":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nSeqAdic"},"fabricante":{"type":"string","description":"XML: cFabricante","minLength":1,"maxLength":60},"desconto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDescDI"},"drawback":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nDraw"}},"additionalProperties":false}}},"additionalProperties":false}},"credito_presumido":{"type":"array","items":{"type":"object","properties":{"codigo":{"type":"string","description":"XML: cCredPresumido"},"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pCredPresumido"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vCredPresumido"}},"additionalProperties":false}},"observacao":{"type":"object","properties":{"campo":{"type":"string","description":"XML: xCampo"},"texto":{"type":"string","description":"XML: xTexto","minLength":1,"maxLength":60}},"additionalProperties":false},"observacao_fisco":{"type":"object","properties":{"campo":{"type":"string","description":"XML: xCampo"},"texto":{"type":"string","description":"XML: xTexto","minLength":1,"maxLength":60}},"additionalProperties":false},"issqn":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBC"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vAliq"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vISSQN"},"municipio_fato_gerador":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMunFG"},"item_lista_servico":{"type":"string","description":"XML: cListServ"},"deducao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDeducao"},"outras_retencoes":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vOutro"},"desconto_incondicionado":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDescIncond"},"desconto_condicionado":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDescCond"},"valor_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vISSRet"},"exigibilidade":{"type":"string","enum":["exigivel","nao_incidencia","isencao","exportacao","imunidade","suspensa_judicial","suspensa_administrativa","1","2","3","4","5","6","7"],"description":"XML: indISS"},"codigo_servico":{"type":"string","description":"XML: cServico","minLength":1,"maxLength":20},"municipio_incidencia":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMun"},"pais":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cPais"},"processo":{"type":"string","description":"XML: nProcesso","minLength":1,"maxLength":30},"incentivo_fiscal":{"type":"boolean","description":"XML: indIncentivo"}},"additionalProperties":false},"informacoes_adicionais":{"type":"string","description":"XML: infAdProd","minLength":1,"maxLength":500},"valor_aproximado_tributos":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vTotTrib"},"icms":{"type":"object","properties":{"origem":{"type":"string","enum":["0","1","2","3","4","5","6","7","8"],"description":"XML: orig"},"cst":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CST"},"csosn":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CSOSN"},"modalidade_bc":{"type":"string","enum":["margem_valor_agregado","pauta","preco_tabelado","valor_operacao","0","1","2","3"],"description":"XML: modBC"},"reducao_bc":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pRedBC"},"beneficio_reducao_bc":{"type":"string","description":"XML: cBenefRBC"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBC"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pICMS"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMS"},"valor_operacao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSOp"},"fcp":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCFCP"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pFCP"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFCP"},"aliquota_diferida":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pFCPDif"},"valor_diferido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFCPDif"},"valor_efetivo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFCPEfet"}},"additionalProperties":false},"st":{"type":"object","properties":{"modalidade_bc":{"type":"string","enum":["preco_tabelado","lista_negativa","lista_positiva","lista_neutra","margem_valor_agregado","pauta","valor_operacao","0","1","2","3","4","5","6"],"description":"XML: modBCST"},"mva":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pMVAST"},"reducao_bc":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pRedBCST"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCST"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pICMSST"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSST"},"fcp":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCFCPST"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pFCPST"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFCPST"}},"additionalProperties":false},"uf":{"type":"string","description":"XML: UFST"},"bc_operacao_propria":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pBCOp"},"desoneracao":{"type":"object","properties":{"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSSTDeson"},"motivo":{"type":"string","enum":["taxi","outros","orgao_fomento","uso_agropecuario","olimpiadas","3","9","10","11","12"],"description":"XML: motDesICMSST"}},"additionalProperties":false}},"additionalProperties":false},"desoneracao":{"type":"object","properties":{"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSDeson"},"motivo":{"type":"string","enum":["taxi","outros","orgao_fomento","uso_agropecuario","olimpiadas","3","9","10","11","12"],"description":"XML: motDesICMS"},"deduz_do_total":{"type":"boolean","description":"XML: indDeduzDeson"}},"additionalProperties":false},"diferimento":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pDif"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSDif"}},"additionalProperties":false},"credito_sn":{"type":"object","properties":{"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pCredSN"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vCredICMSSN"}},"additionalProperties":false},"retido":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCSTRet"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pST"},"valor_substituto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSSubstituto"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSSTRet"},"fcp":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCFCPSTRet"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pFCPSTRet"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFCPSTRet"}},"additionalProperties":false},"base_destino":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCSTDest"},"valor_destino":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSSTDest"}},"additionalProperties":false},"efetivo":{"type":"object","properties":{"reducao_bc":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pRedBCEfet"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCEfet"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pICMSEfet"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSEfet"}},"additionalProperties":false},"monofasico":{"type":"object","properties":{"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qBCMono"},"aliquota_ad_rem":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: adRemICMS"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSMono"},"quantidade_retencao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qBCMonoReten"},"aliquota_ad_rem_retencao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: adRemICMSReten"},"valor_retencao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSMonoReten"},"quantidade_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qBCMonoRet"},"aliquota_ad_rem_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: adRemICMSRet"},"valor_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSMonoRet"}},"additionalProperties":false}},"additionalProperties":false},"ipi":{"type":"object","properties":{"cst":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CST"},"enquadramento":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cEnq"},"cnpj_produtor":{"type":"string","description":"XML: CNPJProd"},"selo":{"type":"object","properties":{"codigo":{"type":"string","description":"XML: cSelo","minLength":1,"maxLength":60},"quantidade":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: qSelo"}},"additionalProperties":false},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBC"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pIPI"},"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qUnid"},"valor_unidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vUnid"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIPI"}},"additionalProperties":false},"ii":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBC"},"despesas_aduaneiras":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDespAdu"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vII"},"iof":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIOF"}},"additionalProperties":false},"pis":{"type":"object","properties":{"cst":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CST"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBC"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pPIS"},"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qBCProd"},"aliquota_valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vAliqProd"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vPIS"}},"additionalProperties":false},"cofins":{"type":"object","properties":{"cst":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CST"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBC"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pCOFINS"},"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qBCProd"},"aliquota_valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vAliqProd"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vCOFINS"}},"additionalProperties":false},"difal":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCUFDest"},"base_calculo_fcp":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCFCPUFDest"},"aliquota_fcp":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pFCPUFDest"},"aliquota_interna":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pICMSUFDest"},"aliquota_interestadual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pICMSInter"},"percentual_partilha":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pICMSInterPart"},"valor_fcp":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFCPUFDest"},"valor_destino":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSUFDest"},"valor_remetente":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSUFRemet"}},"additionalProperties":false},"is":{"type":"object","properties":{"cst":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CSTIS"},"classificacao_tributaria":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cClassTribIS"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCIS"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pIS"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIS"}},"additionalProperties":false},"ibs_cbs":{"type":"object","properties":{"cst":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CST"},"classificacao_tributaria":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cClassTrib"},"doacao":{"type":"boolean","description":"XML: indDoacao"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBC"},"ibs_uf":{"type":"object","properties":{"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pIBSUF"},"diferimento":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pDif"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDif"}},"additionalProperties":false},"devolucao_tributo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDevTrib"},"reducao":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pRedAliq"},"aliquota_efetiva":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pAliqEfet"}},"additionalProperties":false},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIBSUF"}},"additionalProperties":false},"ibs_mun":{"type":"object","properties":{"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pIBSMun"},"diferimento":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pDif"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDif"}},"additionalProperties":false},"devolucao_tributo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDevTrib"},"reducao":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pRedAliq"},"aliquota_efetiva":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pAliqEfet"}},"additionalProperties":false},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIBSMun"}},"additionalProperties":false},"valor_ibs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIBS"},"cbs":{"type":"object","properties":{"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pCBS"},"diferimento":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pDif"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDif"}},"additionalProperties":false},"devolucao_tributo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDevTrib"},"reducao":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pRedAliq"},"aliquota_efetiva":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pAliqEfet"}},"additionalProperties":false},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vCBS"}},"additionalProperties":false},"regular":{"type":"object","properties":{"cst":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CSTReg"},"classificacao_tributaria":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cClassTribReg"},"aliquota_ibs_uf":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pAliqEfetRegIBSUF"},"valor_ibs_uf":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vTribRegIBSUF"},"aliquota_ibs_mun":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pAliqEfetRegIBSMun"},"valor_ibs_mun":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vTribRegIBSMun"},"aliquota_cbs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pAliqEfetRegCBS"},"valor_cbs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vTribRegCBS"}},"additionalProperties":false},"estorno_credito":{"type":"object","properties":{"valor_ibs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIBSEstCred"},"valor_cbs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vCBSEstCred"}},"additionalProperties":false}},"additionalProperties":false},"devolucao":{"type":"object","properties":{"percentual":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pDevol"},"valor_ipi_devolvido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vIPIDevol"}},"additionalProperties":false},"documento_referenciado":{"type":"object","properties":{"chave":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: chaveAcesso"},"item":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: nItem"}},"additionalProperties":false}},"additionalProperties":false},"description":"Itens da nota (1 a 990).","minItems":1,"maxItems":990},"frete":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"seguro":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"desconto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"outras_despesas":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"transporte":{"type":"object","properties":{"modalidade":{"type":"string","enum":["emitente","destinatario","terceiros","proprio_remetente","proprio_destinatario","sem_frete","0","1","2","3","4","9"],"description":"XML: modFrete"},"transportadora":{"type":"object","properties":{"cnpj":{"type":"string","description":"XML: CNPJ"},"cpf":{"type":"string","description":"XML: CPF"},"nome":{"type":"string","description":"XML: xNome","minLength":2,"maxLength":60},"inscricao_estadual":{"type":"string","description":"XML: IE"},"endereco":{"type":"string","description":"XML: xEnder","minLength":1,"maxLength":60},"municipio":{"type":"string","description":"XML: xMun","minLength":1,"maxLength":60},"uf":{"type":"string","description":"XML: UF"}},"additionalProperties":false},"retencao_icms":{"type":"object","properties":{"valor_servico":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vServ"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vBCRet"},"aliquota":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pICMSRet"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vICMSRet"},"cfop":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: CFOP"},"codigo_municipio":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: cMunFG"}},"additionalProperties":false},"veiculo":{"type":"object","properties":{"placa":{"type":"string","description":"XML: placa"},"uf":{"type":"string","description":"XML: UF"},"rntc":{"type":"string","description":"XML: RNTC","minLength":1,"maxLength":20}},"additionalProperties":false},"reboques":{"type":"array","items":{"type":"object","properties":{"placa":{"type":"string","description":"XML: placa"},"uf":{"type":"string","description":"XML: UF"},"rntc":{"type":"string","description":"XML: RNTC","minLength":1,"maxLength":20}},"additionalProperties":false}},"volumes":{"type":"array","items":{"type":"object","properties":{"quantidade":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: qVol"},"especie":{"type":"string","description":"XML: esp","minLength":1,"maxLength":60},"marca":{"type":"string","description":"XML: marca","minLength":1,"maxLength":60},"numeracao":{"type":"string","description":"XML: nVol","minLength":1,"maxLength":60},"peso_liquido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pesoL"},"peso_bruto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: pesoB"},"lacres":{"type":"array","items":{"type":"string","description":"XML: nLacre","minLength":1,"maxLength":60}}},"additionalProperties":false}}},"additionalProperties":false},"cobranca":{"type":"object","properties":{"fatura":{"type":"object","properties":{"numero":{"type":"string","description":"XML: nFat","minLength":1,"maxLength":60},"valor_original":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vOrig"},"desconto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDesc"},"valor_liquido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vLiq"}},"additionalProperties":false},"duplicatas":{"type":"array","items":{"type":"object","properties":{"numero":{"type":"string","description":"XML: nDup","minLength":1,"maxLength":60},"vencimento":{"type":"string","format":"date","description":"XML: dVenc"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDup"}},"additionalProperties":false}}},"additionalProperties":false},"pagamentos":{"type":"array","items":{"type":"object","properties":{"indicador":{"type":"string","enum":["a_vista","a_prazo","0","1"],"description":"XML: indPag"},"forma":{"type":"string","anyOf":[{"enum":["dinheiro","cheque","cartao_credito","cartao_debito","cartao_loja","vale_alimentacao","vale_refeicao","vale_presente","vale_combustivel","boleto","deposito","pix","transferencia","fidelidade","pix_estatico","credito_loja","pagamento_eletronico","sem_pagamento","outros"]},{"pattern":"^[0-9]{2}$"}],"description":"XML: tPag"},"descricao":{"type":"string","description":"XML: xPag","minLength":2,"maxLength":60},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vPag"},"data":{"type":"string","format":"date","description":"XML: dPag"},"cnpj_pagamento":{"type":"string","description":"XML: CNPJPag"},"uf_pagamento":{"type":"string","description":"XML: UFPag"},"cartao":{"type":"object","properties":{"integracao":{"type":"string","enum":["integrado","nao_integrado","1","2"],"description":"XML: tpIntegra"},"cnpj_credenciadora":{"type":"string","description":"XML: CNPJ"},"bandeira":{"type":"string","anyOf":[{"enum":["visa","mastercard","american_express","sorocred","diners","elo","hipercard","aura","cabal","alelo","banes","outros"]},{"pattern":"^[0-9]{2}$"}],"description":"XML: tBand"},"autorizacao":{"type":"string","description":"XML: cAut","minLength":1,"maxLength":128},"cnpj_recebedor":{"type":"string","description":"XML: CNPJReceb"},"terminal":{"type":"string","description":"XML: idTermPag","minLength":1,"maxLength":40}},"additionalProperties":false}},"additionalProperties":false}},"troco":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vTroco"},"intermediador":{"type":"object","properties":{"cnpj":{"type":"string","description":"XML: CNPJ"},"identificador":{"type":"string","description":"XML: idCadIntTran","minLength":2,"maxLength":60}},"additionalProperties":false},"informacoes_fisco":{"type":"string","description":"XML: infAdFisco","minLength":1,"maxLength":2000},"informacoes_complementares":{"type":"string","description":"XML: infCpl","minLength":1,"maxLength":5000},"observacoes":{"type":"array","items":{"type":"object","properties":{"campo":{"type":"string","description":"XML: xCampo"},"texto":{"type":"string","description":"XML: xTexto","minLength":1,"maxLength":60}},"additionalProperties":false}},"observacoes_fisco":{"type":"array","items":{"type":"object","properties":{"campo":{"type":"string","description":"XML: xCampo"},"texto":{"type":"string","description":"XML: xTexto","minLength":1,"maxLength":60}},"additionalProperties":false}},"processos":{"type":"array","items":{"type":"object","properties":{"numero":{"type":"string","description":"XML: nProc","minLength":1,"maxLength":60},"origem":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: indProc"},"tipo_ato":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: tpAto"}},"additionalProperties":false}},"cana":{"type":"object","properties":{"safra":{"type":"string","description":"XML: safra","minLength":4,"maxLength":9},"referencia":{"type":"string","description":"XML: ref"},"fornecimentos":{"type":"array","items":{"type":"object","properties":{"dia":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$","description":"XML: dia"},"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qtde"}},"additionalProperties":false}},"total_mes":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qTotMes"},"total_anterior":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qTotAnt"},"total_geral":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: qTotGer"},"deducoes":{"type":"array","items":{"type":"object","properties":{"descricao":{"type":"string","description":"XML: xDed","minLength":1,"maxLength":60},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vDed"}},"additionalProperties":false}},"valor_fornecimento":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vFor"},"total_deducoes":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vTotDed"},"valor_liquido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$","description":"XML: vLiqFor"}},"additionalProperties":false},"exportacao":{"type":"object","properties":{"uf_embarque":{"type":"string","description":"XML: UFSaidaPais"},"local_embarque":{"type":"string","description":"XML: xLocExporta","minLength":1,"maxLength":60},"local_despacho":{"type":"string","description":"XML: xLocDespacho","minLength":1,"maxLength":60}},"additionalProperties":false},"compra":{"type":"object","properties":{"nota_empenho":{"type":"string","description":"XML: xNEmp","minLength":1,"maxLength":22},"pedido":{"type":"string","description":"XML: xPed","minLength":1,"maxLength":60},"contrato":{"type":"string","description":"XML: xCont","minLength":1,"maxLength":60}},"additionalProperties":false},"calcular":{"type":"boolean","description":"true = o MadNotas calcula rateio, impostos e totais; false (padrão) = usa os valores enviados e só soma os totais."},"totais":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_icms":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_icms_desonerado":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_fcp_uf_destino":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_icms_uf_destino":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_icms_uf_remetente":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_fcp":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"base_calculo_st":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_st":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_fcp_st":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_fcp_st_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_produtos":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_frete":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_seguro":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_desconto":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_ii":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_ipi":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_ipi_devolvido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_pis":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_cofins":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_outras_despesas":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_total":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_aproximado_tributos":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"ibs_cbs":{"type":"object","properties":{"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"ibs_uf":{"type":"object","properties":{"diferimento":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"devolucao_tributo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"}},"additionalProperties":false},"ibs_mun":{"type":"object","properties":{"diferimento":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"devolucao_tributo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"}},"additionalProperties":false},"valor_ibs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"credito_presumido_ibs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"credito_presumido_ibs_suspensivo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"cbs":{"type":"object","properties":{"diferimento":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"devolucao_tributo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"credito_presumido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"credito_presumido_suspensivo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"}},"additionalProperties":false},"estorno_credito":{"type":"object","properties":{"valor_ibs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_cbs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"}},"additionalProperties":false}},"additionalProperties":false},"monofasico":{"type":"object","properties":{"quantidade":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"quantidade_retencao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_retencao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"quantidade_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"}},"additionalProperties":false},"issqn":{"type":"object","properties":{"valor_servicos":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"base_calculo":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_iss":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_pis":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_cofins":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"data_competencia":{"type":"string","format":"date"},"deducao":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"outras_retencoes":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"desconto_incondicionado":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"desconto_condicionado":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_retido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"regime_especial":{"type":["string","integer"],"pattern":"^[0-9.\\-/ ()]+$"}},"additionalProperties":false},"retencoes":{"type":"object","properties":{"pis":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"cofins":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"csll":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"base_irrf":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"irrf":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"base_previdencia":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"previdencia":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"}},"additionalProperties":false},"valor_total_ibs_cbs":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"},"valor_produtos_liquido":{"type":["number","string"],"pattern":"^-?[0-9]+([.,][0-9]+)?$"}},"additionalProperties":false,"description":"Totais esperados, conferidos com os calculados (opcional)."}},"additionalProperties":true,"required":["natureza_operacao","itens"]},"Cancelamento":{"type":"object","properties":{"justificativa":{"type":"string","minLength":15,"maxLength":255}},"required":["justificativa"]},"CartaCorrecao":{"type":"object","properties":{"texto":{"type":"string","minLength":15,"maxLength":1000}},"required":["texto"]},"InutilizacaoEntrada":{"type":"object","properties":{"emitente_id":{"type":"integer"},"modelo":{"type":"string","enum":["55","65"]},"serie":{"type":"integer"},"numero_inicial":{"type":"integer"},"numero_final":{"type":"integer"},"justificativa":{"type":"string","minLength":15,"maxLength":255}},"required":["modelo","serie","numero_inicial","numero_final","justificativa"]},"Nfse":{"type":"object","properties":{"id":{"type":"string","pattern":"^nfse_[0-9a-z]{26}$"},"objeto":{"type":"string","const":"nfse"},"ambiente":{"type":"string","enum":["simulacao","homologacao","producao"]},"modelo":{"type":"string","const":"nfse"},"ref":{"type":["string","null"]},"status":{"type":"string","enum":["processando","autorizada","rejeitada","cancelada","substituida","descartada"]},"etapa":{"type":"string"},"emitente":{"$ref":"#/components/schemas/EmitenteResumo"},"serie_dps":{"type":["integer","null"],"minimum":1,"maximum":89999},"numero_dps":{"type":["integer","null"],"minimum":1,"maximum":999999999},"id_dps":{"type":["string","null"],"pattern":"^DPS\\d{42}$","description":"Id da DPS (45 posições)."},"chave":{"type":["string","null"],"pattern":"^[0-9A-Z]{50}$","description":"Chave da NFS-e (TSChaveNFSe, 50). null até autorizar."},"numero_nfse":{"type":["string","null"],"description":"Número da NFS-e dado pela Sefin. null até autorizar."},"competencia":{"type":["string","null"],"format":"date"},"data_emissao":{"type":["string","null"],"format":"date-time"},"municipio_emissor":{"type":["string","null"],"pattern":"^\\d{7}$"},"municipio_prestacao":{"type":["string","null"],"pattern":"^\\d{7}$"},"codigo_tributacao_nacional":{"type":["string","null"]},"codigo_nbs":{"type":["string","null"]},"valor_servicos":{"type":["string","null"],"pattern":"^-?\\d+\\.\\d{2}$"},"valor_iss":{"type":["string","null"],"pattern":"^-?\\d+\\.\\d{2}$"},"iss_retido":{"type":"boolean"},"valor_retido":{"type":["string","null"],"pattern":"^-?\\d+\\.\\d{2}$"},"valor_liquido":{"type":["string","null"],"pattern":"^-?\\d+\\.\\d{2}$","description":"Grave no seu título este valor, não uma conta sua."},"valor_total":{"type":["string","null"],"pattern":"^-?\\d+\\.\\d{2}$"},"tomador":{"type":["object","null"],"properties":{"documento":{"type":["string","null"]},"nome":{"type":["string","null"]}}},"sefaz":{"type":"object","properties":{"cstat":{"type":["string","null"]},"motivo":{"type":["string","null"]},"protocolo":{"type":"null"},"recibo":{"type":"null"}},"description":"Retorno da Sefin Nacional (cstat = E-código). Protocolo e recibo não existem na NFS-e.","additionalProperties":true},"autorizada_em":{"type":["string","null"],"format":"date-time"},"cancelada_em":{"type":["string","null"],"format":"date-time"},"erros":{"type":"array","items":{"$ref":"#/components/schemas/ErroCampo"}},"avisos":{"type":"array","items":{"$ref":"#/components/schemas/Aviso"}},"tentativas":{"type":"integer"},"proxima_tentativa_em":{"type":["string","null"],"format":"date-time"},"origem":{"type":"string"},"substitui":{"type":["string","null"],"description":"Id da NFS-e que esta substitui."},"substituida_por":{"type":["string","null"],"description":"Id da substituta autorizada."},"criado_em":{"type":["string","null"],"format":"date-time"},"atualizado_em":{"type":["string","null"],"format":"date-time"},"links":{"type":"object","properties":{"self":{"type":"string","format":"uri"},"xml":{"type":"string","format":"uri"},"danfse":{"type":"string","format":"uri"},"eventos":{"type":"string","format":"uri"}},"additionalProperties":true},"payload":{"type":["object","null"],"description":"Só com ?incluir=payload."}},"required":["id","objeto","ambiente","modelo","status","etapa","emitente","links"],"description":"Objeto NFS-e (contrato §9): igual na API, no painel e nos webhooks nfse.*.","additionalProperties":false},"PayloadNfse":{"type":"object","properties":{"ref":{"type":"string","minLength":1,"maxLength":100,"pattern":"^[A-Za-z0-9_.:/-]+$","description":"Sua referência única (idempotência por empresa + ambiente + modelo). Só ASCII: acento = 422 ref_invalida."},"emitente_id":{"type":"integer"},"cnpj_emitente":{"type":"string"},"data_competencia":{"type":"string","format":"date","description":"Padrão: hoje no fuso da UF do emitente. Futura = 422 fora_do_limite."},"calcular":{"type":"boolean","default":true},"municipio_prestacao":{"type":["string","null"],"pattern":"^\\d{7}$","description":"IBGE. Padrão do emitente."},"servicos":{"type":"array","items":{"type":"object","properties":{"codigo":{"type":["string","null"],"maxLength":20,"description":"Seu código. Vai para cIntContrib só com 1 linha. Em simulação, servicos[0].codigo lê o cenário (SIM-…)."},"descricao":{"type":"string","minLength":1,"maxLength":2000},"quantidade":{"type":"string","pattern":"^\\d+(\\.\\d{1,4})?$","default":"1"},"valor_unitario":{"type":"string","pattern":"^\\d+(\\.\\d{1,2})?$","description":"≥ 0,00. Ou mande `valor` (total da linha)."},"valor":{"type":"string","pattern":"^\\d+(\\.\\d{1,2})?$"},"codigo_tributacao_nacional":{"type":["string","null"],"pattern":"^\\d{6}$","description":"cTribNac. Padrão do emitente. Todas as linhas iguais (422 servicos_incompativeis)."},"codigo_nbs":{"type":["string","null"],"pattern":"^\\d{9}$","description":"cNBS. Padrão do emitente."},"codigo_tributacao_municipal":{"type":["string","null"],"pattern":"^\\d{3}$","description":"cTribMun. Padrão do emitente."}},"required":["descricao"],"additionalProperties":true},"minItems":1,"maxItems":50},"informacoes_complementares":{"type":["string","null"]},"tomador":{"type":["object","null"],"properties":{"documento":{"type":"string","description":"CPF (11) ou CNPJ (14, alfanumérico aceito); DV conferido."},"nome":{"type":"string","maxLength":300},"inscricao_municipal":{"type":["string","null"]},"email":{"type":["string","null"],"format":"email"},"telefone":{"type":["string","null"]},"endereco":{"type":"object","properties":{"codigo_municipio":{"type":"string","pattern":"^\\d{7}$"},"cep":{"type":"string","pattern":"^\\d{8}$"},"logradouro":{"type":"string","maxLength":255},"numero":{"type":"string","maxLength":60},"complemento":{"type":["string","null"],"maxLength":156},"bairro":{"type":"string","maxLength":60}},"description":"Só vai à DPS completo (codigo_municipio, cep, logradouro, numero, bairro). Incompleto = 422 endereco_incompleto.","additionalProperties":true}},"required":["documento","nome"],"description":"Opcional, exceto com iss.retido."},"valores":{"type":"object","properties":{"desconto_incondicionado":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"desconto_condicionado":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"ajuste_base_iss":{"type":["object","null"],"properties":{"percentual":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"valor":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}}}},"additionalProperties":true},"iss":{"type":"object","properties":{"tributacao":{"type":"string","enum":["tributavel","imunidade","nao_incidencia","exportacao"],"description":"Padrão do emitente. `exportacao` = 422 nao_suportado na v1."},"aliquota":{"type":["string","null"],"pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Padrão do emitente. Ignorada (aviso aliquota_iss_simples_omitida) no ME/EPP que apura tudo no Simples sem retenção."},"retido":{"type":"boolean","default":false},"tipo_imunidade":{"type":["string","integer","null"],"description":"0–5, com `imunidade`."}},"additionalProperties":true},"retencoes":{"type":"object","properties":{"irrf":{"type":"object","properties":{"aliquota":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"valor":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"description":"`aliquota` (o MadNotas calcula) ou `valor` (usa o seu); com os dois, confere.","additionalProperties":true},"csll":{"type":"object","properties":{"aliquota":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"valor":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"description":"`aliquota` (o MadNotas calcula) ou `valor` (usa o seu); com os dois, confere.","additionalProperties":true},"inss":{"type":"object","properties":{"aliquota":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"valor":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"description":"`aliquota` (o MadNotas calcula) ou `valor` (usa o seu); com os dois, confere.","additionalProperties":true},"cp":{"type":"object","properties":{"aliquota":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"valor":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"description":"`aliquota` (o MadNotas calcula) ou `valor` (usa o seu); com os dois, confere.","additionalProperties":true},"pis":{"type":"object","properties":{"retido":{"type":"boolean"}},"additionalProperties":true},"cofins":{"type":"object","properties":{"retido":{"type":"boolean"}},"additionalProperties":true}},"additionalProperties":true},"tributos_federais":{"type":["object","null"],"properties":{"pis_cofins":{"type":"object","properties":{"cst":{"type":"string","pattern":"^\\d{2}$"},"aliquota_pis":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"aliquota_cofins":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"base":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"additionalProperties":true}}},"ibscbs":{"type":["object","null"],"description":"Opcional; sem ele valem os padrões do emitente.","properties":{"consumidor_final":{"type":"boolean"},"indicador_operacao":{"type":["string","null"],"pattern":"^\\d{6}$","description":"cIndOp. Vazio derruba a DPS (E1235) → 422 cindop_obrigatorio."},"tipo_operacao":{"type":["string","integer"]},"tipo_ente_governamental":{"type":["string","integer"]},"cst":{"type":"string","pattern":"^\\d{3}$"},"classificacao_tributaria":{"type":"string","pattern":"^\\d{6}$","description":"Começa pelo CST."},"credito_presumido":{"type":["object","null"],"description":"Crédito presumido do IBS/CBS (grupo do XSD)."},"tributacao_regular":{"type":"object","properties":{"cst":{"type":"string"},"classificacao_tributaria":{"type":"string"}},"additionalProperties":true},"diferimento":{"type":"object","properties":{"percentual_uf":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"percentual_municipio":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."},"percentual_cbs":{"type":"string","pattern":"^\\d{1,3}(\\.\\d{1,4})?$","description":"Percentual em texto, até 4 casas (\"2.0000\")."}},"additionalProperties":true}}},"obra":{"type":["object","null"],"description":"Obrigatório na construção civil (422 obra_obrigatoria): `{cno}` ou `{inscricao_imobiliaria?, endereco}`.","properties":{"cno":{"type":"string"},"inscricao_imobiliaria":{"type":["string","null"]},"endereco":{"type":"object","properties":{"cep":{"type":"string"},"logradouro":{"type":"string"},"numero":{"type":"string"},"complemento":{"type":["string","null"]},"bairro":{"type":"string"}},"additionalProperties":true}}},"substituicao":{"type":"object","properties":{"codigo_motivo":{"type":"string","enum":["01","02","03","04","05","99"]},"motivo":{"type":"string","minLength":15,"maxLength":255}},"description":"Só em POST /nfse/{id}/substituicao (a chave substituída é montada pelo MadNotas).","additionalProperties":true},"totais":{"type":"object","properties":{"valor_servicos":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_iss":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_liquido":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"description":"Opcional: conferido; diferença > R$ 0,01 = 422 total_divergente com o valor calculado na dica.","additionalProperties":true}},"required":["servicos"],"description":"Payload da NFS-e (contrato §6). Campo desconhecido = aviso campo_desconhecido.","additionalProperties":true},"ValidacaoNfse":{"type":"object","properties":{"valido":{"type":"boolean"},"erros":{"type":"array","items":{"$ref":"#/components/schemas/ErroCampo"}},"avisos":{"type":"array","items":{"$ref":"#/components/schemas/Aviso"}},"id_dps_previsto":{"type":["string","null"]},"serie_dps":{"type":["integer","null"]},"numero_dps_previsto":{"type":["integer","null"],"description":"Não é reservado."},"xml":{"type":["string","null"],"description":"DPS assinada (em simulação, com certificado de teste)."},"totais":{"type":"object","properties":{"valor_servicos":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"desconto_incondicionado":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"desconto_condicionado":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"base_iss":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"aliquota_iss":{"type":["string","null"],"pattern":"^\\d{1,3}(\\.\\d{1,4})?$"},"valor_iss":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_iss_retido":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_pis":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_cofins":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_irrf":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_csll":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_inss":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_retido":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_liquido":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"additionalProperties":true}},"required":["valido","erros","avisos"],"description":"POST /nfse/validar: sempre 200; mesmos passos da emissão sem reservar nem transmitir.","additionalProperties":true},"TotaisNfse":{"type":"object","properties":{"valor_servicos":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"desconto_incondicionado":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"desconto_condicionado":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"base_iss":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"aliquota_iss":{"type":["string","null"],"pattern":"^\\d{1,3}(\\.\\d{1,4})?$"},"valor_iss":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_iss_retido":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_pis":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_cofins":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_irrf":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_csll":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_inss":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_retido":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."},"valor_liquido":{"type":"string","pattern":"^-?\\d+\\.\\d{2}$","description":"Dinheiro em texto, 2 casas (\"1500.00\")."}},"additionalProperties":true},"NfseEmitente":{"type":"object","properties":{"habilitada":{"type":"boolean"},"opcao_simples":{"type":"string","enum":["nao_optante","mei","me_epp"]},"regime_apuracao_simples":{"type":["string","null"],"enum":["tudo_no_simples","iss_fora_do_simples","tudo_fora_do_simples",null],"description":"Obrigatório com me_epp (422 regime_apuracao_obrigatorio)."},"regime_especial":{"type":"string","enum":["nenhum","cooperativa","estimativa","microempresa_municipal","notario_registrador","profissional_autonomo","sociedade_profissionais","outros"],"default":"nenhum"},"municipio_prestacao_padrao":{"type":["string","null"],"pattern":"^\\d{7}$"},"tributacao_iss_padrao":{"type":"string","enum":["tributavel","imunidade","nao_incidencia"],"default":"tributavel"},"aliquota_iss_padrao":{"type":["string","null"],"pattern":"^\\d{1,3}(\\.\\d{1,4})?$"},"codigo_tributacao_nacional_padrao":{"type":["string","null"],"pattern":"^\\d{6}$"},"codigo_nbs_padrao":{"type":["string","null"],"pattern":"^\\d{9}$"},"codigo_tributacao_municipal_padrao":{"type":["string","null"],"pattern":"^\\d{3}$"},"percentual_tributos_simples":{"type":["string","null"],"pattern":"^\\d{1,3}(\\.\\d{1,4})?$"},"ibscbs":{"type":"object","properties":{"habilitado":{"type":"boolean"},"cst":{"type":"string","pattern":"^\\d{3}$"},"classificacao_tributaria":{"type":"string","pattern":"^\\d{6}$"},"indicador_operacao":{"type":["string","null"],"pattern":"^\\d{6}$"}},"additionalProperties":true},"numeracao":{"type":["object","null"],"properties":{"serie_dps":{"type":["integer","null"]},"proximo_numero_dps":{"type":["integer","null"]}}},"convenio":{"type":"object","properties":{"situacao":{"type":"string","enum":["conveniado","nao_conveniado","nao_conferido"]},"conferido_em":{"type":["string","null"],"format":"date-time"}},"description":"No ambiente da chave; em simulação sempre nao_conferido.","additionalProperties":true},"cadastro_municipal":{"type":["object","null"],"description":"Resposta do CNC no ambiente da chave; null em simulação.","properties":{"encontrado":{"type":"boolean"},"inscricao_municipal_na_dps":{"type":"boolean"},"situacao_emissao":{"type":["string","null"]},"conferido_em":{"type":["string","null"],"format":"date-time"}}}},"description":"Bloco `nfse` do emitente (§4.3), em GET /emitentes/{id} e na resposta do PUT.","additionalProperties":true},"NfseEmitenteEntrada":{"type":"object","properties":{"habilitada":{"type":"boolean"},"opcao_simples":{"type":"string","enum":["nao_optante","mei","me_epp"]},"regime_apuracao_simples":{"type":["string","null"],"enum":["tudo_no_simples","iss_fora_do_simples","tudo_fora_do_simples",null],"description":"Obrigatório com me_epp (422 regime_apuracao_obrigatorio)."},"regime_especial":{"type":"string","enum":["nenhum","cooperativa","estimativa","microempresa_municipal","notario_registrador","profissional_autonomo","sociedade_profissionais","outros"],"default":"nenhum"},"municipio_prestacao_padrao":{"type":["string","null"],"pattern":"^\\d{7}$"},"tributacao_iss_padrao":{"type":"string","enum":["tributavel","imunidade","nao_incidencia"],"default":"tributavel"},"aliquota_iss_padrao":{"type":["string","null"],"pattern":"^\\d{1,3}(\\.\\d{1,4})?$"},"codigo_tributacao_nacional_padrao":{"type":["string","null"],"pattern":"^\\d{6}$"},"codigo_nbs_padrao":{"type":["string","null"],"pattern":"^\\d{9}$"},"codigo_tributacao_municipal_padrao":{"type":["string","null"],"pattern":"^\\d{3}$"},"percentual_tributos_simples":{"type":["string","null"],"pattern":"^\\d{1,3}(\\.\\d{1,4})?$"},"ibscbs":{"type":"object","properties":{"habilitado":{"type":"boolean"},"cst":{"type":"string","pattern":"^\\d{3}$"},"classificacao_tributaria":{"type":"string","pattern":"^\\d{6}$"},"indicador_operacao":{"type":["string","null"],"pattern":"^\\d{6}$"}},"additionalProperties":true}},"required":["habilitada","opcao_simples"],"description":"PUT /emitentes/{id}/nfse (§4.1). Série e próximo nDPS vão em PUT /emitentes/{id}/numeracao com modelo \"nfse\".","additionalProperties":true},"EventoNfse":{"type":"object","properties":{"id":{"type":"string","pattern":"^evt_"},"objeto":{"type":"string","const":"evento"},"tipo":{"type":"string","enum":["cancelamento","cancelamento_substituicao","cancelamento_externo"]},"codigo_evento":{"type":"string","description":"101101 cancelamento; o da substituição sai do evento da Sefin."},"sequencia":{"type":"integer"},"texto":{"type":["string","null"]},"codigo_motivo":{"type":["string","null"]},"status":{"type":"string","enum":["processando","registrado","rejeitado"]},"sefaz":{"type":"object","properties":{"cstat":{"type":["string","null"]},"motivo":{"type":["string","null"]},"protocolo":{"type":"null"}},"additionalProperties":true},"autor":{"type":["string","null"]},"registrado_em":{"type":["string","null"],"format":"date-time"},"criado_em":{"type":["string","null"],"format":"date-time"},"documento":{"$ref":"#/components/schemas/Nfse"}},"required":["id","objeto","tipo","status"],"description":"Evento da NFS-e (§11).","additionalProperties":true},"MunicipioNfse":{"type":"object","properties":{"codigo":{"type":"string","pattern":"^\\d{7}$"},"nome":{"type":"string"},"uf":{"type":"string","pattern":"^[A-Z]{2}$"},"convenio":{"type":"string","enum":["conveniado","nao_conveniado","nao_conferido"]},"conferido_em":{"type":["string","null"],"format":"date-time"}},"required":["codigo","nome","uf","convenio"],"additionalProperties":true},"ListaNfse":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Nfse"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}},"required":["dados"],"additionalProperties":true},"CancelamentoNfse":{"type":"object","properties":{"codigo_motivo":{"type":"string","enum":["1","2","9"],"description":"1 erro na emissão · 2 serviço não prestado · 9 outros."},"justificativa":{"type":"string","minLength":15,"maxLength":255}},"required":["codigo_motivo","justificativa"],"additionalProperties":false},"Dfe":{"type":"object","properties":{"id":{"type":"string","pattern":"^dfe_[0-9a-z]{16}$"},"objeto":{"type":"string","const":"dfe"},"ambiente":{"type":"string","enum":["simulacao","homologacao","producao"]},"emitente":{"type":["object","null"],"properties":{"id":{"type":"integer"},"cnpj":{"type":"string"},"razao_social":{"type":"string"}}},"nsu":{"type":"integer","description":"Maior NSU que já tocou este documento (resumo, XML completo, eventos). A lista vem em ordem crescente dele."},"chave":{"type":"string","pattern":"^[0-9]{6}[0-9A-Z]{12}[0-9]{26}$","description":"Chave de acesso (44). Posições 7–18 = raiz e ordem do CNPJ do emitente (pode ter letra MAIÚSCULA, CNPJ alfanumérico); o DV do CNPJ e o resto só dígitos. Minúscula = 422."},"modelo":{"type":"string","enum":["55"],"description":"Só NF-e 55. \"nfse\" está reservado (§22)."},"fornecedor":{"type":"object","properties":{"documento":{"type":["string","null"]},"nome":{"type":["string","null"]},"inscricao_estadual":{"type":["string","null"]}},"additionalProperties":true},"data_emissao":{"type":["string","null"],"format":"date-time"},"tipo_operacao":{"type":["string","null"],"enum":["entrada","saida",null]},"valor_total":{"type":["string","null"],"pattern":"^-?\\d+\\.\\d{2}$"},"situacao_nfe":{"type":"string","enum":["autorizada","cancelada","denegada"],"description":"Muda quando chega evento do emissor."},"xml_completo":{"type":"boolean","description":"true quando o procNFe chegou (normalmente na consulta seguinte à ciência): é a hora de importar."},"manifestacao":{"type":"object","properties":{"tipo":{"type":["string","null"],"enum":["ciencia","confirmacao","desconhecimento","nao_realizada",null]},"status":{"type":["string","null"],"enum":["processando","registrado","rejeitado",null]},"registrada_em":{"type":["string","null"],"format":"date-time"}},"additionalProperties":true},"recebido_em":{"type":["string","null"],"format":"date-time"},"atualizado_em":{"type":["string","null"],"format":"date-time"},"links":{"type":"object","properties":{"self":{"type":"string","format":"uri"},"xml":{"type":"string","format":"uri"},"eventos":{"type":"string","format":"uri"}},"additionalProperties":true}},"required":["id","objeto","ambiente","nsu","chave","modelo","situacao_nfe","xml_completo","manifestacao"],"description":"NF-e recebida (§18). Um `dfe_` por chave: os vários NSUs da mesma chave atualizam o mesmo objeto.","additionalProperties":true},"EventoDfe":{"type":"object","properties":{"id":{"type":"string","pattern":"^evt_"},"objeto":{"type":"string","const":"evento"},"origem":{"type":"string","enum":["manifestacao","emissor"]},"tipo":{"type":"string","description":"ciencia · confirmacao · desconhecimento · nao_realizada (manifestação) · cancelamento · carta_correcao · cancelamento_substituicao (emissor) ou o código do evento."},"codigo_evento":{"type":["string","null"],"description":"210210 · 210200 · 210220 · 210240 · 110111 · 110110 · 110112"},"descricao":{"type":["string","null"]},"justificativa":{"type":["string","null"]},"nsu":{"type":["integer","null"]},"status":{"type":"string","enum":["processando","registrado","rejeitado"]},"sefaz":{"type":"object","properties":{"cstat":{"type":["string","null"]},"motivo":{"type":["string","null"]},"protocolo":{"type":["string","null"]}},"additionalProperties":true},"registrado_em":{"type":["string","null"],"format":"date-time"},"criado_em":{"type":["string","null"],"format":"date-time"}},"required":["id","objeto","origem","tipo","status"],"description":"Manifestação enviada ou evento do emissor que chegou pela distribuição.","additionalProperties":true},"SituacaoDfe":{"type":"object","properties":{"emitente_id":{"type":"integer"},"ambiente":{"type":"string"},"ultimo_nsu":{"type":"integer"},"max_nsu":{"type":"integer"},"ultima_consulta_em":{"type":["string","null"],"format":"date-time"},"proxima_consulta_em":{"type":["string","null"],"format":"date-time"},"estado":{"type":"string","enum":["em_dia","baixando","aguardando","bloqueado","sem_certificado"]},"motivo":{"type":["string","null"]}},"required":["emitente_id","ambiente","ultimo_nsu","max_nsu","estado"],"description":"Cursor da distribuição (§21). A cadência é do MadNotas: 137 ou em dia = próxima consulta em 1 h; 656 = bloqueado 1 h.","additionalProperties":true},"ListaDfe":{"type":"object","properties":{"dados":{"type":"array","items":{"$ref":"#/components/schemas/Dfe"}},"tem_mais":{"type":"boolean"},"proximo_cursor":{"type":["string","null"]}},"required":["dados"],"additionalProperties":true},"ManifestacaoDfe":{"type":"object","properties":{"tipo":{"type":"string","enum":["ciencia","confirmacao","desconhecimento","nao_realizada"],"description":"ciencia 210210 · confirmacao 210200 · desconhecimento 210220 · nao_realizada 210240."},"justificativa":{"type":"string","minLength":15,"maxLength":255,"description":"Obrigatória (15–255) só em nao_realizada. Simulação: SIM-REJ-<cStat> rejeita com esse cStat."}},"required":["tipo"],"additionalProperties":false},"ManifestacaoDfeResposta":{"allOf":[{"$ref":"#/components/schemas/EventoDfe"},{"type":"object","properties":{"dfe":{"$ref":"#/components/schemas/Dfe"}},"required":["dfe"],"additionalProperties":true}]},"SincronizarDfe":{"type":"object","properties":{"emitente_id":{"type":"integer","minimum":1}},"description":"Sem emitente_id: o da chave, ou o único emitente ativo.","additionalProperties":true},"SimulacaoDfe":{"type":"object","properties":{"emitente_id":{"type":"integer","minimum":1},"quantidade":{"type":"integer","minimum":1,"maximum":50,"default":1},"cenario":{"type":"string","enum":["normal","cancelada","so_resumo","cancelamento_posterior"],"default":"normal","description":"normal: resumo agora, XML completo depois da ciência · cancelada: resumo + cancelamento do emissor · so_resumo: o XML completo nunca chega · cancelamento_posterior: o fornecedor cancela uma nota que o emitente JÁ recebeu (informe `chave`; `quantidade` é ignorada)."},"chave":{"type":"string","pattern":"^[0-9]{6}[0-9A-Z]{12}[0-9]{26}$","description":"Só no cenário cancelamento_posterior: chave de uma nota já entregue a este emitente. O cancelamento (evento 110111) chega na consulta feita na hora e atualiza o MESMO dfe (situacao_nfe cancelada, webhook dfe.recebido motivo evento_emissor). Posições 7–18 = raiz e ordem do CNPJ do emitente (pode ter letra MAIÚSCULA, CNPJ alfanumérico); o DV do CNPJ e o resto só dígitos. Minúscula = 422."}},"additionalProperties":false},"SimulacaoDfeResposta":{"type":"object","properties":{"objeto":{"type":"string","const":"simulacao_dfe"},"emitente_id":{"type":"integer"},"quantidade":{"type":"integer"},"cenario":{"type":"string"},"chaves":{"type":"array","items":{"type":"string"}},"consulta":{"type":"object","properties":{"consultou":{"type":"boolean"},"cstat":{"type":["string","null"]},"novos":{"type":"integer"},"atualizados":{"type":"integer"}},"additionalProperties":true},"situacao":{"$ref":"#/components/schemas/SituacaoDfe"},"dados":{"type":"array","items":{"$ref":"#/components/schemas/Dfe"}}},"required":["chaves","situacao","dados"],"additionalProperties":true},"DfeEmitente":{"type":"object","properties":{"habilitado":{"type":"boolean"},"situacao":{"oneOf":[{"$ref":"#/components/schemas/SituacaoDfe"},{"type":"null"}]}},"required":["habilitado"],"description":"Bloco `dfe` do emitente (GET /emitentes/{id}). `situacao` = null antes da primeira habilitação neste ambiente.","additionalProperties":true},"DfeEmitenteEntrada":{"type":"object","properties":{"habilitado":{"type":"boolean"}},"required":["habilitado"],"additionalProperties":false}},"responses":{"400":{"description":"Requisição malformada (JSON inválido, cabeçalho inválido).","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"requisicao","codigo":"json_invalido","mensagem":"O corpo não é um JSON válido: Syntax error. Envie Content-Type: application/json.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"401":{"description":"Chave ausente, inválida ou revogada.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"autenticacao","codigo":"chave_invalida","mensagem":"Chave de API inválida ou revogada.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"402":{"description":"Licença, plano ou franquia não permite a operação.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"conta","codigo":"franquia_esgotada","mensagem":"A franquia do plano acabou neste mês.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"403":{"description":"A chave não tem a permissão, ou chave de produção usada na documentação.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"permissao","codigo":"permissao_negada","mensagem":"Esta chave de API não tem a permissão nfe.write.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"404":{"description":"Não encontrado (inclui recurso de outra empresa).","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"nao_encontrado","codigo":"nao_encontrado","mensagem":"Documento não encontrado.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"409":{"description":"Conflito: mesma ref com payload diferente, ou operação em andamento.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"conflito","codigo":"ref_em_uso","mensagem":"Esta ref já foi usada com outro payload. Use outra ref ou repita o payload original.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"422":{"description":"Payload com erro. Vem TODOS os erros, cada um com o caminho JSON. Nada foi criado.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"validacao","codigo":"payload_invalido","mensagem":"O payload tem erros. Nada foi criado.","detalhes":[{"campo":"itens[0].ncm","codigo":"ncm_inexistente","mensagem":"NCM 99999999 não existe na tabela vigente.","dica":"Confira em GET /utilitarios/ncm?q=…"},{"campo":"destinatario.endereco.codigo_municipio","codigo":"municipio_invalido","mensagem":"Código IBGE do município (7 dígitos) não encontrado."}]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"429":{"description":"Limite de requisições.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"RateLimit-Limit":{"$ref":"#/components/headers/RateLimit-Limit"},"RateLimit-Remaining":{"$ref":"#/components/headers/RateLimit-Remaining"},"RateLimit-Reset":{"$ref":"#/components/headers/RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"limite","codigo":"limite_excedido","mensagem":"Muitas requisições. Tente de novo em 12 segundos.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}},"503":{"description":"Componente temporariamente indisponível.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Erro"},"example":{"erro":{"tipo":"indisponivel","codigo":"componente_indisponivel","mensagem":"O componente … ainda não está disponível neste ambiente. Tente de novo em alguns minutos.","detalhes":[]},"request_id":"req_01jbx3m0a1b2c3d4e5f6g7h8j9"}}}}},"parameters":{"Id":{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Id público do documento (nfe_…/nfce_…)."},"IdNumero":{"name":"id","in":"path","required":true,"schema":{"type":"integer"}},"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string","maxLength":255},"description":"Repetir a requisição com a mesma chave (24 h) devolve a mesma resposta, com Idempotent-Replayed: true."},"Aguardar":{"name":"aguardar","in":"query","required":false,"schema":{"type":"integer","minimum":0,"maximum":25},"description":"Segura a resposta até N segundos esperando o resultado da SEFAZ. NFC-e: padrão 20."},"Simular":{"name":"MadNotas-Simular","in":"header","required":false,"schema":{"type":"string"},"description":"Só com chave de simulação: força um cenário: SIM-NORMAL, SIM-REJ-<cStat>, SIM-DENEGADA, SIM-LENTO, SIM-TIMEOUT, SIM-DUPLICIDADE, SIM-OFFLINE (contingência off-line → autorizada depois do atraso), SIM-OFFLINE-REJ (contingência → rejeitada), SIM-CONFLITO. Também vale como código (cProd) do 1º item."},"SimularAtraso":{"name":"MadNotas-Simular-Atraso","in":"header","required":false,"schema":{"type":"integer","minimum":0,"maximum":600,"default":60},"description":"Só com chave de simulação: segundos (0 a 600, padrão 60) que a nota em contingência (SIM-OFFLINE / SIM-OFFLINE-REJ) espera antes da transmissão simulada. O POST responde `contingencia`; o resultado chega pelo polling e pelos webhooks nfce.contingencia → nfce.autorizada (ou rejeitada)."},"Cursor":{"name":"cursor","in":"query","required":false,"schema":{"type":"string"}},"Limite":{"name":"limite","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},"IdNfse":{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^nfse_"},"description":"Id público da NFS-e (nfse_…). Id de NF-e = 404."},"AguardarNfse":{"name":"aguardar","in":"query","required":false,"schema":{"type":"integer","minimum":0,"maximum":25,"default":20},"description":"Segura a resposta até N s esperando a Sefin. Padrão 20; 0 = sempre 202. Fora de 0..25 = 422 aguardar_invalido."},"SimularNfse":{"name":"MadNotas-Simular","in":"header","required":false,"schema":{"type":"string"},"description":"Só com chave de simulação (vence servicos[0].codigo): SIM-NORMAL, SIM-REJ-<E-código>, SIM-LENTO, SIM-TIMEOUT, SIM-DUPLICIDADE, SIM-CONFLITO, SIM-NAO-CONVENIADO. SIM-DENEGADA não existe na NFS-e (autoriza com aviso simulacao_cenario_invalido). No cancelamento, SIM-REJ-<E-código> na justificativa."},"IdDfe":{"name":"id","in":"path","required":true,"schema":{"type":"string","pattern":"^dfe_"},"description":"Id público do documento recebido (dfe_…). Id de NF-e/NFS-e ou adulterado = 404."}},"headers":{"X-Request-Id":{"description":"Id da requisição (também no corpo de erro).","schema":{"type":"string"}},"RateLimit-Limit":{"description":"Limite da janela.","schema":{"type":"integer"}},"RateLimit-Remaining":{"description":"Restantes na janela.","schema":{"type":"integer"}},"RateLimit-Reset":{"description":"Segundos até zerar.","schema":{"type":"integer"}},"Retry-After":{"description":"Segundos para tentar de novo.","schema":{"type":"integer"}},"Location":{"description":"URL do documento.","schema":{"type":"string"}},"Idempotent-Replayed":{"description":"`true` quando a resposta é a gravada para a mesma ref/Idempotency-Key.","schema":{"type":"string"}}},"examples":{"Documento":{"value":{"id":"nfe_01jbx3k9q8m2s7t4v6w8y0z1a2","objeto":"nfe","ambiente":"simulacao","modelo":"55","ref":"pedido-1001","status":"autorizada","etapa":"concluido","emitente":{"id":9,"cnpj":"99999999000191","razao_social":"Empresa de Demonstração Ltda"},"serie":1,"numero":1532,"chave":"35261099999999000191550010000015321123456780","tipo_emissao":1,"contingencia":false,"data_emissao":"2026-10-29T16:05:12-03:00","valor_total":"100.00","destinatario":{"documento":"12ABC34501DE35","nome":"COMERCIO FICTICIO LTDA"},"sefaz":{"cstat":"100","motivo":"Autorizado o uso da NF-e","protocolo":"135260000012345","recibo":null},"autorizada_em":"2026-10-29T16:05:14-03:00","cancelada_em":null,"erros":[],"avisos":[],"tentativas":1,"proxima_tentativa_em":null,"origem":"api","substitui":null,"substituida_por":null,"criado_em":"2026-10-29T16:05:12-03:00","atualizado_em":"2026-10-29T16:05:14-03:00","links":{"self":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2","xml":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/xml","danfe":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/danfe","eventos":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/eventos"}}},"DocumentoProcessando":{"value":{"id":"nfe_01jbx3k9q8m2s7t4v6w8y0z1a2","objeto":"nfe","ambiente":"simulacao","modelo":"55","ref":"pedido-1001","status":"processando","etapa":"na_fila","emitente":{"id":9,"cnpj":"99999999000191","razao_social":"Empresa de Demonstração Ltda"},"serie":1,"numero":1532,"chave":"35261099999999000191550010000015321123456780","tipo_emissao":1,"contingencia":false,"data_emissao":"2026-10-29T16:05:12-03:00","valor_total":"100.00","destinatario":{"documento":"12ABC34501DE35","nome":"COMERCIO FICTICIO LTDA"},"sefaz":{"cstat":null,"motivo":null,"protocolo":null,"recibo":null},"autorizada_em":null,"cancelada_em":null,"erros":[],"avisos":[],"tentativas":1,"proxima_tentativa_em":"2026-10-29T16:05:14-03:00","origem":"api","substitui":null,"substituida_por":null,"criado_em":"2026-10-29T16:05:12-03:00","atualizado_em":"2026-10-29T16:05:14-03:00","links":{"self":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2","xml":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/xml","danfe":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/danfe","eventos":"https://api.madnotas.com.br/api/v1/nfe/nfe_01jbx3k9q8m2s7t4v6w8y0z1a2/eventos"}}},"PayloadNfe":{"value":{"ref":"pedido-1001","natureza_operacao":"VENDA DE MERCADORIA","destinatario":{"cnpj":"12ABC34501DE35","nome":"COMERCIO FICTICIO LTDA","inscricao_estadual":"110042490114","email":"compras@cliente.test","endereco":{"logradouro":"RUA DO CLIENTE","numero":"55","bairro":"CENTRO","codigo_municipio":"3550308","municipio":"SAO PAULO","uf":"SP","cep":"01001000"}},"itens":[{"codigo":"P001","descricao":"PRODUTO FICTICIO","ncm":"21069090","cfop":"5102","unidade":"UN","quantidade":"3","valor_unitario":"33.3333","valor_bruto":"100.00","icms":{"origem":"0","csosn":"102"},"pis":{"cst":"07"},"cofins":{"cst":"07"}}],"pagamentos":[{"forma":"pix","valor":"100.00"}]}},"PayloadNfce":{"value":{"ref":"caixa-3-cupom-88","itens":[{"codigo":"CAFE01","descricao":"CAFE ESPRESSO","ncm":"21011110","cfop":"5102","unidade":"UN","quantidade":"2","valor_unitario":"6.50","valor_bruto":"13.00","icms":{"origem":"0","csosn":"102"},"pis":{"cst":"07"},"cofins":{"cst":"07"}}],"pagamentos":[{"forma":"dinheiro","valor":"20.00"}],"troco":"7.00"}},"PayloadNfse":{"summary":"Lucro Presumido com ISS e federais retidos (§6)","value":{"ref":"nfse-venda-1234-1","emitente_id":12,"data_competencia":"2026-10-30","calcular":true,"municipio_prestacao":"3550308","servicos":[{"codigo":"SUP-MENSAL","descricao":"Suporte técnico em informática — outubro/2026","quantidade":"1","valor_unitario":"1500.00","codigo_tributacao_nacional":"010701","codigo_nbs":"115013000","codigo_tributacao_municipal":null},{"descricao":"Visita técnica extra (2 h)","quantidade":"2","valor_unitario":"150.00","codigo_tributacao_nacional":"010701","codigo_nbs":"115013000"}],"informacoes_complementares":null,"tomador":{"documento":"72619438000163","nome":"Comercial Horizonte Ltda","inscricao_municipal":null,"email":"fiscal@horizonte.example","telefone":"1133334444","endereco":{"codigo_municipio":"3550308","cep":"01001000","logradouro":"Praça da Sé","numero":"100","complemento":"sala 5","bairro":"Sé"}},"valores":{"desconto_incondicionado":"0.00","desconto_condicionado":"0.00","ajuste_base_iss":null},"iss":{"tributacao":"tributavel","aliquota":"2.0000","retido":true,"tipo_imunidade":null},"retencoes":{"irrf":{"aliquota":"1.5000"},"csll":{"aliquota":"1.0000"},"inss":{"aliquota":"11.0000"},"pis":{"retido":true},"cofins":{"retido":true}},"tributos_federais":{"pis_cofins":{"cst":"01","aliquota_pis":"0.6500","aliquota_cofins":"3.0000"}},"ibscbs":null,"obra":null,"totais":{"valor_servicos":"1800.00","valor_liquido":"1455.30"}}},"PayloadNfseMinimo":{"summary":"Simples ME/EPP, ISS no DAS, sem retenção","value":{"ref":"nfse-os-778-1","servicos":[{"descricao":"Manutenção preventiva de impressora","valor_unitario":"350.00"}],"tomador":{"documento":"38461592719","nome":"Maria Fictícia da Silva"}}},"Nfse":{"summary":"Autorizada","value":{"id":"nfse_01m69evn1vyj7zt0feqh41hpks","objeto":"nfse","ambiente":"simulacao","modelo":"nfse","ref":"QAN3-140635-full","status":"substituida","etapa":"concluido","emitente":{"id":122,"cnpj":"40643205000100","razao_social":"QA N3 Serviços Rio de Janeiro Ltda"},"serie_dps":1,"numero_dps":11,"id_dps":"DPS330455724064320500010000001000000000000011","chave":"33045572240643205000100900100000001126102826225382","numero_nfse":"9001000000011","competencia":"2026-10-30","data_emissao":"2026-10-31T14:07:02-03:00","municipio_emissor":"3304557","municipio_prestacao":"3550308","codigo_tributacao_nacional":"010701","codigo_nbs":"115013000","valor_servicos":"1800.00","valor_iss":"36.00","iss_retido":true,"valor_retido":"344.70","valor_liquido":"1455.30","valor_total":"1800.00","tomador":{"documento":"72619438000163","nome":"Comercial Horizonte Ltda"},"sefaz":{"cstat":null,"motivo":null,"protocolo":null,"recibo":null},"autorizada_em":"2026-10-31T14:07:02-03:00","cancelada_em":"2026-10-31T14:10:05-03:00","erros":[],"avisos":[{"campo":null,"codigo":"simulacao_assinatura_teste","mensagem":"Em simulação a DPS é assinada com um certificado de teste."}],"tentativas":1,"proxima_tentativa_em":null,"origem":"api","substitui":null,"substituida_por":"nfse_01m69f11n9drg9h93bmgaa72my","criado_em":"2026-10-31T14:07:02-03:00","atualizado_em":"2026-10-31T14:10:05-03:00","links":{"self":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69evn1vyj7zt0feqh41hpks","xml":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69evn1vyj7zt0feqh41hpks/xml","danfse":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69evn1vyj7zt0feqh41hpks/danfse","eventos":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69evn1vyj7zt0feqh41hpks/eventos"}}},"NfseProcessando":{"summary":"Aceita, processando (aguardar=0)","value":{"id":"nfse_01m69f6yrxk7pjmwf5a44yf9ab","objeto":"nfse","ambiente":"simulacao","modelo":"nfse","ref":"QAN3-140635-exproc","status":"processando","etapa":"na_fila","emitente":{"id":121,"cnpj":"47591675000116","razao_social":"QA N3 Serviços São Paulo Ltda"},"serie_dps":1,"numero_dps":47,"id_dps":"DPS355030824759167500011600001000000000000047","chave":null,"numero_nfse":null,"competencia":"2026-10-31","data_emissao":"2026-10-31T14:13:12-03:00","municipio_emissor":"3550308","municipio_prestacao":"3550308","codigo_tributacao_nacional":"010701","codigo_nbs":"115013000","valor_servicos":"350.00","valor_iss":"0.00","iss_retido":false,"valor_retido":"0.00","valor_liquido":"350.00","valor_total":"350.00","tomador":null,"sefaz":{"cstat":null,"motivo":null,"protocolo":null,"recibo":null},"autorizada_em":null,"cancelada_em":null,"erros":[],"avisos":[{"campo":null,"codigo":"simulacao_assinatura_teste","mensagem":"Em simulação a DPS é assinada com um certificado de teste."}],"tentativas":0,"proxima_tentativa_em":"2026-10-31T14:13:12-03:00","origem":"api","substitui":null,"substituida_por":null,"criado_em":"2026-10-31T14:13:12-03:00","atualizado_em":"2026-10-31T14:13:12-03:00","links":{"self":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f6yrxk7pjmwf5a44yf9ab","xml":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f6yrxk7pjmwf5a44yf9ab/xml","eventos":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f6yrxk7pjmwf5a44yf9ab/eventos"}}},"NfseRejeitada":{"summary":"Rejeitada pela Sefin (corrija com PUT no mesmo id)","value":{"id":"nfse_01m69f6x872ssjbg053z9v2c50","objeto":"nfse","ambiente":"simulacao","modelo":"nfse","ref":"QAN3-140635-exrej","status":"rejeitada","etapa":"concluido","emitente":{"id":121,"cnpj":"47591675000116","razao_social":"QA N3 Serviços São Paulo Ltda"},"serie_dps":1,"numero_dps":46,"id_dps":"DPS355030824759167500011600001000000000000046","chave":null,"numero_nfse":null,"competencia":"2026-10-31","data_emissao":"2026-10-31T14:13:10-03:00","municipio_emissor":"3550308","municipio_prestacao":"3550308","codigo_tributacao_nacional":"010701","codigo_nbs":"115013000","valor_servicos":"350.00","valor_iss":"0.00","iss_retido":false,"valor_retido":"0.00","valor_liquido":"350.00","valor_total":"350.00","tomador":{"documento":"38461592719","nome":"Maria Fictícia da Silva"},"sefaz":{"cstat":"E0625","motivo":"Alíquota informada para optante ME/EPP do Simples Nacional que apura o ISSQN no Simples e não tem retenção.","protocolo":null,"recibo":null},"autorizada_em":null,"cancelada_em":null,"erros":[{"campo":"iss.aliquota","codigo":"sefaz_E0625","mensagem":"Alíquota informada para optante ME/EPP do Simples Nacional que apura o ISSQN no Simples e não tem retenção.","sefaz":{"cstat":"E0625","xmotivo":"Alíquota informada para optante ME/EPP do Simples Nacional que apura o ISSQN no Simples e não tem retenção."},"dica":"Optante ME/EPP que apura o ISS no Simples e não tem retenção não informa alíquota. Tire `iss.aliquota` ou confira o regime do emitente.","documentacao":"https://api.madnotas.com.br/desenvolvedores/erros/E0625"}],"avisos":[{"campo":null,"codigo":"simulacao_assinatura_teste","mensagem":"Em simulação a DPS é assinada com um certificado de teste."}],"tentativas":1,"proxima_tentativa_em":null,"origem":"api","substitui":null,"substituida_por":null,"criado_em":"2026-10-31T14:13:11-03:00","atualizado_em":"2026-10-31T14:13:11-03:00","links":{"self":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f6x872ssjbg053z9v2c50","xml":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f6x872ssjbg053z9v2c50/xml","eventos":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f6x872ssjbg053z9v2c50/eventos"}}},"NfseSubstituta":{"summary":"Substituta autorizada","value":{"id":"nfse_01m69f1d9effxgb8mmyz791axw","objeto":"nfse","ambiente":"simulacao","modelo":"nfse","ref":"QAN3-140635-sub2","status":"autorizada","etapa":"concluido","emitente":{"id":121,"cnpj":"47591675000116","razao_social":"QA N3 Serviços São Paulo Ltda"},"serie_dps":1,"numero_dps":45,"id_dps":"DPS355030824759167500011600001000000000000045","chave":"35503082247591675000116900100000004526103377034241","numero_nfse":"9001000000045","competencia":"2026-10-31","data_emissao":"2026-10-31T14:10:10-03:00","municipio_emissor":"3550308","municipio_prestacao":"3550308","codigo_tributacao_nacional":"010701","codigo_nbs":"115013000","valor_servicos":"100.00","valor_iss":"2.00","iss_retido":false,"valor_retido":"0.00","valor_liquido":"100.00","valor_total":"100.00","tomador":null,"sefaz":{"cstat":null,"motivo":null,"protocolo":null,"recibo":null},"autorizada_em":"2026-10-31T14:10:11-03:00","cancelada_em":null,"erros":[],"avisos":[{"campo":null,"codigo":"simulacao_assinatura_teste","mensagem":"Em simulação a DPS é assinada com um certificado de teste."}],"tentativas":1,"proxima_tentativa_em":null,"origem":"api","substitui":"nfse_01m69eyjngrvqb9574n6drahcw","substituida_por":null,"criado_em":"2026-10-31T14:10:10-03:00","atualizado_em":"2026-10-31T14:10:11-03:00","links":{"self":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f1d9effxgb8mmyz791axw","xml":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f1d9effxgb8mmyz791axw/xml","danfse":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f1d9effxgb8mmyz791axw/danfse","eventos":"https://api.madnotas.com.br/api/v1/nfse/nfse_01m69f1d9effxgb8mmyz791axw/eventos"}}},"ValidacaoNfse":{"summary":"Válida","value":{"valido":true,"erros":[],"avisos":[{"campo":null,"codigo":"simulacao_assinatura_teste","mensagem":"Em simulação a DPS é assinada com um certificado de teste."}],"id_dps_previsto":"DPS330455724064320500010000001000000000000013","serie_dps":1,"numero_dps_previsto":13,"xml":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<DPS xmlns=\"http://www.sped.fazenda.gov.br/nfse\" versao=\"1.01\"><infDPS Id=\"DPS330455724064320500010000001000000000000013\"…","totais":{"valor_servicos":"1500.00","desconto_incondicionado":"0.00","desconto_condicionado":"0.00","base_iss":"1500.00","aliquota_iss":"2.0000","valor_iss":"30.00","valor_iss_retido":"30.00","valor_pis":"0.00","valor_cofins":"0.00","valor_irrf":"0.00","valor_csll":"0.00","valor_inss":"0.00","valor_retido":"30.00","valor_liquido":"1470.00"}}},"ValidacaoNfseInvalida":{"summary":"Inválida (nada reservado)","value":{"valido":false,"erros":[{"campo":"servicos[1].codigo_tributacao_nacional","codigo":"servicos_incompativeis","mensagem":"Todas as linhas de `servicos` precisam ter os mesmos códigos fiscais (cTribNac, NBS e código municipal): esta difere da 1ª linha.","dica":"Emita uma NFS-e por código de serviço."}],"avisos":[{"campo":null,"codigo":"simulacao_assinatura_teste","mensagem":"Em simulação a DPS é assinada com um certificado de teste."}],"id_dps_previsto":"DPS330455724064320500010000001000000000000013","serie_dps":1,"numero_dps_previsto":13,"xml":null,"totais":{"valor_servicos":"15.00","desconto_incondicionado":"0.00","desconto_condicionado":"0.00","base_iss":"15.00","aliquota_iss":"2.0000","valor_iss":"0.30","valor_iss_retido":"0.00","valor_pis":"0.00","valor_cofins":"0.00","valor_irrf":"0.00","valor_csll":"0.00","valor_inss":"0.00","valor_retido":"0.00","valor_liquido":"15.00"}}},"EventoNfse":{"summary":"Cancelamento registrado","value":{"id":"evt_01m69f0saf31v0npxn7rwhr24g","objeto":"evento","tipo":"cancelamento","codigo_evento":"101101","sequencia":1,"texto":"Valor do serviço digitado errado na emissão","codigo_motivo":"1","status":"registrado","sefaz":{"cstat":null,"motivo":null,"protocolo":null},"registrado_em":"2026-10-31T14:09:51-03:00","criado_em":"2026-10-31T14:09:50-03:00"}},"NfseEmitente":{"summary":"Bloco nfse do emitente","value":{"habilitada":true,"opcao_simples":"me_epp","regime_apuracao_simples":"tudo_no_simples","regime_especial":"nenhum","municipio_prestacao_padrao":"3550308","tributacao_iss_padrao":"tributavel","aliquota_iss_padrao":"2.0000","codigo_tributacao_nacional_padrao":"010701","codigo_nbs_padrao":"115013000","codigo_tributacao_municipal_padrao":null,"percentual_tributos_simples":"6.0000","ibscbs":{"habilitado":false,"cst":"000","classificacao_tributaria":"000001","indicador_operacao":"100301"},"numeracao":{"serie_dps":1,"proximo_numero_dps":46},"convenio":{"situacao":"nao_conferido","conferido_em":null},"cadastro_municipal":null}},"MunicipioNfse":{"summary":"Convênio do município","value":{"codigo":"3550308","nome":"São Paulo","uf":"SP","convenio":"nao_conferido","conferido_em":null}},"CancelamentoNfse":{"summary":"Cancelar","value":{"codigo_motivo":"1","justificativa":"Valor do serviço digitado errado na emissão"}},"SubstituicaoNfse":{"summary":"Substituir","value":{"ref":"nfse-venda-1234-2","substituicao":{"codigo_motivo":"99","motivo":"Correção da descrição e do valor do serviço prestado"},"servicos":[{"descricao":"Suporte técnico em informática — outubro/2026","valor_unitario":"1650.00"}],"tomador":{"documento":"72619438000163","nome":"Comercial Horizonte Ltda"}}},"NfseEmitenteEntrada":{"summary":"ME/EPP no Simples","value":{"habilitada":true,"opcao_simples":"me_epp","regime_apuracao_simples":"tudo_no_simples","regime_especial":"nenhum","municipio_prestacao_padrao":"3550308","tributacao_iss_padrao":"tributavel","aliquota_iss_padrao":"2.0000","codigo_tributacao_nacional_padrao":"010701","codigo_nbs_padrao":"115013000","codigo_tributacao_municipal_padrao":null,"percentual_tributos_simples":"6.0000","ibscbs":{"habilitado":false,"cst":"000","classificacao_tributaria":"000001","indicador_operacao":"100301"}}},"Dfe":{"summary":"Resumo recebido (antes da ciência)","value":{"id":"dfe_0000004b4484d31a","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":54,"chave":"41261087834655000143550010001841871339683281","modelo":"55","fornecedor":{"documento":"87834655000143","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"873093881"},"data_emissao":"2026-10-31T13:20:14-03:00","tipo_operacao":"saida","valor_total":"3.10","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:46:14-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/eventos"}}},"DfeCompleto":{"summary":"XML completo depois da ciência","value":{"id":"dfe_0000004b4484d31a","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":57,"chave":"41261087834655000143550010001841871339683281","modelo":"55","fornecedor":{"documento":"87834655000143","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"873093881"},"data_emissao":"2026-10-31T13:20:14-03:00","tipo_operacao":"saida","valor_total":"3.10","situacao_nfe":"autorizada","xml_completo":true,"manifestacao":{"tipo":"ciencia","status":"registrado","registrada_em":"2026-10-31T18:47:45-03:00"},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:47:47-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/eventos"}}},"DfeCancelada":{"summary":"Cancelada pelo emissor","value":{"id":"dfe_0000004e5ecf77e0","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":59,"chave":"35261089040252000158550010002553841928044609","modelo":"55","fornecedor":{"documento":"89040252000158","nome":"Distribuidora Fictícia de Peças Ltda","inscricao_estadual":"101251919"},"data_emissao":"2026-10-31T11:25:03-03:00","tipo_operacao":"saida","valor_total":"353.00","situacao_nfe":"cancelada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:48:03-03:00","atualizado_em":"2026-10-31T18:48:03-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004e5ecf77e0","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004e5ecf77e0/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004e5ecf77e0/eventos"}}},"ListaDfe":{"summary":"Página por NSU crescente","value":{"dados":[{"id":"dfe_0000004b4484d31a","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":54,"chave":"41261087834655000143550010001841871339683281","modelo":"55","fornecedor":{"documento":"87834655000143","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"873093881"},"data_emissao":"2026-10-31T13:20:14-03:00","tipo_operacao":"saida","valor_total":"3.10","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:46:14-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/eventos"}},{"id":"dfe_0000004c6d47f976","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":55,"chave":"31261072385737000180550010005000251876785858","modelo":"55","fornecedor":{"documento":"72385737000180","nome":"Indústria Modelo de Embalagens Ltda","inscricao_estadual":"975299550"},"data_emissao":"2026-10-31T14:08:14-03:00","tipo_operacao":"saida","valor_total":"182.60","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:46:14-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976/eventos"}},{"id":"dfe_0000004dbe3b6cf8","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":56,"chave":"41261094656763000139550010001477261574930601","modelo":"55","fornecedor":{"documento":"94656763000139","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"830784666"},"data_emissao":"2026-10-31T10:21:14-03:00","tipo_operacao":"saida","valor_total":"162.15","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:46:14-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8/eventos"}}],"tem_mais":false,"proximo_cursor":null}},"EventoDfe":{"summary":"Ciência registrada","value":{"id":"evt_0000005i377b0520","objeto":"evento","origem":"manifestacao","tipo":"ciencia","codigo_evento":"210210","descricao":"Ciência da Emissão","justificativa":null,"nsu":null,"status":"registrado","sefaz":{"cstat":"135","motivo":"Evento registrado e vinculado a NF-e","protocolo":"891267223142628"},"registrado_em":"2026-10-31T18:47:45-03:00","criado_em":"2026-10-31T18:47:45-03:00"}},"ManifestacaoDfeResposta":{"summary":"Ciência registrada (201)","value":{"id":"evt_0000005i377b0520","objeto":"evento","origem":"manifestacao","tipo":"ciencia","codigo_evento":"210210","descricao":"Ciência da Emissão","justificativa":null,"nsu":null,"status":"registrado","sefaz":{"cstat":"135","motivo":"Evento registrado e vinculado a NF-e","protocolo":"891267223142628"},"registrado_em":"2026-10-31T18:47:45-03:00","criado_em":"2026-10-31T18:47:45-03:00","dfe":{"id":"dfe_0000004b4484d31a","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":54,"chave":"41261087834655000143550010001841871339683281","modelo":"55","fornecedor":{"documento":"87834655000143","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"873093881"},"data_emissao":"2026-10-31T13:20:14-03:00","tipo_operacao":"saida","valor_total":"3.10","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":"ciencia","status":"registrado","registrada_em":"2026-10-31T18:47:45-03:00"},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:47:45-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/eventos"}}}},"ManifestacaoDfeRejeitada":{"summary":"Manifestação rejeitada pelo AN (201, status rejeitado)","value":{"id":"evt_0000005kad15776a","objeto":"evento","origem":"manifestacao","tipo":"nao_realizada","codigo_evento":"210240","descricao":"Operação não Realizada","justificativa":"SIM-REJ-596 evento fora do prazo de manifestacao","nsu":null,"status":"rejeitado","sefaz":{"cstat":"596","motivo":"Rejeição: Evento apresentado fora do prazo: [prazo vigente]","protocolo":null},"registrado_em":null,"criado_em":"2026-10-31T18:47:55-03:00","dfe":{"id":"dfe_0000004c6d47f976","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":55,"chave":"31261072385737000180550010005000251876785858","modelo":"55","fornecedor":{"documento":"72385737000180","nome":"Indústria Modelo de Embalagens Ltda","inscricao_estadual":"975299550"},"data_emissao":"2026-10-31T14:08:14-03:00","tipo_operacao":"saida","valor_total":"182.60","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":"nao_realizada","status":"rejeitado","registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:47:55-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976/eventos"}}}},"SituacaoDfe":{"summary":"Em dia","value":{"emitente_id":130,"ambiente":"simulacao","ultimo_nsu":61,"max_nsu":61,"ultima_consulta_em":"2026-10-31T18:48:20-03:00","proxima_consulta_em":"2026-10-31T19:48:30-03:00","estado":"em_dia","motivo":null}},"SimulacaoDfeResposta":{"summary":"3 notas fictícias","value":{"objeto":"simulacao_dfe","emitente_id":130,"quantidade":3,"cenario":"normal","chaves":["41261087834655000143550010001841871339683281","31261072385737000180550010005000251876785858","41261094656763000139550010001477261574930601"],"consulta":{"consultou":true,"cstat":"138","novos":3,"atualizados":0},"situacao":{"emitente_id":130,"ambiente":"simulacao","ultimo_nsu":56,"max_nsu":56,"ultima_consulta_em":"2026-10-31T18:46:14-03:00","proxima_consulta_em":"2026-10-31T19:46:24-03:00","estado":"em_dia","motivo":null},"dados":[{"id":"dfe_0000004b4484d31a","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":54,"chave":"41261087834655000143550010001841871339683281","modelo":"55","fornecedor":{"documento":"87834655000143","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"873093881"},"data_emissao":"2026-10-31T13:20:14-03:00","tipo_operacao":"saida","valor_total":"3.10","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:46:14-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004b4484d31a/eventos"}},{"id":"dfe_0000004c6d47f976","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":55,"chave":"31261072385737000180550010005000251876785858","modelo":"55","fornecedor":{"documento":"72385737000180","nome":"Indústria Modelo de Embalagens Ltda","inscricao_estadual":"975299550"},"data_emissao":"2026-10-31T14:08:14-03:00","tipo_operacao":"saida","valor_total":"182.60","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:46:14-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004c6d47f976/eventos"}},{"id":"dfe_0000004dbe3b6cf8","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":56,"chave":"41261094656763000139550010001477261574930601","modelo":"55","fornecedor":{"documento":"94656763000139","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"830784666"},"data_emissao":"2026-10-31T10:21:14-03:00","tipo_operacao":"saida","valor_total":"162.15","situacao_nfe":"autorizada","xml_completo":false,"manifestacao":{"tipo":null,"status":null,"registrada_em":null},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:46:14-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8/eventos"}}]}},"DfeEmitente":{"summary":"Bloco dfe do emitente","value":{"habilitado":true,"situacao":{"emitente_id":130,"ambiente":"simulacao","ultimo_nsu":53,"max_nsu":53,"ultima_consulta_em":"2026-10-31T18:35:30-03:00","proxima_consulta_em":"2026-10-31T19:35:40-03:00","estado":"em_dia","motivo":null}}},"ManifestacaoDfe":{"summary":"Ciência da emissão","value":{"tipo":"ciencia"}},"ManifestacaoDfeNaoRealizada":{"summary":"Operação não realizada","value":{"tipo":"nao_realizada","justificativa":"Mercadoria devolvida na portaria sem entrada no estoque"}},"SimulacaoDfe":{"summary":"3 notas no cenário normal","value":{"emitente_id":12,"quantidade":3,"cenario":"normal"}},"SimulacaoDfeCancelamentoPosterior":{"summary":"Fornecedor cancela uma nota já entregue","value":{"emitente_id":12,"cenario":"cancelamento_posterior","chave":"35261059183627000178550010000123451000123459"}},"SimulacaoDfeRespostaCancelamentoPosterior":{"summary":"Mesma nota, agora cancelada","value":{"objeto":"simulacao_dfe","emitente_id":130,"quantidade":1,"cenario":"cancelamento_posterior","chaves":["41261094656763000139550010001477261574930601"],"consulta":{"consultou":true,"cstat":"138","novos":0,"atualizados":1},"situacao":{"emitente_id":130,"ambiente":"simulacao","ultimo_nsu":61,"max_nsu":61,"ultima_consulta_em":"2026-10-31T18:48:20-03:00","proxima_consulta_em":"2026-10-31T19:48:30-03:00","estado":"em_dia","motivo":null},"dados":[{"id":"dfe_0000004dbe3b6cf8","objeto":"dfe","ambiente":"simulacao","emitente":{"id":130,"cnpj":"47670421000193","razao_social":"QA N6 Serviços São Paulo Ltda"},"nsu":61,"chave":"41261094656763000139550010001477261574930601","modelo":"55","fornecedor":{"documento":"94656763000139","nome":"Comercial Teste de Ferragens Ltda","inscricao_estadual":"830784666"},"data_emissao":"2026-10-31T10:21:14-03:00","tipo_operacao":"saida","valor_total":"162.15","situacao_nfe":"cancelada","xml_completo":false,"manifestacao":{"tipo":"desconhecimento","status":"rejeitado","registrada_em":"2026-10-31T18:47:58-03:00"},"recebido_em":"2026-10-31T18:46:14-03:00","atualizado_em":"2026-10-31T18:48:20-03:00","links":{"self":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8","xml":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8/xml","eventos":"https://proj-6e831164-6bc2-4128-8e36-00a304b709f7.test.madbuilder.dev/api/v1/dfe/dfe_0000004dbe3b6cf8/eventos"}}]}},"SincronizarDfe":{"summary":"Pedir consulta","value":{"emitente_id":12}},"DfeEmitenteEntrada":{"summary":"Ligar","value":{"habilitado":true}}}},"webhooks":{"nfse.autorizada":{"post":{"tags":["NFS-e"],"summary":"nfse.autorizada","description":"A Sefin gerou a NFS-e.","operationId":"webhook_nfse_autorizada","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"nfse.autorizada"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"$ref":"#/components/schemas/Nfse"}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"nfse.rejeitada":{"post":{"tags":["NFS-e"],"summary":"nfse.rejeitada","description":"A Sefin recusou a DPS (erros[] no objeto).","operationId":"webhook_nfse_rejeitada","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"nfse.rejeitada"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"$ref":"#/components/schemas/Nfse"}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"nfse.cancelada":{"post":{"tags":["NFS-e"],"summary":"nfse.cancelada","description":"Cancelamento homologado (inclusive o externo).","operationId":"webhook_nfse_cancelada","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"nfse.cancelada"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"allOf":[{"$ref":"#/components/schemas/Nfse"},{"type":"object","properties":{"evento":{"type":"object","properties":{"id":{"type":"string"},"codigo_evento":{"type":"string"},"codigo_motivo":{"type":["string","null"]},"origem":{"type":"string","enum":["api","painel","externo"]},"autor":{"type":["string","null"]}},"additionalProperties":true}},"additionalProperties":true}]}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"nfse.substituida":{"post":{"tags":["NFS-e"],"summary":"nfse.substituida","description":"A substituta foi autorizada; `dados` é a NFS-e ANTIGA.","operationId":"webhook_nfse_substituida","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"nfse.substituida"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"allOf":[{"$ref":"#/components/schemas/Nfse"},{"type":"object","properties":{"substituta":{"type":"object","properties":{"id":{"type":"string"},"chave":{"type":["string","null"]},"numero_nfse":{"type":["string","null"]}},"additionalProperties":true}},"additionalProperties":true}]}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"nfse.evento_rejeitado":{"post":{"tags":["NFS-e"],"summary":"nfse.evento_rejeitado","description":"A Sefin recusou um cancelamento; a nota segue autorizada.","operationId":"webhook_nfse_evento_rejeitado","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"nfse.evento_rejeitado"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"allOf":[{"$ref":"#/components/schemas/Nfse"},{"type":"object","properties":{"evento":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string"},"sefaz":{"type":"object","properties":{"cstat":{"type":["string","null"]},"motivo":{"type":["string","null"]}},"additionalProperties":true}},"additionalProperties":true}},"additionalProperties":true}]}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"emitente.nfse_convenio_alterado":{"post":{"tags":["NFS-e"],"summary":"emitente.nfse_convenio_alterado","description":"O município deixou de ser conveniado ou voltou a ser.","operationId":"webhook_emitente_nfse_convenio_alterado","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"emitente.nfse_convenio_alterado"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"type":"object","properties":{"emitente_id":{"type":"integer"},"municipio":{"type":"string"},"situacao_anterior":{"type":"string"},"situacao":{"type":"string"}},"additionalProperties":true}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"dfe.recebido":{"post":{"tags":["DF-e"],"summary":"dfe.recebido","description":"Documento recebido novo, ou um que já existia mudou de um jeito que importa: motivo novo · xml_completo (o procNFe chegou: hora de importar) · evento_emissor (o fornecedor cancelou ou corrigiu).","operationId":"webhook_dfe_recebido","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"dfe.recebido"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"type":"object","properties":{"motivo":{"type":"string","enum":["novo","xml_completo","evento_emissor"]},"dfe":{"$ref":"#/components/schemas/Dfe"}},"required":["motivo","dfe"],"additionalProperties":true}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"dfe.manifestacao_registrada":{"post":{"tags":["DF-e"],"summary":"dfe.manifestacao_registrada","description":"O Ambiente Nacional registrou a manifestação.","operationId":"webhook_dfe_manifestacao_registrada","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"dfe.manifestacao_registrada"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"type":"object","properties":{"evento":{"$ref":"#/components/schemas/EventoDfe"},"dfe":{"$ref":"#/components/schemas/Dfe"}},"required":["evento","dfe"],"additionalProperties":true}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}},"dfe.manifestacao_rejeitada":{"post":{"tags":["DF-e"],"summary":"dfe.manifestacao_rejeitada","description":"O Ambiente Nacional rejeitou a manifestação (cStat no evento).","operationId":"webhook_dfe_manifestacao_rejeitada","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"tipo":{"type":"string","const":"dfe.manifestacao_rejeitada"},"criado_em":{"type":["string","null"],"format":"date-time"},"ambiente":{"type":"string"},"api_versao":{"type":"string","const":"v1"},"dados":{"type":"object","properties":{"evento":{"$ref":"#/components/schemas/EventoDfe"},"dfe":{"$ref":"#/components/schemas/Dfe"}},"required":["evento","dfe"],"additionalProperties":true}},"required":["id","tipo","dados"],"additionalProperties":true}}}},"responses":{"200":{"description":"Responda 2xx em até 10 s; senão o MadNotas tenta de novo."}}}}}}