Sign inGet started
Back to blog
Tax reform

How to issue an NF-e with IBS and CBS through the API in 2026

How to issue an NF-e with IBS and CBS through the Stackin API: the ibs_cbs fields, what the API computes, the CST and cClassTrib checks before SEFAZ and the simulation.

To issue an NF-e with IBS and CBS through the Stackin API, each item carries in product.br.ibs_cbs the CST, the tax classification (cClassTrib) and the three rates: rate_state (pIBSUF), rate_city (pIBSMun) and rate_federal (pCBS). From that the API builds each item's IBSCBS group and the invoice's IBSCBSTot total, and computes the base and the IBS and CBS amounts itself from those rates, so the item and the total never disagree.

Before transmitting, Stackin checks the CST and the cClassTrib against the official tables and refuses with a 422 what SEFAZ would reject, with a code, the field and a message. To see the amounts before issuing, POST /api/v1/ibs-cbs/calculate runs the same calculation and the same checks as a simulation, without issuing anything.

Which IBS/CBS fields the NF-e takes

  • cst: the IBS/CBS CST, three digits.
  • classification: the cClassTrib, six digits.
  • rate_state, rate_city and rate_federal: the rates, in percent. On an NF-e all three are required when the group is sent; if one is missing, the request comes back 422.
  • base: the vBC, optional. Without it, the base is the item amount.
  • reduction_ibs and reduction_cbs: the rate reduction percentage (pRedAliq), for CSTs 011, 200 and 515 only.
  • operation_indicator: the cIndOp, which belongs to the NFS-e and is refused on an NF-e.

In 2026, art. 125 of the ADCT, added by Constitutional Amendment 132, sets IBS at 0.1% (state rate) and CBS at 0.9%. On issuance Stackin does not fill in a rate for you: the three fields go in the request, as in the example below.

POST /api/v1/invoices
Copy
curl -X POST https://api.stackin.io/api/v1/invoices \
  -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": "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
            }
          }
        }
      }
    ],
    "recipient_address": {
      "street": "Rua das Flores",
      "number": "1200",
      "neighborhood": "Centro",
      "city": "Joinville",
      "state": "SC",
      "zip_code": "89201100"
    }
  }'

Stackin does not choose the CST or the cClassTrib. Both are a tax decision about the operation, and the API only checks that the combination sent exists and applies to that invoice.

What Stackin computes from the rates

  • vBC is the base sent or, without it, the item amount.
  • vIBSUF, vIBSMun and vCBS are the base times each level's rate, rounded to two decimals; vIBS is the sum of state and municipality.
  • With a reduction (CSTs 011, 200 and 515), each level gains the gRed group with pRedAliq and the effective rate pAliqEfet = rate × (1 − pRedAliq / 100), and the amount comes from the effective rate. If you do not send reduction_ibs and reduction_cbs, the API uses the pRedIBS and pRedCBS percentages of the official cClassTrib table.
  • With a deferral (CSTs 510 and 515), each level gains the gDif group with a pDif of 100% and the computed vDif, and the tax amount becomes what is left after it.
  • IBSCBSTot is the sum of the item groups.

Stackin's IBS/CBS math is tested against the test cases of the Receita Federal's own calculator, which run in the API's test suite. What the calculator does and does not do is covered in Receita Federal's IBS/CBS calculator.

Which rejections the API stops before SEFAZ

Each check below matches a validation rule of NT 2025.002-RTC. When it fails, the invoice is not transmitted and you get a 422 instead of a rejection:

  • IBS_CBS_CLASS_CST_MISMATCH: the cClassTrib belongs to another CST. At SEFAZ this would be rejection 1024 (tax classification incompatible with the CST).
  • IBS_CBS_CLASS_NOT_IN_FORCE: the cClassTrib is not in force on the issue date, taken in the issuer state's timezone.
  • IBS_CBS_CLASS_NOT_ALLOWED: the official table does not allow that cClassTrib on the document model (indNFe = 0 for the NF-e). At SEFAZ this would be rejection 1025.
  • IBS_CBS_REDUCTION_REQUIRED: the CST requires a rate reduction, you did not send reduction_ibs and reduction_cbs and the table has no percentages to fill them from. Without the reduction group, SEFAZ would answer 1033.
  • IBS_CBS_REDUCTION_NOT_ALLOWED: a reduction was sent for a CST that does not allow one (that would be 1032).

Two rules Stackin meets while building the XML, without asking anything more of you. For CSTs 510 and 515 it writes the gDif group, whose absence SEFAZ rejects with 1030. And it writes gIBSCBS only when the CST indicator table requires it: for a CST that does not allow it, such as 410, the item carries only the CST and the cClassTrib, avoiding rejections 1021 (group sent improperly) and 1022 (group missing).

422 — cClassTrib of another CST
Copy
{
  "detail": {
    "code": "IBS_CBS_CLASS_CST_MISMATCH",
    "field": "items[0].ibs_cbs.cst",
    "message": "cClassTrib 000001 belongs to CST 000; you sent 200. Send cst 000, or the cClassTrib of CST 200 that fits the operation (the SEFAZ answers 1024).",
    "expected": "000",
    "received": "200"
  }
}

Today the API does not build the specific groups that CSTs 620, 800, 810 and 811 ask for; items with those CSTs remain subject to SEFAZ refusal.

How to simulate IBS and CBS before issuing

POST /api/v1/ibs-cbs/calculate takes 1 to 990 items, each with cst, classification and amount or base, plus the operation_date. The rates are optional: without them and with a date in 2026, the official 2026 rates apply (CBS 0.9%, IBS state 0.1%, IBS municipal 0%) and the item comes back with rates_source: "official_2026". Outside 2026 the rates are required, or the answer is a 422 IBS_CBS_RATES_REQUIRED. The CST and cClassTrib checks are the same as on issuance, with the same error codes.

POST /api/v1/ibs-cbs/calculate
Copy
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-11-22",
    "items": [
      { "cst": "000", "classification": "000001", "amount": 240 }
    ]
  }'
Response (excerpt)
Copy
{
  "simulated": true,
  "document_type": "nfe",
  "operation_date": "2026-11-22",
  "items": [
    {
      "cst": "000",
      "classification": "000001",
      "has_group": true,
      "rates_source": "official_2026",
      "amounts": {
        "base": "240.00",
        "ibs_state": "0.24",
        "ibs_city": "0.00",
        "ibs": "0.24",
        "cbs": "2.16",
        "deferred_ibs_state": "0.00",
        "deferred_ibs_city": "0.00",
        "deferred_cbs": "0.00"
      }
    }
  ]
}

The response always carries simulated: true and a notice: it is a simulation, not a fiscal document. Nothing is issued, stored or sent to a tax authority. The document_type field only picks the model the cClassTrib is checked against; the amounts are always the NF-e's. The route uses the invoice:read scope and is documented on /api.

In the SDKs, the method lives on the FiscalReference class (calculate_ibs_cbs in Python, calculateIbsCbs in Node and PHP); see /sdks. In Python:

Python
Copy
from stackin import FiscalReference

ref = FiscalReference(api_key="$STACKIN_API_KEY")

result = ref.calculate_ibs_cbs(
    [{"cst": "000", "classification": "000001", "amount": 240}],
    operation_date="2026-11-22",
)
print(result.items[0].amounts.cbs, result.total.ibs)

For AI agents, the Stackin MCP server exposes the same simulation as the read-only calculate_ibs_cbs tool.

And IBS/CBS on the NFS-e

On the NFS-e the DPS group carries cst, classification and operation_indicator (the cIndOp, the NFS-e Anexo VII code for where the service is supplied), plus the optional groups personal_use, government, referenced_nfse, recipient, real_estate, movable_goods, regular_taxation, deferral and presumed_credit. Base, rates and reductions are refused with a 422, because the NFS-e IBS and CBS amounts are computed by the Sefin Nacional, not by Stackin. On the production layout, operation_indicator is required whenever the group is sent.

NFS-e with IBS/CBS
Copy
{
  "document_type": "nfse",
  "client_name": "John Doe",
  "tax_id": "00000000000",
  "items": [
    {
      "description": "Consultoria técnica - 10 horas",
      "unit_price": "1500.00",
      "product": {
        "br": {
          "ibs_cbs": {
            "cst": "000",
            "classification": "000001",
            "operation_indicator": "100301"
          }
        }
      }
    }
  ]
}

The NFS-e cClassTrib also goes through the CST, vigência and model checks. In production an MEI company does not send the group (IBS_CBS_NOT_FOR_MEI), and a Simples Nacional ME/EPP sends it only when the company's simples_apuracao_ibs_cbs fiscal field is 3, that is, when it settles IBS and CBS outside the DAS (IBS_CBS_SIMPLES_IN_DAS otherwise). In homologation, for a competência from 2026-10-01, the layout lists the group as mandatory and every regime may send it. The other DPS fields, the rules per regime and the warnings are in the API reference. For the rest of issuance, see Issue NF-e and Issue NFS-e.