NF-e rejected by SEFAZ: the rejections the API stops before sending
Which SEFAZ rejections the Stackin API checks before transmitting an NF-e, the 422 with code and exact field, and how to test without issuing on POST /invoices/validate.

An NF-e rejected by SEFAZ costs a round trip to the authorizer, a code with a short message and the work of finding out which field caused it. Many of those rejections, however, follow rules published in Annex I of the Taxpayer Guidance Manual (MOC) and in the technical notes — and a published rule can be checked before sending. That is what the Stackin API does: before signing and transmitting the NF-e, it checks the request against those rules and returns the error right away, naming the exact field, without the document ever reaching SEFAZ.
For an integrator that changes two things. The response is a 422 from the API itself, with a stable code (NCM_NOT_FULL_CODE, for instance), the path of the field in your body (items[0].product.br.ncm) and, where one exists, the rejection code SEFAZ would have returned in sefaz_rejection — that number is what you look up in the manual. And none of it uses up the plan's allowance: only documents authorized in production count (cancelled ones included); a rejected attempt, before or at SEFAZ, does not, and the homologation environment is free.
Which rejections the API stops before sending
The list covers what the API checks today when issuing an NF-e (model 55) through POST /api/v1/invoices and POST /api/v1/invoices/validate. Each line gives the code SEFAZ would return, the code the API answers and what is checked.
- 777 and 471 — incomplete NCM.
NCM_NOT_FULL_CODE(777):product.br.ncmwith 2 digits is only accepted as00.NCM_00_ONLY_FOR_SERVICE_LINE(471):00only on a service line (one with the ISSQN group). An 8-digit NCM outside the TIPI table answersINVALID_NCM_CODE, and a CEST outside the Convênio ICMS 142/2018 table,INVALID_CEST_CODE. - 611 — invalid GTIN.
GTIN_CHECK_DIGIT_INVALIDfor a wrong check digit, GS1 modulo 10.GTIN_FORMAT_INVALID(225) whenproduct.barcodedoes not have 8, 12, 13 or 14 digits (nor isSEM GTIN). - 225 — field length.
DESCRIPTION_TOO_LONG(descriptionover 120 characters),UNIT_TOO_LONG(product.unitover 6) andADDRESS_FIELD_LENGTH_INVALID: the layout limits ofxProd,uCom/uTriband the address, instead of a schema failure at SEFAZ. - Character outside Latin-1.
CHARACTER_OUTSIDE_LATIN1: emoji, ideograph or Cyrillic inclient_name, in the items or in the address. The NF-e only accepts ISO-8859-1, accents included; the error names the field and the character. - 518, 519, 731, 732 and 733 — CFOP inconsistent with the operation.
CFOP_INCONSISTENT_WITH_DIRECTION(518 and 519) when the first digit does not match the direction (outbound 5, 6 or 7; inbound 1, 2 or 3) andCFOP_INCONSISTENT_WITH_DESTINATION(731, 732 and 733) when it does not match the destination — same state, another state or abroad —, which the API infers from the recipient's state. A 3-digit CFOP (102) is completed with the right digit. - 321, 327 and 328 — returns.
RETURN_CFOP_REQUIRES_RETURN_PURPOSE(328): a return CFOP only on a note withpurpose: "return"(or complementary).RETURN_PURPOSE_REQUIRES_RETURN_CFOP(327): a return note only with a return CFOP.RETURN_REFERENCED_KEY_REQUIRED(321): a return carries the returned NF-e's key inreferenced_keys, except for the CFOPs the rule exempts. The same key twice inreferenced_keys(680) or a complementary note without exactly one key (254 and 255) fall under field validation, the list-shaped422. - 745, 748 and 225 — PIS and COFINS.
PIS_GROUP_REQUIRED(745) andCOFINS_GROUP_REQUIRED(748): ataxblock with nopisor nocofins; for an untaxed item, send{"cst": "07"}.PIS_COFINS_OTHER_BASIS_REQUIRED(225): an "other operations" CST needsv_bcand the rate, orq_bc_prodandv_aliq_prod. - 527 — export with an incompatible ICMS.
EXPORT_ICMS_SITUATION_INVALID: an item with a 7xxx CFOP only takes CSOSN 300 or CST 41, except on a return. - 355, 356, 510, 511 and 720 — foreign operations.
RECIPIENT_COUNTRY_REQUIRES_STATE_EX,RECIPIENT_ABROAD_TAX_ID_NOT_ALLOWEDandRECIPIENT_ABROAD_COUNTRY_REQUIRED: a recipient abroad (state: "EX") is identified byforeign_id, not by CPF/CNPJ, and has acountry_codeother than 1058.EXPORT_REQUIRED(355) andEXPORT_NOT_ALLOWED(356): an outbound NF-e to another country requires theexportgroup, and no other accepts it. - 350 — invalid RECOPI.
RECOPI_NUMBER_INVALID:recopi_numberneeds 20 digits, a valid date and time between 2013 and the moment of issuance, and the two modulo-11 check digits. - 854 and 960 — monophasic fuel.
FUEL_UNIT_MISMATCH(854) andFUEL_ICMS_SITUATION_INVALID(960): for an ANP code in the monophasic taxation table, the unit must be the table's (except on export) and the ICMS one of the CSTs the rule accepts. - 879, 489 and 225 — manufacturer.
MANUFACTURER_CNPJ_REQUIRED(879):ind_escala: "N"requiresmanufacturer_cnpj.MANUFACTURER_CNPJ_ALL_ZEROS(489): an all-zero CNPJ is refused.MANUFACTURER_REQUIRES_CEST(225): the two fields only exist after acest.MANUFACTURER_CNPJ_CHECK_DIGITS_INVALID: a wrong check digit in the manufacturer's CNPJ. - Contingency.
CONTINGENCY_REASON_LENGTH_INVALID,CONTINGENCY_STARTED_AFTER_EMISSIONandCONTINGENCY_NOT_AVAILABLE_IN_UFrefuse a badly declared contingency, each with its owncodeand no single SEFAZ cStat. - 664 — presumed credit outside the state's table. Each
presumed_credits[].codeis checked against the cBenef table of the issuer's state, validity on the issuance date included:PRESUMED_CREDIT_CODE_INVALID_FOR_UF. Today the loaded table is Santa Catarina's, which applies this rule; in other states the code goes without this check. - 1024 — cClassTrib incompatible with the IBS/CBS CST.
ibs_cbs.classificationis checked against the official tax classification table: a CST different from the table's →IBS_CBS_CLASS_CST_MISMATCH; a classification out of force or not allowed on the NF-e →IBS_CBS_CLASS_NOT_IN_FORCEorIBS_CBS_CLASS_NOT_ALLOWED. - CSOSN in the wrong regime. On a line filled from the catalog (
item_id), CSOSN for a company outside Simples Nacional and MEI, or CST for one inside →ITEM_TAX_REGIME_MISMATCH. - 228 and 703 — issuance date; recipient data.
issued_atmore than 30 days in the past or more than 5 minutes in the future, a CPF/CNPJ with a wrong check digit and astate_registrationin the wrong format (2 to 14 digits, orISENTO) are field format errors, the list-shaped422.
What the response looks like when the API refuses
A refusal comes in one of two shapes, both 422. A field format error — CPF/CNPJ, state registration, date, referenced keys — is the standard validation 422, with detail as a list of fields. Everything else — the official tables (NCM, CEST, cBenef, cClassTrib) and the layout and cross-field rules (CFOP, GTIN, PIS, returns, exports) — is a 422 with detail as an object: code, field (the path in your body, such as items[0].product.br.cfop), message and, where they apply, sefaz_rejection (the cStat the check spares you), expected and received. Branch on detail.code. The 400 is left only for the issuer's own configuration: certificate, address and fiscal fields. It holds for issuance and for reissue. Messages are in English and carry the SEFAZ code in parentheses.
A 2-digit NCM, for example, comes back before any contact with the authorizer:
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": "Loja Exemplo Ltda",
"tax_id": "11222333000181",
"recipient_address": {
"street": "Rua Exemplo", "number": "100", "neighborhood": "Centro",
"city": "Curitiba", "state": "PR", "zip_code": "80010000"
},
"items": [{
"description": "Parafuso sextavado",
"unit_price": 2.50,
"product": {"unit": "UN", "quantity": 100, "br": {"ncm": "73", "cfop": "102"}}
}]
}'HTTP/1.1 422 Unprocessable Content
{
"detail": {
"code": "NCM_NOT_FULL_CODE",
"field": "items[0].product.br.ncm",
"message": "items[0].ncm='73' is a chapter, and the SEFAZ requires the full 8-digit NCM (rejection 777). Only a service line takes '00'.",
"sefaz_rejection": "777",
"expected": "8 digits",
"received": "73"
}
}And an IBS/CBS classification that does not belong to the CST sent comes back like this:
HTTP/1.1 422 Unprocessable Content
{
"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"
}
}Each error's shape is in Errors and Item values; the IBS/CBS group fields, in IBS/CBS.
How to check an NF-e before issuing it with POST /invoices/validate
POST /api/v1/invoices/validate takes the same body as POST /api/v1/invoices and runs every check that happens before the document is sent, then stops: nothing goes to the SEFAZ or the ADN, no number is used, nothing is stored and nothing is charged. Only the rate-limit counter moves (120 a minute, counted apart from issuance). The scope is invoice:read, so a key or app that can only read can check a draft without being able to issue.
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": "Loja Exemplo Ltda",
"tax_id": "11222333000181",
"recipient_address": {
"street": "Rua Exemplo", "number": "100", "neighborhood": "Centro",
"city": "Curitiba", "state": "PR", "zip_code": "80010000"
},
"items": [{
"description": "Parafuso sextavado",
"unit_price": 2.50,
"product": {"unit": "UN", "quantity": 100, "barcode": "7891000100104", "br": {"ncm": "73", "cfop": "102"}}
}]
}'If the draft passes everything, the answer is 200 with valid: true and warnings, which lists the defaults the company would declare, such as tax_regime_default. If something would be refused, it is 422 with valid: false, detail — the first refusal, exactly what POST /invoices would answer, so code reading detail.code handles both routes alike — and errors. A reference table (NCM, CEST, cCredPresumido, IBS/CBS) reports its first refusal; the layout and cross-field rules report every one found, one per line and broken rule. The company's own blockers (certificate, address, IE, plan) also come in errors, with field: null and a fix_url.
HTTP/1.1 200 OK
{
"valid": true,
"warnings": []
}HTTP/1.1 422 Unprocessable Content
{
"valid": false,
"detail": {
"code": "NCM_NOT_FULL_CODE",
"field": "items[0].product.br.ncm",
"message": "items[0].ncm='73' is a chapter, and the SEFAZ requires the full 8-digit NCM (rejection 777). Only a service line takes '00'.",
"sefaz_rejection": "777",
"expected": "8 digits",
"received": "73"
},
"errors": [
{
"code": "NCM_NOT_FULL_CODE",
"field": "items[0].product.br.ncm",
"message": "items[0].ncm='73' is a chapter, and the SEFAZ requires the full 8-digit NCM (rejection 777). Only a service line takes '00'.",
"sefaz_rejection": "777",
"expected": "8 digits",
"received": "73"
},
{
"code": "GTIN_CHECK_DIGIT_INVALID",
"field": "items[0].product.barcode",
"message": "items[0].barcode='7891000100104' has a wrong check digit (GTIN mod 10); the SEFAZ refuses it (611).",
"sefaz_rejection": "611",
"received": "7891000100104"
}
],
"warnings": []
}Passing here is not a guarantee of authorization: the authorizer can still reject what only it knows, such as the recipient's registration or a number already used.
What the API cannot check in advance
Some rejections depend on data only SEFAZ holds. 232 — recipient's state registration (IE) not informed is the most common example: SEFAZ refuses when the recipient's CNPJ has an active IE and the note goes without it. The API checks the format of recipient_address.state_registration and fills the recipient indicator from it — ISENTO becomes an exempt contributor, no IE a non-contributor —, but whether that CNPJ has an active IE only SEFAZ's register says. The same goes for duplicate numbering, covered in the post on rejection 539.
The MCP server's validate_invoice_payload tool today checks only field formats, that NCM and CFOP are present and that the address is complete; it does not run the rules in this list. To run them without issuing, use POST /api/v1/invoices/validate over the HTTP API, or issue in homologation, which is free — see Environments.
When SEFAZ rejects it anyway
When the authorizer is the one refusing, the response is a 422 with code: "AUTHORITY_REJECTED" and an error block with SEFAZ's code and message, guidance when the cause is known, the invoice_id and retryable. With the invoice_id, GET /api/v1/invoices/{invoice_id}/rejection explains the rejection in plain words: code, message (the original text), explanation, steps, the field to fix and, when there is one, a suggested value. A document that is not rejected returns 409. The raw history of every attempt stays in `/submissions`.
curl https://api.stackin.io/api/v1/invoices/$INVOICE_ID/rejection \
-H "Authorization: Bearer $STACKIN_API_KEY"from stackin import Invoice
invoice = Invoice()
explanation = invoice.rejection("c0a8e2d4-5b1f-4c3e-9a7d-2f6b8e1d4a90")
print(explanation["code"], explanation["message"])
print(explanation["explanation"])
for step in explanation["steps"]:
print("-", step)The Node SDK has the same method, rejection(invoiceId), and on the MCP server the explain_rejection tool gives the assistant the same reading: it shows the original code and message and only applies a suggested value after you confirm it.
- MOC 7.0 – Annex I, NF-e and NFC-e Layout and Validation Rules (Portal da NF-e)
- Technical Note 2025.002 v1.53 – Consumption Tax Reform in the NF-e (Portal da NF-e)
- Technical Note 2019.001 v1.70 – cBenef and presumed credit validation rules (Portal da NF-e)
- Technical Note 2023.001 v1.60 – Fuels under monophasic taxation (Portal da NF-e)