Machine translation, not yet reviewed.

RTC/Gov calculator

Exposes the government's RTC Calculator (Reforma Tributária sobre o Consumo — IBS, CBS and IS) to external customers, through an integration application that talks to the…

✅ Available in development and UAT. Production is still pending the pre-production security review (DFE-2796, in progress) and the cut of the release-proxy-vX.Y.Z tag.

Exposes the government's RTC Calculator (Reforma Tributária sobre o Consumo, the Brazilian consumption tax reform — IBS, CBS and IS) to external customers, through an integration application that talks to the official calculator. The calculation is passed through byte for byte; the service adds authentication, product control, caching and limits.

Base URL

EnvironmentURL
Developmenthttps://<API_HOST>
UAT (sandbox)https://<API_HOST>
Production(to be confirmed — depends on DFE-2796 + tag release-proxy-v*) 🔜
Production (whitelabel)https://<API_HOST> (to be confirmed) 🔜

API Reference

Full interactive reference (Scalar): API reference.

Authentication

OAuth2 JWT token obtained via client_credentials (application token), in the Authorization: Bearer {token} header. See Authentication and Authorization.

Access requirements, in addition to a valid token:

  • Realm role RTC_INTEGRATION_API granted to the client.
  • RTC Calculator product enabled for the customer.
  • The customer is resolved from the token's customer-id claim — do not send the X-Customer-ID header.
  • The companyId in the body must belong to the authenticated customer.

Content-type: application/vnd.materimperium.api.v1+json (standard envelope — see REST APIs).

Endpoints

Prefix: /api/integration/dfe/rtc/calculadora. The {model} path variable is 55 (NF-e) or 65 (NFC-e).

POST /{model}/regime-geral

Calculates the RTC taxes (general regime) for a set of items.

Interactive reference: API reference

POST /api/integration/dfe/rtc/calculadora/{model}/regime-geralPOST/api/integration/dfe/rtc/calculadora/{model}/regime-geralSign in to see the host and reference

Query params

ParameterRequiredDefaultDescription
versaonolatestCalculator version. Outside the whitelist → 400 INVALID_CALCULATOR_VERSION (the accepted list is included in the message). Currently only latest is deployed in all three environments.

Body (request)

FieldTypeRequiredDescription
companyIdUUIDyesCompany that provides the context for the call; must belong to the customer.
dataHoraEmissaoISO offset date-timenoDefault: now (America/Sao_Paulo time zone).
municipiointeger (7 digits)yesIBGE code of the municipality of the IBS taxable event.
ufstring (2 uppercase)yesIssuer's UF (state).
itens[]list (1..990)yesItems to calculate.
itens[].numerointegeryesSequential item number.
itens[].ncmstringyesProduct NCM.
itens[].cststringnoIBS/CBS CST.
itens[].baseCalculodecimalyesItem calculation base.
itens[].quantidadedecimalnoCommercial quantity.
itens[].unidadestringnoCommercial unit.
itens[].cClassTribstringnoTax classification code.
itens[].tributacaoRegularobjectno{ cst, cClassTrib } — taxation the item would have under the regular regime. If sent, both fields are required.

⚠️ Although cst and cClassTrib are marked as optional in the schema, the government calculator currently rejects (400 TAX_CALCULATION_ERROR) requests without both filled in. Always send both.

Response 200 — standard envelope with data:

FieldDescription
versaoAppCalculator application version.
versaoDbVersion of the rates/rules database.
descricaoVersaoDbDatabase description.
dataVersaoDbDatabase date.
ambienteCalculator environment.
calculoByte-for-byte pass-through of the government Calculator's response. The schema belongs to the government and preserves the original numeric representation (e.g., 1000.00 stays 1000.00). It currently contains objetos[] with tribCalc.IBSCBS per item (including memoriaCalculo, a text explaining the legal framework) and a total.tribCalc.IBSCBSTot with the aggregates — treat it as an opaque object: the full schema belongs to the government and may change without notice from this API.

Example (request):

POST /api/integration/dfe/rtc/calculadora/55/regime-geral?versao=latest
Content-Type: application/json
Authorization: Bearer $TOKEN

{
  "companyId": "6f1c1a3e-2d5b-4f0a-9c0d-8b4f2a1c9e77",
  "dataHoraEmissao": "2026-05-10T08:15:30-03:00",
  "municipio": 3550308,
  "uf": "SP",
  "itens": [
    {
      "numero": 1,
      "ncm": "84713012",
      "cst": "000",
      "baseCalculo": 1000.00,
      "quantidade": 1.0,
      "unidade": "UN",
      "cClassTrib": "000001"
    }
  ]
}

Example (response), with calculo captured live:

{
  "code": "0",
  "message": "",
  "success": true,
  "data": {
    "versaoApp": "1.0.18",
    "versaoDb": "v0041",
    "descricaoVersaoDb": "Base de alíquotas 2026",
    "dataVersaoDb": "2026-01-15",
    "ambiente": "PRODUCAO",
    "calculo": {
      "objetos": [
        {
          "nObj": 1,
          "tribCalc": {
            "IBSCBS": {
              "CST": "000",
              "cClassTrib": "000001",
              "gIBSCBS": {
                "vBC": "1000.00",
                "gIBSUF": { "pIBSUF": "0.10", "vIBSUF": "1.00", "memoriaCalculo": "Operação de consumo com enquadramento legal em LC 214/2025, tributada conforme Tributação integral. A base de cálculo utilizada é de R$ 1000.00000000, com alíquota de 0.100000%." },
                "gIBSMun": { "pIBSMun": "0.00", "vIBSMun": "0.00", "memoriaCalculo": "Operação de consumo com enquadramento legal em LC 214/2025, tributada conforme Tributação integral. A base de cálculo utilizada é de R$ 1000.00000000, com alíquota de 0.000000%." },
                "vIBS": "1.00",
                "gCBS": { "pCBS": "0.90", "vCBS": "9.00", "memoriaCalculo": "Operação de consumo com enquadramento legal em LC 214/2025, tributada conforme Tributação integral. A base de cálculo utilizada é de R$ 1000.00000000, com alíquota de 0.900000%." }
              }
            }
          }
        }
      ],
      "total": {
        "tribCalc": {
          "IBSCBSTot": {
            "vBCIBSCBS": "1000.00",
            "gIBS": {
              "gIBSUF": { "vDif": "0.00", "vDevTrib": "0.00", "vIBSUF": "1.00" },
              "gIBSMun": { "vDif": "0.00", "vDevTrib": "0.00", "vIBSMun": "0.00" },
              "vIBS": "1.00",
              "vCredPres": "0.00",
              "vCredPresCondSus": "0.00"
            },
            "gCBS": { "vDif": "0.00", "vDevTrib": "0.00", "vCBS": "9.00", "vCredPres": "0.00", "vCredPresCondSus": "0.00" },
            "gMono": { "vIBSMono": "0.00", "vCBSMono": "0.00", "vIBSMonoReten": "0.00", "vCBSMonoReten": "0.00", "vIBSMonoRet": "0.00", "vCBSMonoRet": "0.00" }
          }
        }
      }
    }
  }
}

The IBS/CBS rates in the example above (0.10% / 0.90%) reflect the 2026 test period of the Brazilian tax reform (LC 214/2025) — they are not the full reference rates, which increase gradually until 2033.

GET /{model}/versao

Returns the current calculator version (served from cache). Same authentication, same product gate, and it counts toward the customer's quota.

Interactive reference: API reference

GET /api/integration/dfe/rtc/calculadora/{model}/versaoGET/api/integration/dfe/rtc/calculadora/{model}/versaoSign in to see the host and reference

Query params: versao (optional, same as the endpoint above).

Response 200 — data: versaoApp, versaoDb, descricaoVersaoDb, dataVersaoDb, ambiente.

Version, cache and quota semantics

  • Version selection: ?versao= is optional (default latest); it allows calculating against older databases. A version outside the configured whitelist → 400 INVALID_CALCULATOR_VERSION. Currently the whitelist only has latest deployed in all three environments.
  • Response cache: identical responses (same customer, model, target version and payload) are served from cache for up to 60s. The cache is internal to the application and cannot be controlled by the customer (no status header or bypass). If dataHoraEmissao is omitted, "now" may reflect up to one TTL ago — anyone who needs determinism should provide the date explicitly.
  • Quota / limits: per-customer quota (429 RATE_LIMITED, with Retry-After) — every request counts, including GET /versao and responses served from cache. There is also upstream concurrency protection (429 CONCURRENCY_LIMITED).

Message language

Resolved via Accept-Language: pt-BR (default), en-US, es-ES.

Error Codes

Errors follow the standard ApiError envelope (see REST APIs); the code field is the stable identifier for the integrator to branch on. Authentication codes (401, and the 403 for insufficient scope) arrive in the same envelope, but are emitted by the security layer before the controller — which is why they do not appear in the declared responses of the OpenAPI spec.

HTTPcodeCause
400TAX_CALCULATION_ERRORInvalid/unreadable body, or rejection (4xx) by the calculator (title/detail in the message).
400INVALID_MODEL_CODEmodel outside the supported list (55, 65).
400INVALID_CALCULATOR_VERSIONversao outside the whitelist.
400(field validation)@Valid — e.g., empty itens or more than 990, invalid UF, municipality not 7 digits, incomplete tributacaoRegular.
401UNAUTHORIZEDToken missing, invalid or expired.
403CUSTOMER_NOT_ACTIVEInactive customer.
403INVALID_CUSTOMER_CONTEXTToken without the customer-id claim, or company that does not belong to the customer.
403PRODUCT_NOT_ENABLEDRTC Calculator product not enabled for the customer.
403FORBIDDENValid token, but without the RTC_INTEGRATION_API role.
413PAYLOAD_TOO_LARGEBody above the configured limit.
429RATE_LIMITEDCustomer quota exceeded (accompanied by Retry-After).
429CONCURRENCY_LIMITEDUpstream concurrency limit reached.
502TAX_CALCULATOR_UNAVAILABLETransport failure or 5xx from the calculator.
503IAM_UNAVAILABLEIAM unavailable and no cached access decision.
503AUTH_UNAVAILABLEToken issuer/JWKS unreachable during validation (rare).
504TAX_CALCULATOR_TIMEOUTCalculator timeout (accompanied by Retry-After).
500INTERNAL_ERRORUnexpected failure — still returned within the standard envelope.

Changelog

[1.0.0] — 2026-09-02

Added

  • POST /{model}/regime-geral — calculation of RTC taxes (general regime).
  • GET /{model}/versao — current calculator version.

Available in development and UAT; production expected after DFE-2796 is closed and the release-proxy-v* tag is cut.

[Unreleased]

Added

  • Real example of calculo (pass-through payload from the government Calculator, engine v0043) in the endpoints section, and a note that cst/cClassTrib are required in practice by the government engine despite being optional in the schema.

Reconciled with the service in development and UAT. Last review: 2026-09-08 (mi-dev-portal-doc — DFE-2852).

On this page