API Reference
Issue, consult, cancel and correct
Issuing, consulting, cancelling, reissuing, correction letters and numbering invalidation — NF-e and NFS-e, each with what it supports.
JSON over HTTPS
Requests and responses are JSON, authenticated with a Bearer API key.
Scoped to one company
Every request is scoped to one company — the issuer's UF, address, and digital certificate are resolved server-side from the API key, so a request only needs the business fields (buyer, items, amounts).
Just getting started?
Create a free account, generate an API key and issue your first document in homologation — free and unlimited, no card.
https://api.stackin.io/api/v1CopyAll API endpoints are relative to this base URL.
Download the Postman collectionGenerated from the same OpenAPI as this page. Import it and fill in the api_key variable.
Copy a prompt for your AI
Paste it into your editor's assistant chat — Claude Code, Cursor, Copilot, Codex or ChatGPT. Each prompt tells the agent what to do, what to check and what never to do with your key.
- Build the integrationIssuing from your own domain objects, with idempotency, webhooks, rejections and tests.Copy promptCopy prompt: Build the integration
Show the prompt
You are my coding assistant. Build invoice issuing through Stackin into this project (NFS-e for services, NF-e for goods), in homologation. 1. Read the code and tell me where a billable sale or service comes from and who the recipient is. Propose where the integration lives (one module/service) before writing it. 2. Use the official SDK (https://docs.stackin.io/en/sdks) or the HTTP API (https://docs.stackin.io/en/api). Create the client once, with the key in STACKIN_API_KEY. 3. Build the issue call from the domain objects: https://docs.stackin.io/en/api#issue-invoice and https://docs.stackin.io/en/api#item-values. Do not make up an NCM, CFOP or service code — read it from the product record or ask me. 4. Send one idempotency key per business event (the order id, for example), stored with the order: https://docs.stackin.io/en/api#idempotency. Repeating the call must never produce a second invoice. 5. Store the returned id and access key. Follow the outcome by webhook (https://docs.stackin.io/en/api#webhooks), checking Stackin-Signature and ignoring a repeated Stackin-Delivery-Id; consult the status (https://docs.stackin.io/en/api#consult-invoice) only as a fallback. 6. Treat a rejection as a business state: store the reason, show it to the user and allow a reissue after the fix (https://docs.stackin.io/en/api#errors, https://docs.stackin.io/en/api#reissue-invoice). 7. Write tests with a mocked client and an optional integration test against homologation. Never: - expose the key in code, logs or commits; - issue in production, or switch the key to production, without my explicit confirmation; - retry an issue call without the same idempotency key./prompts/en/integration.md - Fix an errorDiagnoses authentication, validation, tax-authority rejections, certificates and rate limits, and proposes the fix.Copy promptCopy prompt: Fix an error
Show the prompt
You are my coding assistant. Help me diagnose a problem with Stackin (Brazilian NF-e and NFS-e invoices) in this project. 1. Ask for the exact error message, the HTTP status, the operation and the document type. Do not guess before that. 2. Check the environment without exposing the key: does STACKIN_API_KEY exist? Is it an API key (api.stackin.io) or an SDK key (sdk.stackin.io)? Homologation or production? 3. Classify by status, using https://docs.stackin.io/en/api#errors: - 401: key missing, expired, or created for the other host. - 403: the connection does not cover the company, or the permission/OAuth scope is missing (INSUFFICIENT_PERMISSION, https://docs.stackin.io/en/mcp#scopes). - 400: the issuer's setup — certificate, address or fiscal fields at https://app.stackin.io. - 422: company_required (the connection covers several companies and the call names none, https://docs.stackin.io/en/api#companies), an invalid field, or a SEFAZ/municipal rejection with the error block. For the authority's code and what to change, use explain_rejection over MCP, GET /invoices/{invoice_id}/rejection over the API, or rejection(invoice_id) in the Python SDK; the other SDKs do not have the method yet, so call the HTTP route. The submission history (get_invoice_submissions, https://docs.stackin.io/en/api#invoice-submissions) is only the raw data, for when the explanation is not enough. - 429: wait Retry-After and repeat with the same idempotency key (https://docs.stackin.io/en/api#rate-limits). - 502/503: the authority did not answer; check error.retryable. 4. Propose the smallest fix, explain why, and apply it only after I agree. Never: - print or commit the key; - reissue, cancel or issue again in production without my explicit confirmation — first check the invoice was not already authorized; - turn off webhook signature checks to "make it work"./prompts/en/troubleshoot.md
Authentication
The API authenticates with an API key — same mechanism as the SDK, just with its context set to . No login, no JWT — one Bearer header on every request.
Getting an API key
- 1Sign up and log in at .
- 2Create a company — this is required before a key.
- 3In the dashboard, with the company selected, go to Management → Integrations → API keys. The context starts as
sdk— switch it toapi. - 4Name the key and choose its environment —
homologationorproduction. Both are required at creation, and the environment is fixed for the key’s whole lifetime. - 5Copy the key immediately — it's shown , at creation time, and can't be retrieved again. Losing it means revoking it and creating a new one.
curl https://api.stackin.io/api/v1/invoices \
-H "Authorization: Bearer $STACKIN_API_KEY"A missing or invalid token gets a 401 — see below.
Environments
Every API key is created for exactly one environment — or or — chosen when you generate it, and fixed for that key's lifetime.
There's no environment field in API requests: the key decides where the document goes.
Free and unlimited — it's the real SEFAZ/ADN test environment, not a mock — so integrate and test fully before switching to production. The recipient goes through the same rules as production: for an NF-e the SEFAZ accepts the test CNPJ 99999999000191; for an NFS-e the ADN checks the tomador against the Receita registry — the CNPJ (E0190) and the CPF (E0206 invalid check digits, E0207 not registered) — so use an active CNPJ or a real, registered CPF.
For real documents. Make sure everything works in homologation before switching.
A company can hold keys for both environments at once (up to 3 total).
Several companies
An API key belongs to one company and needs nothing here — calls made with it work exactly as before. An OAuth credential, the kind an app receives through the consent screen, may cover several companies, each with its own permissions, all in one environment.
With such a credential, every call that touches a company's documents names the company in the X-Stackin-Company header or the company_id query parameter. The value is the company's UUID or its CNPJ/CPF, punctuation ignored: 11.222.333/0001-81 and 11222333000181 are the same company. A credential that covers a single company can keep naming none.
GET /me/companies lists what the credential covers: each company's company_id, name, tax_id and permissions. It needs no company named, and neither do the fiscal-code and taxpayer lookups. An API key lists its one company with every permission.
Webhook deliveries carry company_id and tax_id beside event and data, so one receiver serving several companies knows which one each event belongs to.
curl https://api.stackin.io/api/v1/me/companies \
-H "Authorization: Bearer $STACKIN_ACCESS_TOKEN"
curl "https://api.stackin.io/api/v1/invoices?limit=20" \
-H "Authorization: Bearer $STACKIN_ACCESS_TOKEN" \
-H "X-Stackin-Company: 11.222.333/0001-81"{
"environment": "production",
"companies": [
{
"company_id": "6f1c2a9e-3b7d-4c21-9a8e-2d5f0b6c7e14",
"name": "Buyer Company Ltd",
"tax_id": "11222333000181",
"permissions": ["invoice:read", "invoice:issue"]
},
{
"company_id": "0b8d4e71-5a2c-4f90-8e13-7c6a9d2b1f05",
"name": "Buyer Company Ltd — Branch",
"tax_id": "11222333000262",
"permissions": ["invoice:read"]
}
]
}{
"detail": {
"error": "company_required",
"error_description": "This credential covers several companies. Name one in the X-Stackin-Company header or the company_id query parameter, by id or tax id.",
"companies": [
{
"company_id": "6f1c2a9e-3b7d-4c21-9a8e-2d5f0b6c7e14",
"name": "Buyer Company Ltd",
"tax_id": "11222333000181",
"permissions": ["invoice:read", "invoice:issue"]
}
]
}
}- X-Stackin-Company
- header | optionalthe company the call acts on, by UUID or CNPJ/CPF. Only a credential that covers several companies needs it; an API key that sends it must name its own company.
- company_id
- query | optionalthe same value as a query parameter, for a client that cannot set a header. The header wins when both are sent.
- 422
- company_requiredthe credential covers several companies and the call named none. The answer lists them.
- 403
- company_not_in_scopethe company named is not one the credential covers. The answer lists the ones it does.
- 422
- company_ambiguousthe tax id names more than one company the credential covers. Name it by its UUID instead.
- 403
- insufficient_scopethe credential covers the company but not this operation there.
codeisINSUFFICIENT_PERMISSIONand the description readsneeds X, has Y, company=<id>.
Idempotency
Issuing is the one call you must not repeat blindly. If the response is lost — a timeout, a dropped connection — the document may well have been authorized, and a second attempt issues a second fiscal document: another credit, another series number burned, and undoing it means cancelling, which has a deadline.
Send an Idempotency-Key header to make the retry safe. Repeat with the same key and the same body and you get the first response back — no second document, no credit consumed. It works on POST /invoices and on POST /invoices/{id}/reissue.
Generate the key yourself — one UUID per business event, not per HTTP request — and keep it for as long as you might retry. Keys live 24 hours; after that the same key is treated as new.
curl -X POST https://api.stackin.io/api/v1/invoices \
-H "Authorization: Bearer $STACKIN_API_KEY" \
-H "Idempotency-Key: 3f7c1e9a-2b4d-4f6a-8c1e-9d0b5a7f2c34" \
-H "Content-Type: application/json" \
-d '{
"document_type": "nfse",
"client_name": "John Doe",
"tax_id": "00000000000",
"items": [
{ "description": "Technical consulting - 10 hours", "unit_price": "1500.00" }
]
}'- Idempotency-Key
- header | optionalyour key, up to 255 characters. It is scoped to your company: one account's key never collides with another's.
- 201
- replaysame key, same body: returns the recorded response without reprocessing.
- 422
- mismatchsame key, different body. Reusing a key on another request is a client bug, not a retry.
- 409
- in progressthe first call is still running. Consult before trying again.
Rate limits
Limits are per API key. Each company has its own count — one client's volume never spends another's allowance.
Issuing has a tighter limit than consulting, and consulting a tighter one than reading history. The more an operation depends on the SEFAZ, the fewer calls per minute it takes.
Every response carries the limit, what's left, and when the window reopens. Going over returns 429 with Retry-After in seconds — wait that long before trying again.
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1788556800{
"detail": "Rate limit reached: 60 requests per 60s for this operation. Retry after the window resets."
}- POST /invoices
- 60 / minproduces a document and consumes credit.
- POST /invoices/{id}/reissue
- 60 / minproduces a document and consumes credit.
- GET /invoices/{access_key}
- 120 / minreaches the SEFAZ, but produces no document.
- GET /invoices/dps/{dps_id}
- 120 / minreaches the SEFAZ, but produces no document.
- POST /invoices/{access_key}/cancel
- 120 / minreaches the SEFAZ, but produces no document.
- POST /invoices/validate
- 120 / minchecks the draft: nothing is sent, issued or charged. Counted apart from issuing.
- GET /invoices
- 600 / minnever leaves stackin.
- /clients, /clients/{id}
- 600 / minnever leaves stackin.
Webhooks
Instead of polling to learn how an issuance ended or whether a document was issued against your tax id, register an https URL and stackin tells you. An endpoint with events: [] gets all of them, including events added after it was registered — answer 2xx to the ones you don't handle, or list only those you want. An unknown event name is refused at registration.
Every delivery is signed in Stackin-Signature, shaped t=<epoch>,v1=<hmac>. The HMAC is SHA-256 over {timestamp}.{body} with your secret. Check it before processing: the signature is what separates our delivery from whoever learned your URL.
Delivery is at least once — on failure we retry 6 times, waiting from 30s up to 6h. Use Stackin-Delivery-Id to ignore what you already handled. The history, including what we gave up on, is at GET /webhooks/deliveries.
The envelope carries environment (homologation or production) and, in data, the external_reference you sent at issuance, or null if you sent none. On invoice.rejected, access_key can be null: a rejected document may have no key.
curl -X POST https://api.stackin.io/api/v1/webhooks \
-H "Authorization: Bearer $STACKIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://seu-erp.com.br/stackin", "secret": "um-segredo-longo-e-aleatorio", "events": []}'{
"event": "invoice.authorized",
"company_id": "6f1c2a9e-3b7d-4c21-9a8e-2d5f0b6c7e14",
"tax_id": "11222333000181",
"environment": "production",
"data": {
"invoice_id": "9f2c1e3a-4b5d-6e7f-8a9b-0c1d2e3f4a5b",
"document_type": "nfe",
"access_key": "35240912345678000199550010000000011000000017",
"status": "issued",
"amount": 1500.0,
"external_reference": "pedido-1042"
}
}{
"event": "received_invoice.stored",
"company_id": "6f1c2a9e-3b7d-4c21-9a8e-2d5f0b6c7e14",
"tax_id": "11222333000181",
"environment": "production",
"data": {
"access_key": "42260831112223330001815500000012341123456789",
"schema": "resNFe",
"has_full_document": false,
"issuer": {
"tax_id": "31112223000181",
"name": "Fornecedor Exemplo LTDA"
},
"amount": 1234.5,
"issued_at": "2026-11-17T13:05:02-03:00",
"operation_status": "1",
"environment": "production",
"payment_required": false
}
}import hashlib, hmac, time
def verify(secret: str, body: str, header: str, tolerance: int = 300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
if abs(int(time.time()) - int(parts["t"])) > tolerance:
return False
expected = hmac.new(
secret.encode(),
f'{parts["t"]}.{body}'.encode(),
hashlib.sha256,
).hexdigest()
return hmac.compare_digest(expected, parts["v1"])- invoice.authorized
- eventthe SEFAZ authorized the document.
- invoice.rejected
- eventthe SEFAZ refused it. The reason is on the invoice's history.
- invoice.cancelled
- eventthe cancellation went through.
- invoice.corrected
- eventa correction letter was filed.
- received_invoice.stored
- eventa document issued against your tax id was stored for the first time (summary or full). Once per access key.
- received_invoice.full_document
- eventthe full XML (procNFe) of a received document arrived and can be downloaded. Once per access key.
- Stackin-Signature
- headerthe timestamp is part of what is signed, so a captured delivery cannot be replayed later.
- Stackin-Delivery-Id
- headeridentifies the delivery. Two with the same id are the same thing, sent again.
Versioning
The path is /api/v1. Inside it we may add — a new response field, a new enum value, a new endpoint, a new optional parameter — without changing versions.
Your side of that: treat an unknown field as data, not as an error. All four official SDKs already do, each with a test locking the behaviour. If you call the API directly, don't validate the response against a closed schema.
Removing something, changing a type, tightening a validation or changing what a value means requires a new version. When a /v2 exists, /v1 keeps answering for at least 12 months — and says so on every response, with the headers alongside.
Deprecation: Fri, 01 Jan 2027 00:00:00 GMT
Sunset: Sat, 01 Jan 2028 00:00:00 GMT
Link: <https://docs.stackin.io/api#versioning>; rel="deprecation"- additive
- no new versionnew field, new enum value, new endpoint, new optional parameter.
- breaking
- requires /v2removing something, changing a type, tightening a validation, changing what a value means, making an optional parameter required.
- Deprecation
- HTTP-datewhen the version was marked to go. It is an HTTP-date, not ISO.
- Sunset
- HTTP-datewhen it stops answering. At least 12 months after the announcement.
Pagination
GET /invoices is paginated with and and query params (default query params (default , max , max ).
The response envelope always includes:
- total
- integertotal rows matching the filters.
- total_pages
- integer
- next_page / prev_page
- integer | null
- data
- arraythe page's rows.
Errors
The API uses standard HTTP status codes. In most cases the response carries a detail. When the SEFAZ or ADN refuses an operation the body also carries an error block, and the status says whose problem it is: 422 the data, 503 try later, 502 the authorizer could not be reached.
Issuing answers 201 Created, not 200. So do invalidating numbering and registering a webhook. Deleting a webhook answers 204, with no body.
Guide:NF-e rejection 539: what it means and how to fix it · NF-e rejection 204: duplicate NF-e, what it means and how to fix it · SEFAZ unavailable: how to confirm it and issue NF-e in contingency
Example response
{
"detail": "This company has no state set — required for NFe. Set it via PATCH /companies/{id}."
}| HTTP | Error | When | Learn more |
|---|---|---|---|
| 400 | Invalid configuration | The issuer's configuration (certificate, address, fiscal fields) is missing or invalid. | |
| 401 | Unauthorized | The Bearer token is missing, expired, invalid, or wasn't created for the host you're calling (api.stackin.io vs sdk.stackin.io). | See details |
| 402 | Quota reached | The company's plan quota for production invoices was reached and the plan has no overage price (trial). | |
| 404 | Not found | No document with that access key or invoice_id belongs to the company behind your key. | |
| 409 | Operation conflict | The requested operation doesn't apply to that document_type (e.g. an nfse-only operation on an nfe). | |
| 422 | Validation error | The request body failed validation — a required field is missing or malformed. | |
| 422 | Rule refused | A rule checked before the SEFAZ refused the document: layout, a cross-field rule or a reference table. detail is an object with code, field and message, and nothing reached the authorizer. | |
| 422 | Authorizer rejectedAuthorizer rejection | The SEFAZ or ADN received the request and refused its data. The body carries code: AUTHORITY_REJECTED, and error carries the authorizer's own code and message, our guidance when we have it, and retryable: false — the same request fails the same way. | See details |
| 429 | Rate limited | Too many calls for this key in the current window. The Retry-After header says how many seconds to wait. | See details |
| 501 | Not implemented | Signing for that document type/country isn't implemented on the server yet. | |
| 502 | Authorizer unreachable | Nobody answered: the authorizer could not be reached or failed on its side (HTTP 5xx), or a step on ours did — no endpoint for that state, the PDF renderer. error.retryable says whether trying again can help. | See details |
| 503 | Authorizer paused | The SEFAZ said it is paused (108, 109) or throttled the company for asking too often (656). The data is fine and error.retryable is true: try again later. | See details |
Rules refused before the SEFAZ
The layout rules, the rules across fields and the reference tables are checked before the document leaves. A refusal answers 422 with detail as an object: code, field, message, and, when they apply, sefaz_rejection, expected and received.
field is the path of the offending value in your request body, for example items[0].product.br.cfop. sefaz_rejection is the SEFAZ cStat the check spares you; it is absent where no single cStat applies.
Layout and cross-field rules used to answer 400 with a plain-text detail. They answer 422 now, so branch on detail.code. The 400 stays for the issuer's own configuration: certificate, address and fiscal fields. This applies to issuing and to reissuing.
{
"detail": {
"code": "CFOP_INCONSISTENT_WITH_DESTINATION",
"field": "items[0].product.br.cfop",
"message": "items[0].cfop='6102' is inconsistent with this invoice's operation type (rejections 518, 519, 731-733).",
"sefaz_rejection": "732",
"expected": "5xxx",
"received": "6102"
}
}Codes and the cStat they spare
- CFOP_INCONSISTENT_WITH_DIRECTION
- 518 or 519
- CFOP_INCONSISTENT_WITH_DESTINATION
- 731, 732 or 733
- RETURN_CFOP_REQUIRES_RETURN_PURPOSE
- 328
- RETURN_PURPOSE_REQUIRES_RETURN_CFOP
- 327
- RETURN_REFERENCED_KEY_REQUIRED
- 321
- MANUFACTURER_CNPJ_CHECK_DIGITS_INVALID
- no cStat
- MANUFACTURER_REQUIRES_CEST
- 225
- MANUFACTURER_CNPJ_REQUIRED
- 879
- MANUFACTURER_CNPJ_ALL_ZEROS
- 489
- NCM_NOT_FULL_CODE
- 777
- NCM_00_ONLY_FOR_SERVICE_LINE
- 471
- DESCRIPTION_TOO_LONG
- 225
- UNIT_TOO_LONG
- 225
- GTIN_FORMAT_INVALID
- 225
- GTIN_CHECK_DIGIT_INVALID
- 611
- RECOPI_NUMBER_INVALID
- 350
- PIS_COFINS_OTHER_BASIS_REQUIRED
- 225
- PIS_GROUP_REQUIRED
- 745
- COFINS_GROUP_REQUIRED
- 748
- EXPORT_ICMS_SITUATION_INVALID
- 527
- FUEL_UNIT_MISMATCH
- 854
- FUEL_ICMS_SITUATION_INVALID
- 960
- CHARACTER_OUTSIDE_LATIN1
- no cStat
- ADDRESS_FIELD_LENGTH_INVALID
- 225
- RECIPIENT_COUNTRY_REQUIRES_STATE_EX
- 511
- RECIPIENT_ABROAD_TAX_ID_NOT_ALLOWED
- 720
- RECIPIENT_ABROAD_COUNTRY_REQUIRED
- 510
- EXPORT_REQUIRED
- 355
- EXPORT_NOT_ALLOWED
- 356
- CONTINGENCY_NOT_AVAILABLE_IN_UF
- no cStat
- CONTINGENCY_REASON_LENGTH_INVALID
- no cStat
- CONTINGENCY_STARTED_AFTER_EMISSION
- no cStat
- GROUP_NOT_IN_LAYOUT
- 225
- PRESENCE_HOME_DELIVERY_NFCE_ONLY
- 794
- PRESENCE_OUTSIDE_REQUIRES_REFERENCE
- 864
- INTERMEDIARY_NOT_ALLOWED_FOR_PRESENCE
- 435
- PAYMENT_NOT_ALLOWED_FOR_PURPOSE
- 871
- NO_PAYMENT_WITH_AMOUNT
- 904
- PAYMENT_DESCRIPTION_REQUIRED
- 441
- PAYMENT_DESCRIPTION_NOT_ALLOWED
- 442
- CARD_NOT_ALLOWED_FOR_METHOD
- 963
- CARD_INTEGRATED_DATA_REQUIRED
- 392
- PAYMENT_CHANGE_REQUIRED
- 866
- PAYMENT_CHANGE_MISMATCH
- 869
Item values
unit_price is the price of one unit. amount is the gross total of the line's products, before discount, freight, insurance and other expenses.
Send either. Sending both asserts they agree: quantity x unit_price is compared with amount and the document is refused before transmission if they differ by more than one cent (a rounding gap is accepted). Decimal values may be sent as strings to keep their precision — unit_price takes up to 10 places.
# unit_price: what one unit costs
{
"description": "Teclado",
"product": { "quantity": 2, "unit": "UN", "br": { "ncm": "84716052", "cfop": "5102" } },
"unit_price": "120.00"
}
# -> qCom 2.0000 vUnCom 120.0000000000 vProd 240.00
# amount: the line's gross total (the original contract)
{
"description": "Teclado",
"product": { "quantity": 3 },
"amount": "50.00"
}
# -> qCom 3.0000 vUnCom 16.6666666667 vProd 50.00
# both, checked against each other before transmission
{
"description": "Teclado",
"product": { "quantity": 2 },
"unit_price": "120.00",
"amount": "240.00"
}When they do not agree the answer is 422, naming the line and both numbers:
{
"detail": {
"code": "ITEM_TOTAL_MISMATCH",
"field": "items[0].amount",
"message": "amount is 50.00, but quantity x unit_price is 150.00. Send only one of them: unit_price with quantity, or amount for the whole line.",
"expected": "150.00",
"received": "50.00"
}
}Also refused: neither field (ITEM_AMOUNT_MISSING), values at or below zero, a discount larger than the gross amount (ITEM_DISCOUNT_EXCEEDS_GROSS) and precision the XML cannot carry (ITEM_PRECISION_UNSUPPORTED). Nothing has to migrate: amount keeps the meaning it always had.
IBS/CBS — tax reform
The tax-reform group, per item. Required from 2026 for the regime normal. cst and classification (cClassTrib) are your fiscal decision; the API derives the amounts from the rates.
The three rates are percentages: rate_state (pIBSUF), rate_city (pIBSMun) and rate_federal (pCBS). base is optional — without it, the base is the item amount. An item without the group emits nothing, which is what an NF-e looked like before the reform.
{
"description": "Teclado",
"unit_price": "120.00",
"product": {
"quantity": 2,
"br": {
"ncm": "84716052",
"cfop": "5102",
"ibs_cbs": {
"cst": "000",
"classification": "000001",
"rate_state": 0.1,
"rate_city": 0.0,
"rate_federal": 0.9
}
}
}
}NFS-e
On an nfse, items[0].product.br.ibs_cbs takes cst, classification (cClassTrib) and operation_indicator (cIndOp, 6 digits, from the NFS-e Anexo VII table, such as 100301). They go into the IBSCBS group of the DPS. The group is optional in 2026 (NT SE/CGNFS-e 004 v2.0, §1.1) and is sent only when ibs_cbs is sent.
{
"document_type": "nfse",
"client_name": "John Doe",
"tax_id": "00000000000",
"items": [
{
"description": "Technical consulting - 10 hours",
"unit_price": "1500.00",
"nbs": "115021000",
"product": {
"br": {
"ibs_cbs": {
"cst": "000",
"classification": "000001",
"operation_indicator": "100301"
}
}
}
}
]
}The Sefin Nacional computes the NFS-e base, rates and amounts itself, so base, rate_state, rate_city, rate_federal, reduction_ibs and reduction_cbs are refused with 422 on an nfse. On an nfe the three rates are still required and operation_indicator is refused.
operation_indicator is mandatory in production (layout v1.01) and optional in homologation (NT 009 layout). Without it in production the API answers 422 IBS_CBS_OPERATION_INDICATOR_REQUIRED. A real-estate indicator (020101, 020201 and 020301, and in homologation also 020202 and 020401) needs the real_estate group: without it the API answers IBS_CBS_REAL_ESTATE_REQUIRED, unless the service is one of the civil-works subitems, which takes nfse.construction instead and refuses real_estate (IBS_CBS_REAL_ESTATE_NOT_ALLOWED).
A classification not allowed on an NFS-e (indNFSe 0 in the cClassTrib table) is refused with 422 IBS_CBS_CLASS_NOT_ALLOWED. Who may send the group depends on the layout of the environment. In production (layout v1.01) an MEI cannot send it (422 IBS_CBS_NOT_FOR_MEI) and an ME/EPP (simples_nacional 3) can only when the company fiscal field simples_apuracao_ibs_cbs is 3; otherwise 422 IBS_CBS_SIMPLES_IN_DAS. In homologation (NT 009 layout), for a competência from 2026-10-01 the layout lists the group as mandatory and every regime may send it; for an earlier competência the production rules apply. Where the layout lists it as mandatory and the item sends none, the NFS-e goes out and the answer carries the warning IBS_CBS_RECOMMENDED.
On an nfse the service's NBS code goes in items[].nbs (DPS cServ/cNBS), beside description and not inside product: nine digits (115021000) or dotted (1.1502.10.00), answered back as nine digits. It is required together with ibs_cbs: a line that carries the group without it is refused with 422 NBS_REQUIRED (ADN rule E0322). A code that is not on the NBS list (NFS-e Anexo B) is refused with 422 NBS_UNKNOWN. With item_id, the catalog item's nbs is used when the line sends none. GET /service-codes/{service_code}/nbs lists the NBS, cIndOp and cClassTrib that Anexo VIII pairs with a service code; they are suggestions, never filled in for you. A catalog service (POST /items) takes nbs too.
The rest of the group is optional: personal_use (indFinal), government (tpOper, tpEnteGov), referenced_nfse (gRefNFSe), recipient (dest), real_estate (imovel), movable_goods (bensMoveis), regular_taxation (gTribRegular), deferral (gDif) and presumed_credit (cCredPres). The API checks each against the service code and the layout and refuses what the ADN would, with IBS_CBS_* codes. Some parts exist in only one layout: real_estate.city_code, lease, more than one unit, base_adjustments and movable_goods exist only in homologation (NT 009), and sent to production they are refused with IBS_CBS_FIELD_LAYOUT_UNSUPPORTED.
NFS-e fields (DPS)
On an nfse the request takes optional DPS fields, beside the ones above. Every one is optional and backward compatible: a request that sends none behaves as it always did. What the ADN would certainly reject is refused with 422 before anything is sent; what is merely missing is a warning. Which fields an MEI cannot send, and why, is under Regime rules.
An NFS-e carries one service. More than one item answers 422 NFSE_SINGLE_ITEM: issue one NFS-e per service.
Per item
- items[].nbs
- string | optionalNBS code of the service (
cServ/cNBS), nine digits or dotted. Required withibs_cbs(422NBS_REQUIRED); a code outside the NBS list isNBS_UNKNOWN. Required for an export (NBS_REQUIRED_FOR_EXPORT). Falls back to the catalog item's withitem_id. - items[].municipal_service_code
- string | optionalThe municipality's own tax code for the service (
cTribMun), three digits. Falls back to the catalog item's withitem_id. An MEI cannot state it:MUNICIPAL_SERVICE_CODE_NOT_FOR_MEI(E0313). - items[].internal_code
- string | optionalThe issuer's own code for the service (
cIntContrib), up to 20 letters or digits. Falls back to the catalog item's withitem_id. - items[].conditional_discount
- number | string | optionalConditional discount in BRL, above 0 and below the service amount (E0432), or
ITEM_CONDITIONAL_DISCOUNT_EXCEEDS_SERVICE. It does not change the ISSQN base. - items[].product.br.ibs_cbs
- object | optionalThe rest of the IBSCBS group:
personal_use,government,referenced_nfse,recipient,real_estate,movable_goods,regular_taxation,deferralandpresumed_credit. See IBS/CBS.
Recipient
- recipient_address.complement
- string | optionalComplement of the address (apartment, suite, block), written as
xCplup to 156 characters on an NFS-e. A longer one is never refused: it is left out of the document and the answer carriesRECIPIENT_COMPLEMENT_OMITTED. - recipient_address.country_iso2, postal_code, province
- string | optionalFor a recipient abroad (
stateEX):country_iso2(ISO 3166 alpha-2, notBR, E0246),postal_codeandprovince, all required.country_codestays the BACEN code the NF-e takes. - foreign_id, foreign_id_missing_reason
- string | integer | optionalFor a recipient abroad,
foreign_id(NIF) orforeign_id_missing_reasonis required (E0223):1exempt from a NIF,2the country does not require one.0is refused (E0226). - recipient_municipal_registration
- string | optionalRecipient's inscrição municipal, up to 15 letters or digits, written as
toma/IM. Refused on an NF-e. Withclient_id, the saved client's is used when this is left out.
The nfse object
Document-level fields go in nfse. Every group is optional.
- nfse.competence_date
- string (date) | optionalCompetência date (
dCompet),YYYY-MM-DD. Left out, the local date of the issuance. After the issuance date:COMPETENCE_AFTER_ISSUANCE(E0015). It also decides the IBS/CBS date rules: before 2026 the group is refused (IBS_CBS_BEFORE_2026, E0850), and in homologation from 2026-10-01 the layout lists it as mandatory (E0855). - nfse.service_city_code
- string | optionalIBGE code (7 digits) of the municipality where the service was performed (
cLocPrestacao). Left out, the company's municipality. A code not in the municipality reference:SERVICE_CITY_NOT_FOUND. Not together withservice_country_code. - nfse.service_country_code
- string | optionalISO 3166 alpha-2 country where the service was performed, instead of
service_city_code;BRis refused (E0304). The NFS-e then needsitems[0].nbs(NBS_REQUIRED_FOR_EXPORT) andforeign_trade(FOREIGN_TRADE_REQUIRED). - nfse.approximate_taxes
- object | optionalApproximate tax burden of Lei 12.741 (
totTrib), overriding the company'sapproximate_tax_*settings. Exactly one shape:simples_percent(ME/EPP only);federal_percent,state_percentandmunicipal_percent; orfederal_amount,state_amountandmunicipal_amount, each at most the service value (APPROXIMATE_TAX_AMOUNT_ABOVE_SERVICE). With none sent and none on the company, the DPS declaresindTotTrib0 and an ME/EPP or non-optante getsAPPROXIMATE_TAXES_MISSING. - nfse.iss
- object | optionalThe ISSQN (
tribMun).taxation:taxable(default),immune(withimmunity_type1 to 5),export(with an optionalresult_country_code) ornot_levied. Only withtaxable:suspension(typejudicial or administrative, 30-digitprocess_number),municipal_benefit(14-digitidand one ofreduction_amountorreduction_percent) andrate(above 0, at most 5, overriding the company'siss_rate).retention:none,tomadororintermediary, which needsnfse.intermediarywith atax_idand an address in Brazil (ISS_RETENTION_INTERMEDIARY_REQUIRED). Left out,items[0].tax_retaineddecides; sent together they must agree (ISS_RETENTION_CONFLICT). - nfse.federal
- object | optionalFederal taxes (
tribFed):pis_cofins(cst, and optionallybase,pis_rate,cofins_rate,pis_amount,cofins_amountandwithholding_type) and the amounts withheldsocial_security_withheld,irrf_withheldandsocial_contributions_withheld, each above 0 and below the service value. Left out, the DPS carries notribFed. - nfse.deductions
- object | optionalDeduction or reduction of the ISSQN base:
percentoramount, anddocuments(1 to 1000), each with atype, exactly one identification (nfse_key,nfe_key,cte_key,municipal_nfse,paper_invoice,fiscal_document,other_documentorother_dfe),issue_date,total_amountanddeducted_amount. Written asvDedRedin production, where the documents replacepercentandamount, and asvAjusteBCin homologation (NT 009), where they can go beside either.other_dfe(keyanddescription) exists only in homologation (NT 009). A document type the environment's layout lacks isDEDUCTIONS_LAYOUT_UNSUPPORTED. The municipality decides which deductions it admits for each service code. - nfse.substitution
- object | optionalIssues this NFS-e in place of an authorized one:
access_key(50 characters, of this company and environment, authorized and not cancelled),reason_code(01,02,03,04,05or99) andreason(15 to 255 characters, required with99). Refused withSUBSTITUTED_NFSE_NOT_FOUND,SUBSTITUTED_NFSE_OTHER_ENVIRONMENT,SUBSTITUTED_NFSE_NOT_AUTHORIZED,SUBSTITUTED_NFSE_CANCELLEDorSUBSTITUTED_NFSE_KEY_MISMATCH, and, when a field the ADN freezes changed,SUBSTITUTION_COMPETENCE_CHANGED,SUBSTITUTION_SERVICE_CHANGED,SUBSTITUTION_RECIPIENT_CHANGEDorSUBSTITUTION_AMOUNT_CHANGED. A competência left out is taken from the substituted NFS-e. Once the new one is authorized, the old one is stored as cancelled and itssubstituted_by_invoice_idinGET /invoicespoints at the new one. - nfse.construction
- object | optionalThe construction the service is for (
obra):work_id_type(cnoorcib) withwork_id, or anaddress, and optionallyproperty_registration. The ADN requires it for some services (E0370): left out, the answer carriesCONSTRUCTION_RECOMMENDED; sent for another service,CONSTRUCTION_NOT_ALLOWED. - nfse.event
- object | optionalThe activity or event the service is for (
atvEvento):name,start_date,end_dateand anevent_idor anaddress. The ADN requires it for item 12 of the service list (E0390): left out,EVENT_RECOMMENDED; sent for another service,EVENT_NOT_ALLOWED. - nfse.references
- object | optional
order_number(xPed),order_items(up to 99),reference_document(docRef) andtechnical_document(idDocTec: ART, RRT, DRT), beside the free text initems[].observations. - nfse.intermediary
- object | optionalWho intermediated the service: exactly one of
tax_id,foreign_id(NIF) orforeign_id_missing_reason, plusname, anaddress(in Brazil, or abroad, which a NIF or a missing reason requires) and optionallycaepf,municipal_registration,phoneandemail. Itstax_idcannot share the company's CNPJ root (INTERMEDIARY_IS_ISSUER). One abroad makes the NFS-e an export, which needsitems[0].nbsandforeign_trade. - nfse.provider
- object | optionalWhat the company adds to the DPS
prest:caepf(14 digits),phoneandemail, all optional. The company's name and address are not taken: the ADN refuses them when the company issues the DPS (E0121, E0128). A phone or e-mail the layout cannot carry is left out of the document. - nfse.recipient_caepf
- string | optionalThe tomador's CAEPF (
toma/CAEPF), 14 digits. Optional. - nfse.foreign_trade
- object | optionalA service traded with someone abroad (
comExt):service_mode,relationship,currency_code,foreign_amount,provider_support,recipient_support,temporary_goods(withimport_declarationorexport_registrationas it says) andshare_with_mdic. Required when the tomador or the intermediary is abroad orservice_country_codeis sent (FOREIGN_TRADE_REQUIRED). Sent for a service with no one abroad and no export:FOREIGN_TRADE_NOT_FOREIGN.
Company fiscal fields
Defaults the company keeps for every NFS-e, set in fiscal_fields of PATCH /company (owner only) or under Management → Settings → Company details in the dashboard. An empty string clears one.
- approximate_tax_*_percent
- string | optionalDefaults of the approximate taxes (Lei 12.741) when the request sends no
nfse.approximate_taxes:approximate_tax_simples_percent(ME/EPP only, 0 to 99.99) andapproximate_tax_federal_percent,approximate_tax_state_percentandapproximate_tax_municipal_percent(0 to 100), two decimals. - municipal_registration
- string | optionalThe provider's inscrição municipal, up to 15 characters, written as
prest/IM. The ADN requires it when the municipality holds the provider in its complementary registry (E0116) and rejects it when it does not (E0120). An MEI's is never sent. - special_tax_regime
- string | optional
regEspTrib:0none (default),1cooperative,2estimativa,3municipal microenterprise,4notary or registrar,5self-employed professional,6society of professionals,9other. An MEI (E0174) and an ME/EPP withsimples_apuracao1 (E0175) take only0: another value is refused with422when written. - iss_rate
- string | optionalThe ISSQN rate in percent, above 0 and at most 5 (E0595): the
pAliqwhen the request sends nonfse.iss.rate. Written on a taxable NFS-e only where the layout takes a rate: never for an MEI or under a special tax regime, and for an ME/EPP paying the ISSQN in the Simples only when it is retained. - nfse_recipient_cpf_address
- string | optionalWhether the NFS-e carries the address (
toma/end) of a recipient identified by CPF:1sends it (default, also when unset),0leaves it out, which avoids the ADN rejection E0245 when the address city does not match the CPF registry. The address is still sent when the ISSQN is retained by the tomador (E0237) or the IBS/CBS operation places the supply at the tomador's address (E0243). A CNPJ recipient and one abroad are not affected; the address stays on the client and the invoice. An empty string clears it.
Regime rules
The regime belongs to the company (see Tax regimes). Each refusal below is 422 with detail.code, detail.field and detail.message, answered before anything is sent, numbered or charged; the rule code in parentheses is the ADN rule that would reject the DPS.
- MEI (simples_nacional 2)
- The ADN refuses these in an MEI's DPS, so the API refuses them first: the IBS/CBS group where the layout does not list it as mandatory (
IBS_CBS_NOT_FOR_MEI);nfse.deductions(DEDUCTIONS_NOT_FOR_MEI, E0436);nfse.federal(FEDERAL_TAXES_NOT_FOR_MEI, E0676);nfse.iss.rate(ISS_RATE_NOT_FOR_MEI, E0600);nfse.iss.municipal_benefit(ISS_BENEFIT_NOT_FOR_MEI, E0534);nfse.approximate_taxes.simples_percent(APPROXIMATE_TAXES_SIMPLES_NOT_FOR_MEI, E0710);items[].municipal_service_code(MUNICIPAL_SERVICE_CODE_NOT_FOR_MEI, E0313); and ISSQN retention (MEI_ISS_NOT_RETAINED, E0583). Left out, an MEI declaresindTotTrib0; its municipal registration is never sent and itsregEspTribis always 0. - ME/EPP (simples_nacional 3)
- With
simples_apuracao1, the default, the ISSQN is paid in the Simples:nfse.iss.rategoes only with retention (ISS_RATE_WITHOUT_RETENTION, E0625), and a retained ISSQN without a rate getsISS_RATE_REQUIRED_WITH_RETENTION; the special tax regime is always 0 (E0175);nfse.deductionsonly for the service codes Anexo I lists (DEDUCTIONS_NOT_FOR_SIMPLES_SERVICE). The IBS/CBS group follows the layout rule above:IBS_CBS_SIMPLES_IN_DASunlesssimples_apuracao_ibs_cbsis 3.simples_percentof the approximate taxes is accepted only for this regime. - Not in the Simples (simples_nacional 1)
nfse.approximate_taxes.simples_percentis refused (APPROXIMATE_TAXES_SIMPLES_NOT_FOR_NON_OPTANTE, E0713); send the federal, state and municipal percentages or amounts.nfse.iss.rate, or the company'siss_rate, is written on a taxable NFS-e.- Special tax regime (company special_tax_regime other than 0)
- The DPS takes no ISSQN retention (E0588), rate (
ISS_RATE_SPECIAL_REGIME, E0604), municipal benefit (ISS_BENEFIT_SPECIAL_REGIME, E0535) or deduction (DEDUCTIONS_SPECIAL_REGIME, E0438); a regime the ADN would reject for the company is not sent and the answer carriesSPECIAL_TAX_REGIME_IGNORED.
Warnings and refusals
A refusal stops the issuance and names the rule. A warning never does: 201 carries it in warnings, in the shape of POST /invoices/validate, for what is missing and the ADN may reject the document for. POST /invoices/validate returns both without sending anything.
- APPROXIMATE_TAXES_MISSING
- An ME/EPP or a non-optante with no approximate taxes in the request or on the company: the DPS declares
indTotTrib0 and the ADN may reject it (E0712, E0713). - IBS_CBS_RECOMMENDED
- An item without
ibs_cbswhere the layout lists the group as mandatory: in homologation, a competência from 2026-10-01 (E0855). The NFS-e goes out without it. - IBS_CBS_OPERATION_TYPE_RECOMMENDED
- A service of LC 116 subitem 10.05, 15.09, 17.12 or 25.05 without
government.operation_type(E0903). - IBS_CBS_MOVABLE_GOODS_RECOMMENDED
- The lease of movable goods (99.04.01) in homologation without
movable_goods(E0963). - IBS_CBS_DEFERRAL_RECOMMENDED
- A CST that allows deferral without
deferral(E0972). - CONSTRUCTION_RECOMMENDED
- A service the ADN requires
nfse.constructionfor, sent without it (E0370). - EVENT_RECOMMENDED
- An item 12 service sent without
nfse.event(E0390). - FOREIGN_TRADE_RECOMMENDED
nfse.iss.taxationexport, with no one abroad, sent withoutnfse.foreign_trade.- ISS_RATE_REQUIRED_WITH_RETENTION
- An ME/EPP in the Simples with the ISSQN retained and no rate (E0621, E0628).
- RECIPIENT_COMPLEMENT_OMITTED
- A recipient complement longer than the layout takes, left out of the document.
- SPECIAL_TAX_REGIME_IGNORED
- The company's special tax regime was not sent because the ADN would reject it for this company; the DPS declares 0.
- MUNICIPAL_REGISTRATION_IGNORED
- The company's municipal registration was not sent because the company is an MEI.
Sale terms: presence, transport and payment
An NF-e can say how the sale happened: how the buyer took part (presence), the marketplace it went through (intermediary), the freight and its volumes (transport), and how it was paid (payments and change). They are NF-e only: on an nfse request any of them is refused with 422.
Every field is optional. Left out, the note is the same as before these fields existed: presence 9, no intermediary, freight mode 9 with no volume, and one payment of method 90 (no payment) for 0.00. Send a group only when the sale has something to say about it.
When to send each group
- presence
- How the buyer took part in the sale. An online store sends
2. Left out:9. - intermediary
- Only when a marketplace or platform brokered the sale: its CNPJ and the seller's identifier there. Left out, the sale is written as made on your own site or store.
- transport
- Who arranges the freight and the packages carried. Left out: freight mode
9and no volume. The freight value itself stays on each line'sproduct.freight. - payments
- How the buyer paid, up to 100 entries. Left out: one payment of method
90for0.00. - change
- Only when the payments add up to more than the note's total.
- items[].product.net_weight / gross_weight
- Weight in kg of one unit of the line. Used to build the volume when
transportis sent withoutvolumes.
E-commerce example
An online sale shipped with the seller paying the freight and paid by dynamic PIX: presence 2, freight mode 0 and a payment of method 17.
{
"document_type": "nfe",
"client_name": "Buyer Company Ltd",
"tax_id": "11222333000181",
"presence": "2",
"transport": { "freight_mode": "0" },
"payments": [{ "method": "17", "amount": "224.88" }],
"items": [
{
"description": "Rosa Holambra Vermelha",
"unit_price": "112.44",
"product": {
"quantity": 2,
"net_weight": 0.35,
"gross_weight": 0.4,
"br": { "ncm": "06031100", "cfop": "5102" }
}
}
],
"recipient_address": {
"street": "Rua das Flores",
"number": "1200",
"neighborhood": "Centro",
"city": "Joinville",
"state": "SC",
"zip_code": "89201100",
"city_code": "4209102"
}
}The body above is accepted as is. The line weighs 0.35 kg net and 0.4 kg gross per unit, so the note carries one volume of 0.700 kg net and 0.800 kg gross.
Code tables
presence
- 0
- Not applicable (complementary or adjustment note)
- 1
- In person
- 2
- Internet
- 3
- Telephone
- 5
- In person, outside the establishment
- 9
- Other, non-presential
4 (home delivery) is the NFC-e's and is refused on an NF-e. 5 needs the note it follows in referenced_keys.
transport.freight_mode
- 0
- The seller contracts the freight (CIF)
- 1
- The buyer contracts the freight (FOB)
- 2
- A third party
- 3
- The seller carries it
- 4
- The buyer carries it
- 9
- No transport
payments[].method
- 01
- Cash
- 02
- Check
- 03
- Credit card
- 04
- Debit card
- 05
- Store credit card
- 10
- Food voucher
- 11
- Meal voucher
- 12
- Gift voucher
- 13
- Fuel voucher
- 14
- Trade bill (duplicata mercantil)
- 15
- Boleto
- 16
- Bank deposit
- 17
- PIX, dynamic
- 18
- TED
- 19
- Loyalty program, cashback, virtual credit
- 20
- PIX, static
- 21
- Store credit
- 22
- Electronic payment not reported (issuing system hardware failure)
- 23
- PIX, automatic
- 24
- TEF "Book Transfer" (between accounts of the same bank)
- 90
- No payment (amount 0)
- 91
- Paid later
- 99
- Other (needs description)
Any code outside the national table is refused.
payments[].card.integration
- 1
- Integrated with the seller's system (TEF, e-commerce); needs tax_id and authorization
- 2
- Not integrated (stand-alone POS)
The card group is only accepted for methods 03, 04, 10, 11, 12, 13, 15, 17, 18.
{
"payments": [
{
"method": "03",
"amount": "224.88",
"card": {
"integration": "1",
"tax_id": "11444777000161",
"brand": "01",
"authorization": "123456"
}
}
]
}payments[].card.brand
- 01
- Visa
- 02
- Mastercard
- 03
- American Express
- 06
- Elo
- 07
- Hipercard
- 99
- Other
The API accepts the codes 01 to 27 and 99 of the national card brand table.
Marketplace sales
intermediary.tax_id is the platform's CNPJ, with or without punctuation, and its check digits are verified. identifier is the seller's user name or profile at the platform, 2 to 60 characters. It is accepted with presence 1, 2, 3 or 9.
{
"presence": "2",
"intermediary": {
"tax_id": "11444777000161",
"identifier": "loja-da-ana"
}
}Change
When the payments exceed the note's total, send change with exactly the difference, up to R$ 300,000.00. Here the total is R$ 224.88 and the buyer handed over R$ 250.00.
{
"payments": [{ "method": "01", "amount": "250.00" }],
"change": "25.12"
}Volume derived from the item weights
Send transport without volumes and, when every goods line carries product.net_weight, the API writes one volume with quantity 1 and the sum of quantity × net_weight over the lines. gross_weight is summed the same way, on its own: a weight missing from one goods line leaves that weight out of the volume.
{
"quantity": 1,
"net_weight": "0.700",
"gross_weight": "0.800"
}Send volumes to describe the packages yourself (quantity, species, brand, numbering, net_weight and gross_weight in kg, up to 3 decimal places); an empty list writes none. Without transport, no volume is written.
Rules checked before the SEFAZ
These refuse the document with 422 and a detail.code before anything is sent, and POST /invoices/validate lists them. The number is the SEFAZ rejection each one spares you.
- PRESENCE_HOME_DELIVERY_NFCE_ONLY
- 794Presence 4 is for an NFC-e. An NF-e shipped to the buyer is 2, 3 or 9.
- PRESENCE_OUTSIDE_REQUIRES_REFERENCE
- 864Presence 5 needs the note it follows in referenced_keys.
- INTERMEDIARY_NOT_ALLOWED_FOR_PRESENCE
- 435An intermediary only goes with presence 1, 2, 3 or 9. Left out, presence counts as 9.
- PAYMENT_NOT_ALLOWED_FOR_PURPOSE
- 871An adjustment or return note carries method 90 only.
- NO_PAYMENT_WITH_AMOUNT
- 904Method 90 takes amount 0.
- PAYMENT_DESCRIPTION_REQUIRED
- 441Method 99 needs a description of the method used.
- PAYMENT_DESCRIPTION_NOT_ALLOWED
- 442description is only for method 99.
- CARD_NOT_ALLOWED_FOR_METHOD
- 963The card group only goes with the card methods listed above.
- CARD_INTEGRATED_DATA_REQUIRED
- 392Integration 1 needs card.tax_id and card.authorization.
- PAYMENT_CHANGE_REQUIRED
- 866Payments above the note's total need change.
- PAYMENT_CHANGE_MISMATCH
- 869change must be exactly what the payments exceed the total by.
Values refused by the request schema
These are refused with 422 as an invalid value: the answer names the field. The number is the SEFAZ rejection each one spares you.
- intermediary.tax_id
- 440
- payments[].card.tax_id
- 437
- payments[].method
- 436
- payments[].card.brand
- 443
- change
- 965
Tax regimes
The regime belongs to the company, not to the request. An NF-e reads tax_regime (the CRT) and an NFS-e reads simples_nacional (the opSimpNac), both from the company's fiscal_fields, set under Management → Settings → Company details in the dashboard at app.stackin.io. Unset, the NF-e goes out with CRT 3 and the NFS-e with opSimpNac 1.
Each row cites the official rule and the rejection it produces: the NF-e Anexo I (MOC 7.00) and the NFS-e Anexo I (SEFIN/ADN, v1.01). A rule marked “Facul.” in the Anexo is optional: each UF decides whether to apply it, so the same document can be authorized in one state and rejected in another.
NF-e — tax_regime (CRT)
- CRT 1
- Simples NacionalICMS goes in a CSOSN group (
IcmsSn101toIcmsSn900, Anexo I groups N10c to N10h, “Grupo CRT=1”). A CST with CRT 1 is rule N12-20, rejection 590 — Facul., per UF. - CRT 2
- Simples Nacional, gross revenue above the sublimitRule N12a-10 rejects a CSOSN for any CRT other than 1 (591 — Facul., per UF); N12-20 rejects a CST only for CRT 1. A UF may also refuse CRT 2 itself: rule C21-10, rejection 812 — Facul., per UF.
- CRT 3
- Regime normalICMS goes in a CST group (
Icms00toIcms90, Anexo I groups N02 to N10). A CSOSN with CRT 3 is rule N12a-10, rejection 591 — Facul., per UF. - CRT 4
- Simples Nacional — MEIAccepted by the current schema (
leiauteNFe_v4.00.xsd, PL_010h). Anexo I 7.00 predates this value and names no group for it; its rule N12a-10 is written for every CRT other than 1 (591 — Facul., per UF).
Send the regime the SEFAZ has on file: a CRT that differs from the state register is rule 7C21-10, rejection 481 — Facul., per UF.
NFS-e — simples_nacional (opSimpNac)
The value must match the Simples Nacional register on the DPS competence date, or the ADN answers E0160.
- opSimpNac 1
- Not opted inAlso the value for a CNPJ that is not in the Simples Nacional register (E0160).
- opSimpNac 2
- Opted in — MEIISSQN cannot be retained (E0583). Since v0.8.0 the API refuses
tax_retained: truefor an MEI before the ADN, with422andMEI_ISS_NOT_RETAINED. The special taxation regime must be “none” (E0174); the API always sendsregEspTrib0. - opSimpNac 3
- Opted in — ME/EPPMicro or small company in the Simples Nacional (Anexo I, field opSimpNac).
In production (layout v1.01) an ME/EPP may send the IBS/CBS group on an nfse only when the company fiscal field simples_apuracao_ibs_cbs is 3 (IBS and CBS at the regular regime, outside the DAS); 1, the default, means they are paid in the DAS. Set it under Management → Settings → Company details in the dashboard or in fiscal_fields of PATCH /company (owner only). The NFS-e layouts in force have no field for it, so it is not written into the DPS. In production an MEI cannot send the group. In homologation (NT 009 layout), for a competência from 2026-10-01 the layout lists the group as mandatory and every regime may send it.
Invoices
Issue an invoice
Issues a new document. On an nfe, items[].product.br (ncm, cfop) is required. On an nfse a service has no tax classification code, so the rest comes from description and amount of each item; items[].product.br.ibs_cbs and the DPS fields of NFS-e fields are optional.
The 201 answers {"result", "warnings"}. warnings is [] when there is nothing to report, and otherwise lists activity findings that did not stop the issuance, in the shape of POST /invoices/validate. See Validate an invoice.
Optional request fields
Beyond the required fields, the request accepts these. Where a field is marked nfe only, it applies to the NF-e alone.
- discount
- number | string | optionalA discount on the whole document, in BRL. Spread over the lines in proportion to each line's amount after its own discount, rounded to cents, adding up to exactly this value.
- issued_at
- string (date-time) | optionalEmission date-time (
dhEmi), ISO 8601 with a timezone offset; a value without one is refused. Defaults to now. nfe: at most 30 days in the past (cStat 228) and 5 minutes in the future (cStat 703), also withcontingency: true. nfse: not in the future (E0008). Not stored: a reissue uses now unless it is sent again. - contingency_started_at
- string (date-time) | optionalWhen the issuer entered contingency, ISO 8601 with a timezone offset; only with
contingency: true. Written as the NF-e'side/dhContin the issuer's local offset. Defaults to the document'sdhEmi, and may not be later thanissued_at(or than now when it is left out). - contingency_reason
- string | optionalWhy the issuer entered contingency, 15 to 256 characters on one line; only with
contingency: true. Written as the NF-e'side/xJust. Defaults to “Ambiente normal de autorização da SEFAZ de origem indisponível”. - purpose
- enum | optionalWhy the NF-e is issued (
finNFe):normal,complementary,adjustmentorreturnof goods. Defaults tonormal. nfe only. - direction
- enum | optional
outfor an outgoing NF-e (tpNF=1, CFOP 5/6/7);infor an incoming one the company issues itself, such as a sale returned by the buyer (tpNF=0, CFOP 1/2/3). Defaults toout. nfe only. - referenced_keys
- string[] | optionalAccess keys of the NF-e this one refers to (
refNFe): the note being returned, complemented or adjusted. Required forpurpose=complementary(exactly one) and, except for CFOPs 1201, 1202, 1410, 1411, 5921 and 6921, forpurpose=return. nfe only. - foreign_id
- string | optionalPassport or other document of a buyer abroad (
idEstrangeiro): 5 to 20 letters, digits or:.+-/(). Only withrecipient_address.stateEX; may be left out. - export
- object | optionalWhere the goods leave Brazil:
exit_state(a Brazilian state, never EX),placeanddispatch_place. Required for an nfe to a recipient abroad, refused otherwise. - recipient_address.country_code
- string | optionalBACEN country code (e.g. 2496 United States, 0639 Argentina). Brazil (1058) when omitted; required, and not 1058, when
stateis EX.country_nameis printed beside it. - items[].product.br.fuel
- object | optionalThe NF-e fuel group (
comb), needed for a fuel CFOP — without it the SEFAZ answers 660. Carriesanp_code(cProdANP),anp_description,consumer_stateand, for GLP, its percentages. - items[].product.br.presumed_credits
- object[] | optionalPresumed credits of the item (
cCredPresumido), up to 4, each withcode,percentageandamount. nfe only. Thecodeis checked against the cBenef table of the issuer's state, as in force on the issue date: a code the table lacks, or one outside its validity, is refused with422anddetail.codePRESUMED_CREDIT_CODE_INVALID_FOR_UF(detail.fieldnames the credit), without calling the SEFAZ, which would answer 664 (NT 2019.001, rule I05h-10). Only SC has that table today; for an issuer in any other state the codes go through unchecked. - external_reference
- string | optionalYour own id for this document — an order number, a ticket. Stored as sent, returned on every read and webhook, and filterable on
GET /invoices. - client_id
- string (uuid) | optionalA saved client of the company (see Clients). Its name,
tax_id,foreign_id, address, e-mail and phone fill whatever the request leaves out; what the request sends wins.404when the company has no such client,422when it is deactivated. - update_client
- boolean | optionalAfter an authorized issuance, a new recipient is saved as a client. An existing client is only rewritten with this request's data when this is
true; otherwise only the use is counted. Default:false. - client_email
- string (email) | optionalRecipient's e-mail. Left out with a
client_id, the saved client's e-mail is used. Kept on the invoice and sent again on a reissue. Written into the document asdest/emailon an NF-e (up to 60 characters) andtoma/emailon an NFS-e (up to 80); a longer one, or one with characters beyond Latin-1, is left out of the document and the issuance goes on. Also saved on the client created after an authorized issuance; on an existing client only withupdate_clientset totrue, and only the value sent — left out, the saved e-mail stays. A reissue does not touch the client. - client_phone
- string | optionalRecipient's phone: 8 to 15 digits with an optional leading
+; spaces, dots, dashes and parentheses are dropped. Falls back to the saved client's phone with aclient_id, and is kept on the invoice and the client, the same way asclient_email. Written into the document as digits only, area code first (a+55is dropped unless the recipient is abroad):dest/enderDest/foneon an NF-e, up to 14 digits and only with arecipient_address, andtoma/foneon an NFS-e, up to 20; a longer one is left out of the document and the issuance goes on.
List invoices
Lists the company's issuance history, paginated (see Pagination above). Filter with document_type and status (issued, rejected, cancelled).
fields=summary leaves items and fiscal_operation null on every row, about a tenth of the size. Consult one document for its lines.
Consult an invoice
Looks up a document's current status directly at the authorizer by its access key. Requires as a query param.
Consult by DPS id
Looks up an NFS-e when you only know the DPS id, for example the document_id of a 502 OUTCOME_UNKNOWN. It asks the national authority whether that DPS issued a note and answers like the consult by access key, plus the note's access_key. The id must be your company's own (its CNPJ or CPF and municipality are part of it), otherwise 400. A 404 means the authority has no note for that DPS. If the authority holds the note as cancelled, the answer carries status cancelled.
Cancel an invoice
Cancels a previously authorized document. must be at least 15 characters for nfe (the authorizer's xJust field requires it). Cancelling doesn't refund plan quota — the authorizer capacity was already spent on issuance.
Reissue invoice
Retries a failed submission by the document's local `id` (not its access key — a rejected invoice doesn't have one). Useful for retrying after fixing a configuration problem or an authorizer outage. Consumes credit like a fresh issuance, since it's a new transmission.
Correct invoice
Guide:NF-e correction letter (CC-e): what can be corrected, deadline, how-to
Corrects an already-authorized document with a correction letter (CC-e), without cancelling and reissuing — it consumes no credit and burns no series number. It covers mistakes that don't change the tax: a product name, transport details, extra information.
The text runs 15 to 1000 characters. A CC-e cannot fix anything that changes the tax owed, the seller, the buyer, or the issue date — those still mean cancelling and reissuing. The original document doesn't change: the correction is attached to it. At most 20 per document, numbered for you. NF-e only; NFS-e answers 409.
Invalidate range
Guide:Invalidating NF-e numbers at the SEFAZ: when and how
NF-e numbering is sequential and the SEFAZ expects it to have no gaps. The number is reserved the moment issuing starts, so a submission that fails afterwards — a rejection, a timeout — leaves a hole in the series. Invalidating the range is how that hole gets closed.
The reason runs 15 to 255 characters and the range is inclusive. A number that already reached the SEFAZ can't be invalidated: we check our own records first and answer 409 naming them, without a round trip — and the SEFAZ checks again for what we can't see from here. NF-e only, and no access key: there is no document to point at. Use GET /invoices/invalidations to list the ranges already reported.
In AC, BA and SP there is nothing to invalidate. Since 2026-11-01 the Pedido de Inutilização no longer applies there (Ajuste SINIEF 40/26), and the SEFAZ turned the service off (NT 2023.002 v1.02). For an issuer in one of those states we answer 422 with detail.code INVALIDATION_NOT_AVAILABLE_IN_UF, without calling the SEFAZ: a gap in the numbering there needs no filing, and the SEFAZ no longer refuses a number there for having been invalidated. If any other state answers that the service is off (rejection 998 or HTTP 404), the answer is a 422 with error.code INVALIDATION_SERVICE_DISABLED and retryable: false.
Document PDF
The printed representation the authorizer generates — DANFE for NF-e, DANFSe for NFS-e. Returns raw bytes, the only method that does not return an object: write it to a file or serve it directly.
The XML remains the legally valid document; the PDF is a convenience. The authorizer’s endpoint for it is unstable, so a 502 here means the authorizer is unavailable, not that the invoice is wrong.
Attempts
Every attempt made for one invoice and what came back from the authorizer. consult gives the status; this gives the reason — the rejection code and the XML that was sent.
It takes the invoice_id, not the access key: a rejected document never had one. This is how you find out that a rejection was, say, 972.
Received invoices
Documents other companies issued against your tax id. It reads what the API already collected — it does not call the authorizer on the spot.
Collection runs on a schedule on the API side because the SEFAZ caps how many times a tax id may ask per day. Reading here does not spend that quota.
GET /received-invoices/{access_key}/xml returns the full XML (procNFe) as application/xml, in the key's environment. Downloading is not charged: a received document is billed once, when it is stored.
Before a manifestation the SEFAZ delivers only the summary (resNFe); then the answer is 409 with RECEIVED_XML_NOT_AVAILABLE and the manifestation path. The full XML arrives on a later distribution read, after a ciência or confirmação. A document past the allowance with a negative balance answers 402 RECEIVED_PAYMENT_REQUIRED until a top-up.
Manifestation
Guide:NF-e Recipient Manifestation: events, deadlines and XML download
The recipient’s formal answer: confirmation, acknowledgement, unknown operation or operation not performed.
Only operation not performed takes a reason — and it requires one. The SDK checks that before leaving your machine, rather than spending a round trip to be told.
Clients
Each company keeps the recipients it issues to: one client list per company, the same one the dashboard shows. A client carries a name, a CPF/CNPJ (or a foreign_id, for a buyer abroad), state and municipal registrations, e-mail, phone, address and notes, plus source, uses_count and last_used_at, which say where it came from and how much it has been used. The list is company data: with a credential that covers several companies, it follows the chosen company, like the documents do.
GET /clients lists the active clients by name, in the same envelope as GET /invoices. search matches part of the name, the CPF/CNPJ (with or without punctuation) or the foreign_id; source and is_active filter; offset, limit, sort_by (name, last_used_at, created_at, uses_count) and order_by page as on the invoice listing. GET /clients/{id} reads one client, active or not.
POST /clients creates one under the issuance's own rules: the CPF/CNPJ check digits are verified (alphanumeric CNPJ included), a Brazilian client needs a tax_id, and foreign_id is only accepted with address.state EX. A CPF/CNPJ the company already has answers 409 CLIENT_EXISTS with the existing client's client_id: read or reactivate that one instead of searching for it.
PATCH /clients/{id} changes only the fields sent; null clears a field and address replaces the whole address. The result is validated as a whole, so removing a Brazilian client's tax_id answers 422. DELETE /clients/{id} deactivates, it does not erase: the client leaves the listing, stays readable by id and keeps holding its CPF/CNPJ. PATCH with is_active true brings it back.
curl -X POST https://api.stackin.io/api/v1/clients \
-H "Authorization: Bearer $STACKIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Buyer Company Ltd",
"tax_id": "11.222.333/0001-81",
"state_registration": "123456789",
"email": "purchasing@buyer.com.br",
"address": {
"street": "Rua das Flores",
"number": "1200",
"neighborhood": "Centro",
"city": "Sao Paulo",
"state": "SP",
"zip_code": "01001000",
"city_code": "3550308"
}
}'{
"id": "0b6c3d1e-7a2f-4e59-9c10-5d8e2f3a4b6c",
"company_id": "6f1c2a9e-3b7d-4c21-9a8e-2d5f0b6c7e14",
"name": "Buyer Company Ltd",
"tax_id": "11222333000181",
"foreign_id": null,
"state_registration": "123456789",
"municipal_registration": null,
"email": "purchasing@buyer.com.br",
"phone": null,
"address": {
"street": "Rua das Flores",
"number": "1200",
"neighborhood": "Centro",
"city": "Sao Paulo",
"state": "SP",
"zip_code": "01001000",
"city_code": "3550308"
},
"notes": null,
"source": "manual",
"last_used_at": null,
"uses_count": 0,
"is_active": true,
"created_at": "2026-11-17T12:00:00Z",
"updated_at": "2026-11-17T12:00:00Z"
}{
"detail": {
"code": "CLIENT_EXISTS",
"message": "This company already has a client with tax_id 11222333000181.",
"client_id": "0b6c3d1e-7a2f-4e59-9c10-5d8e2f3a4b6c"
}
}Issuing to a saved client
On POST /invoices, client_id fills whichever of client_name, tax_id, foreign_id and recipient_address the request leaves out; what the request sends wins, and an explicit null counts as sent. The client's state registration goes into the address when the address has none, and client_name is no longer required. The merged request is validated again, so a client without an address on an NF-e gets the usual 422. A client_id that is not the company's answers 404 CLIENT_NOT_FOUND; a deactivated client, 422 CLIENT_INACTIVE.
After an authorized issuance, the recipient is saved as a client when it is new, recognized by its CPF/CNPJ or, for a buyer abroad, by its foreign_id or its name. An existing client only gains one more use and a new last-used date; name, address and registration are rewritten only with update_client on. A rejected issuance saves and counts nothing, a replay with the same idempotency key counts no extra use, and a failure while saving the client never fails the issued document. A deactivated client is counted and stays deactivated.
curl -X POST https://api.stackin.io/api/v1/invoices \
-H "Authorization: Bearer $STACKIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document_type": "nfse",
"client_id": "0b6c3d1e-7a2f-4e59-9c10-5d8e2f3a4b6c",
"items": [
{ "description": "Consultoria em sistemas", "amount": "1500.00" }
]
}'- source
- manual | issued | issuancewhere the client came from:
manual, created byPOST /clientsor in the dashboard;issued, imported in the dashboard from documents already issued;issuance, saved on its own after an issuance. - invoice:read
- scope
GET /clientsandGET /clients/{id}. An API key has every permission. - invoice:issue
- scope
POST,PATCHandDELETEon/clients. There is no separate client permission: whoever may issue may manage the clients issuing creates. - 409
- CLIENT_EXISTSthe company already has a client, active or deactivated, with that CPF/CNPJ or
foreign_id.detail.client_idnames it. - 404
- CLIENT_NOT_FOUNDthe company has no client with that id. It is also the answer for another company's client.
- 422
- CLIENT_INACTIVE
POST /invoiceswith theclient_idof a deactivated client. Reactivate it before issuing.
Validate an invoice
POST /invoices/validate takes the same body as POST /invoices and runs every check that runs before the document is sent, then stops. Nothing is sent to the SEFAZ or the ADN, no number is taken, nothing is stored and nothing is charged.
200 answers {"valid": true, "warnings": []}. 422 answers {"valid": false, "detail", "errors", "warnings"}: detail is exactly what POST /invoices would answer, so code that reads detail.code treats both routes the same, and errors lists what was found.
A reference table (NCM, CEST, cCredPresumido, IBS/CBS) reports its first refusal. The layout and cross-field rules report every one found, one per broken line and rule.
warnings lists the defaults the company would declare, such as tax_regime_default, simples_nacional_default and service_code_default, and the activity findings below. Each item has code, message and field.
The scope is invoice:read, so an app that can read can check a draft without being allowed to issue. The limit is 120 calls per minute, counted apart from issuing.
curl -X POST https://api.stackin.io/api/v1/invoices/validate \
-H "Authorization: Bearer $STACKIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document_type": "nfe",
"client_name": "Buyer Company Ltd",
"tax_id": "11222333000181",
"items": [
{
"description": "Rosa Holambra Vermelha",
"unit_price": "112.44",
"product": {
"br": { "ncm": "06031100", "cfop": "5102" }
}
}
],
"recipient_address": {
"street": "Rua das Flores",
"number": "1200",
"neighborhood": "Centro",
"city": "Joinville",
"state": "SC",
"zip_code": "89201100",
"city_code": "4209102"
}
}'{
"valid": true,
"warnings": []
}{
"valid": false,
"detail": {
"code": "CFOP_INCONSISTENT_WITH_DESTINATION",
"field": "items[0].product.br.cfop",
"message": "items[0].cfop='6102' is inconsistent with this invoice's operation type (rejections 518, 519, 731-733).",
"sefaz_rejection": "732",
"expected": "5xxx",
"received": "6102"
},
"errors": [
{
"code": "CFOP_INCONSISTENT_WITH_DESTINATION",
"field": "items[0].product.br.cfop",
"message": "items[0].cfop='6102' is inconsistent with this invoice's operation type (rejections 518, 519, 731-733).",
"sefaz_rejection": "732",
"expected": "5xxx",
"received": "6102"
}
],
"warnings": []
}Activity check
When the company's activities do not cover what the document sells, warnings carries one of the codes below. The same findings come back in the warnings of the 201 of POST /invoices. A warning never blocks: the answer stays 200 and the issuance goes through, unless the company turned on the block described next.
- MEI_ACTIVITY_NOT_ALLOWED
- An NFS-e issued by a MEI whose national tax code (cTribNac) is linked to no occupation allowed to a MEI with ISS in Annex XI of CGSN Resolution 140/2018. Issuing it can lead to the company being removed from the MEI regime.
- ACTIVITY_NOT_REGISTERED
- The service is allowed, but is not linked to any of the CNAEs registered for the company. For ME/EPP and the normal regime it is raised only when every CNAE of the company is covered by the correlation.
- MEI_NO_ICMS_ACTIVITY
- An NF-e sale by a MEI where none of its registered CNAEs allows ICMS.
field is the request path the finding is about, such as items[0].service_code, and null when the code came from the company's default service_code. code is the stable key; read it, not message.
Accept-Language takes pt-BR, en or es and sets the language of the activity messages. Everything else in the answer stays in English.
The correlation between the national tax code and the CNAE is curated by Stackin: no official one exists. The company's CNAEs are read from the CNPJ registry (the Receita Federal's open data, reloaded monthly). A company with no CNPJ in the registry gets no activity warning.
Blocking the issuance
The company setting block_activity_mismatch (boolean, off by default) turns MEI_ACTIVITY_NOT_ALLOWED and ACTIVITY_NOT_REGISTERED into a 422. Read it with GET /company and change it with PATCH /company. Only the company owner, or an API key of the owner, may write it; anyone else gets 403.
On, POST /invoices answers 422 with {"detail": {"code", "field", "message"}} and nothing is sent, numbered or charged, and POST /invoices/validate lists the finding in errors. MEI_NO_ICMS_ACTIVITY never blocks. A reissue does not run the activity check.
The company's blockers
Before the body, the company is checked for the document type. These come with field: null and a fix_url to the screen that fixes them.
- CERTIFICATE_MISSING
- CERTIFICATE_EXPIRED
- CERTIFICATE_UNREADABLE
- ISSUER_ADDRESS_INCOMPLETE
- ISSUER_STATE_REGISTRATION_MISSING
- PLAN_LIMIT_REACHED
IBS/CBS simulation
Simulates the IBS/CBS group an NF-e would carry for a set of items, without issuing anything. The response always has simulated: true and a notice: it is a simulation, not a fiscal document, and has no legal effect. Nothing is stored or sent to a tax authority.
Authenticate with an API key, or an OAuth token with the invoice:read scope. The call counts against the read rate limit.
document_type (nfe, nfce or nfse, default nfe) only picks the model the classification (cClassTrib) is checked against. The amounts are always the NF-e's: an NFS-e's amounts are computed by the Sefin Nacional, not by Stackin, and the NFS-e issuance checks do not run here.
Send rates for every item, or the rates on an item, which win over rates. With no rates and an operation_date in 2026, the official 2026 rates apply (CBS 0.9%, IBS UF 0.1%, IBS Mun 0%) and the item reports rates_source: official_2026. Outside 2026 the rates are required, or the answer is 422 IBS_CBS_RATES_REQUIRED. A CST without the gIBSCBS group (such as 400 or 410) needs no rate.
curl -X POST https://api.stackin.io/api/v1/ibs-cbs/calculate \
-H "Authorization: Bearer $STACKIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"operation_date": "2026-05-10",
"items": [
{ "cst": "000", "classification": "000001", "amount": 200 }
]
}'
curl -X POST https://api.stackin.io/api/v1/ibs-cbs/calculate \
-H "Authorization: Bearer $STACKIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document_type": "nfe",
"operation_date": "2027-03-01",
"rates": { "rate_state": 0.05, "rate_city": 0.05, "rate_federal": 8.8 },
"items": [
{ "cst": "000", "classification": "000001", "amount": 100 },
{ "cst": "410", "classification": "410001", "base": 80 }
]
}'{
"simulated": true,
"notice": "Simulation only: not a fiscal document and no legal effect. The amounts are what the NF-e IBS/CBS group would carry for these inputs; nothing was issued, stored or sent to any tax authority.",
"document_type": "nfe",
"operation_date": "2026-05-10",
"items": [
{
"cst": "000",
"classification": "000001",
"indicators": { "group": 1, "reduction": 0, "deferral": 0 },
"has_group": true,
"rates": {
"rate_state": "0.1000",
"rate_city": "0.0000",
"rate_federal": "0.9000"
},
"rates_source": "official_2026",
"reduction_ibs": null,
"reduction_cbs": null,
"effective_rates": null,
"deferral": null,
"amounts": {
"base": "200.00",
"ibs_state": "0.20",
"ibs_city": "0.00",
"ibs": "0.20",
"cbs": "1.80",
"deferred_ibs_state": "0.00",
"deferred_ibs_city": "0.00",
"deferred_cbs": "0.00"
}
}
],
"total": {
"base": "200.00",
"ibs_state": "0.20",
"ibs_city": "0.00",
"ibs": "0.20",
"cbs": "1.80",
"deferred_ibs_state": "0.00",
"deferred_ibs_city": "0.00",
"deferred_cbs": "0.00"
}
}{
"detail": {
"code": "IBS_CBS_RATES_REQUIRED",
"field": "items[0].rate_state"
}
}Request fields
- document_type
- nfe | nfce | nfse | optionalThe model the
classificationis checked against. Defaultnfe. - operation_date
- string (date) | requiredDate of the operation,
YYYY-MM-DD. It picks the cClassTrib vigência and, with no rates sent, the official 2026 rates. - rates
- object | optionalRates for every item:
rate_state(pIBSUF),rate_city(pIBSMun) andrate_federal(pCBS), in percent, 0 to 100. - items
- object[] | requiredFrom 1 to 990 items.
- items[].cst
- string | requiredCST of IBS/CBS, 3 digits.
- items[].classification
- string | requiredcClassTrib, 6 digits.
- items[].amount
- number | optionalThe item amount. Send
amountorbase; withoutbase, the base is the amount. - items[].base
- number | optionalThe base (vBC). Defaults to
amount. - items[].reduction_ibs / reduction_cbs
- number | optionalpRedAliq of the IBS and of the CBS, in percent. Only for CST 011, 200 and 515; left out, they come from the cClassTrib table.
- items[].rate_state / rate_city / rate_federal
- number | optionalThe item's own
rate_state,rate_cityandrate_federal. They win overrates.
Response fields
- simulated
- booleanAlways
true. - notice
- stringStates that the result is a simulation, not a fiscal document.
- document_type / operation_date
- string
document_typeandoperation_dateas sent. - items[]
- object[]One entry per item, in order:
cst,classification,indicators(group,reduction,deferral),has_group(whethergIBSCBSwould go out),ratesandrates_source(callerorofficial_2026),reduction_ibs,reduction_cbs,effective_rates(pAliqEfet),deferral(pDif) andamounts. Without the group,ratesandrates_sourcearenull. - items[].amounts
- object
base(vBC),ibs_state(vIBSUF),ibs_city(vIBSMun),ibs(vIBS),cbs(vCBS),deferred_ibs_state,deferred_ibs_cityanddeferred_cbs(vDif). Decimal strings, as the XML carries them. - total
- objectThe same
amounts, summed as the note's IBSCBSTot.
Errors
The cClassTrib and CST checks are those of NF-e issuance, and detail.field points into this request, such as items[0].classification.
- 422
- IBS_CBS_CLASS_CST_MISMATCHThe
classificationdoes not belong to thecst. - 422
- IBS_CBS_CLASS_NOT_IN_FORCEThe
classificationis not in force on theoperation_date. - 422
- IBS_CBS_CLASS_NOT_ALLOWEDThe
classificationis not allowed on thedocument_typesent. - 422
- IBS_CBS_REDUCTION_NOT_ALLOWEDA reduction was sent for a CST that does not take one.
- 422
- IBS_CBS_REDUCTION_REQUIREDThe CST needs a reduction and none was sent or found in the cClassTrib table.
- 422
- IBS_CBS_RATES_REQUIREDNo rates outside 2026, for a CST that carries the group.
detail.fieldnames the missing rate.