Skip to navigation

Einvoice XML Validation

View as Markdown

Run SAT validation on an already-created document. Executes three steps in order and records the outcome (audit log + validation-history row):

  1. Schema — CFDI 4.0 structure + required attributes.

  2. SAT status — queries SAT’s ConsultaCFDIService for the invoice status (Vigente = valid).

  3. RFC — the receiver RFC matches the configured company RFC.

The document must have finished importing (creation status = SUCCESS) before it can be validated.

Endpoint

POST /v2/einvoice/mexico/validate

Request Headers

AttributeTypeOptionDescription
x-api-keyStringRequiredA unique string
AuthorizationStringRequiredBearer token
Content-TypeStringRequiredapplication/json
AcceptStringOptionalapplication/json

Request Payload

FieldTypeRequiredDescription
documentIdString✅The Staple document id to validate
{
"documentId": "245234"
}

Response (Success — VALID)

{
"documentId": "245234",
"uuid": "699628be-2f06-4bc9-adc2-860b51eecbca",
"validation_result": "VALID",
"validatedAt": "2026-07-09T08:29:06.785Z",
"invalid_reason": null,
"steps": {
"schema": { "result": "PASS", "detail": null },
"satStatus": { "result": "PASS", "detail": null },
"rfc": { "result": "PASS", "detail": null }
}
}

Response (INVALID)

{
"documentId": "245234",
"uuid": "699628be-2f06-4bc9-adc2-860b51eecbca",
"validation_result": "INVALID",
"validatedAt": "2026-07-09T08:29:06.785Z",
"invalid_reason": "Cancelled E-Invoice",
"steps": {
"schema": { "result": "PASS", "detail": null },
"satStatus": { "result": "FAIL", "detail": "Cancelled E-Invoice" }
}
}

Response Fields

FieldTypeDescription
documentIdStringThe validated document id
uuidStringCFDI Folio Fiscal (UUID) from the XML
validation_resultStringVALID or INVALID
validatedAtStringISO timestamp of the validation run
invalid_reasonStringnull
stepsObjectPer-step results — schema, satStatus, rfc

steps.\* Fields

FieldTypeDescription
resultStringPASS or FAIL
detailStringnull

Only the steps that actually ran are present. Validation stops at the first failing step, so e.g. a schema failure returns steps.schema only; a SAT failure returns schema + satStatus.

Notes

  • documentId is the main identifier for this endpoint.

  • Validation can only run once the document’s creation status = SUCCESS (document is RECEIVED/COMPLETED).

  • Common satStatus.detail values: Cancelled E-Invoice, E-Invoice Not Found, Unknown SAT Status: , SAT service unavailable: no response after 3 attempts.

  • Every call is recorded as a validation-history row and an audit-trail entry (validated_document).

Errors

StatusWhen
400 Bad RequestMissing documentId; document not found; caller not authorized; document not yet processed (creation status not success); XML missing; or CFDI has no UUID
401 / 403Missing/invalid x-api-key or Authorization, or no access to the document
502 / 503SAT (or upstream dependency) temporarily unavailable

Want the example request/response pairs formatted for Postman (so you can drop them into saved Examples — e.g. one VALID, one INVALID – Cancelled, one 400 – not processed), or shall I paste the status endpoint next?

Authentication

x-api-keystring
API key issued by Staple.

Request

This endpoint expects an object.
documentIdstringOptional

Response

Successful response