Skip to main content

Error handling

Availability

The normalized error codes and messages described here apply starting July 2, 2026. Before that date, error codes and messages may differ from what is documented on this page.

The API returns errors as JSON and uses standard HTTP status codes. For programmatic error handling, use code: it is a stable, predictable string.

message is meant for humans. It may change to improve clarity or support localization, so avoid using it for branching logic.

Error object

{
"ok": false,
"message": "La solicitud no es válida.",
"status": 400,
"code": "invalid_request",
"location": "body",
"path": "customer.email",
"errors": [
{
"message": "\"customer.email\" is required",
"code": "required",
"location": "body",
"path": "customer.email"
}
]
}
FieldTypeDescription
okbooleanAlways false for error responses. You can ignore it for programmatic handling.
messagestringHuman-readable error message.
statusnumberHTTP status code.
codestringStable root code for handling the error.
locationstringLocation of the data related to the error, such as body, query, params, or files. Included only when applicable.
pathstringPath of the field related to the error. Included only when applicable.
errorsarrayAdditional details. Included only when there are multiple validation errors or relevant external details.
errors[].messagestringHuman-readable message for a detail.
errors[].codestringDetail subcode. For validation errors, this uses a ValidationErrorCode; for external errors, it may be the original SAT or PAC code.
errors[].locationstringLocation of the data related to the detail, such as body, query, params, or files.
errors[].pathstringPath of the field related to the detail.
errors[].sourcestringExternal source for the detail, such as sat or pac. Included only for external errors.

Interpreting codes

The root code classifies the main result of the request and is the value you should check first when deciding how to handle an error.

Codes inside errors[] are detail subcodes. They explain invalid fields or external responses, but they do not replace the root code. They may be Facturapi validation subcodes or original codes from external systems such as SAT or PAC.

Validation errors

When the request does not match the input contract, the root error uses code: "invalid_request". When details are available, errors[] includes each invalid field with path, location, and a validation subcode.

Validation subcodes are documented at the end of this page as detail subcodes because they appear in errors[].code, not in error.code.

External errors

Some operations depend on external validations or services, such as SAT or PAC. In those cases, the root code remains a Facturapi code, for example invoice_stamping_validation_error.

If the external provider returns useful details, they are included in errors[] with the original code:

{
"message": "La factura no pasó la validación de timbrado.",
"status": 400,
"code": "invoice_stamping_validation_error",
"errors": [
{
"message": "El RFC del receptor no se encuentra en la lista de RFC inscritos no cancelados del SAT.",
"code": "CFDI40145",
"source": "sat"
}
],
"ok": false
}

For SAT stamping validation codes, see the CFDI 4.0 error matrix published as part of SAT's official Anexo 20 documentation.

Useful headers

Some error responses include useful headers for programmatic handling or observability:

HeaderDescription
Retry-AfterRecommended seconds to wait before retrying. Included in errors with code: "rate_limit_exceeded".
X-Facturapi-Log-IdRequest correlation ID. You can keep it in your observability stack to investigate errors with support.

Root error codes (error.code)

This list is the documented reference for public root API codes. We may add new codes at any time when new features or new error cases require them, but we aim to keep this page up to date so integrations have a predictable reference.

CommonErrorCode

CodeDescription
conflictThe request cannot be completed because of a conflict.
forbiddenThe authenticated caller does not have permission for this action.
internal_errorAn unexpected internal error occurred.
not_foundThe requested resource was not found.
unauthorizedThe request could not be authenticated.

AuthErrorCode

CodeDescription
api_key_invalidThe provided API key is invalid.
api_key_not_allowedThe API key cannot perform this action.
feature_not_availableThe feature is not available for the organization.
live_api_key_requiredThe operation requires a live API key.
mcp_permission_deniedThe caller does not have permission to use this MCP tool.
missing_credentialsThe request did not include credentials.
organization_incompleteThe organization is not fully configured for this operation.
subscription_requiredThe operation requires an active subscription.
subscription_live_access_requiredThe subscription does not allow live-mode access.
user_key_invalidThe provided user key is invalid.
user_suspendedThe user is suspended.

RequestErrorCode

CodeDescription
idempotency_key_in_useThe idempotency key is already being used by another request.
rate_limit_exceededThe request exceeded the allowed rate limit.
date_range_too_largeThe requested date range exceeds the allowed limit.
image_file_requiredAn image file is required.
invalid_country_codeThe country code is invalid.
invalid_dateThe date is invalid.
invalid_date_rangeThe date range is invalid.
invalid_image_fileThe provided file is not a valid image.
invalid_jsonThe request body is not valid JSON.
invalid_requestThe request is invalid.
invalid_multipart_form_dataThe multipart/form-data payload is invalid.
invalid_state_codeThe state code is invalid.
invalid_timezoneThe timezone is invalid.
multipart_limit_exceededThe multipart/form-data request exceeds the allowed limits.
page_too_largeThe requested page exceeds the allowed limit.
payload_too_largeThe request payload exceeds the maximum allowed size.

CustomerErrorCode

CodeDescription
customer_could_not_be_resolvedThe customer could not be resolved from the request or related resources.
customer_edit_link_not_foundThe customer edit link does not exist or has expired.
customer_edit_link_unavailableThe customer edit link is not available.
customer_email_requiredThe customer email address is required.
customer_has_invoicesThe customer cannot be deleted because it has associated invoices.
customer_not_foundThe customer was not found.
customer_tax_info_unavailableThe customer tax information is not available.

ProductErrorCode

CodeDescription
product_not_foundThe product was not found.

SupplierErrorCode

CodeDescription
supplier_not_foundThe supplier was not found.

CatalogErrorCode

CodeDescription
product_key_not_foundThe SAT product or service key was not found.
tariff_code_not_foundThe tariff fraction was not found.
unit_key_not_foundThe SAT unit key was not found.

InvoiceErrorCode

CodeDescription
invoice_already_stampedThe invoice has already been stamped.
invoice_not_draftThe invoice is not a draft.
invoice_not_foundThe invoice was not found.
invoice_not_stampedThe invoice has not been stamped.

InvoiceDraftErrorCode

CodeDescription
draft_not_ready_to_stampThe draft is not ready to be stamped.
draft_update_in_progressThe draft is already being updated.

InvoiceStampingErrorCode

CodeDescription
invoice_stamping_failedThe invoice could not be stamped.
invoice_stamping_service_unavailableThe stamping service is unavailable.
invoice_stamping_validation_errorThe invoice failed stamping validation.
manifesto_signature_failedThe manifesto could not be signed.
stamping_in_progressStamping for this invoice is already in progress.

InvoiceDeliveryErrorCode

CodeDescription
invoice_email_delivery_failedThe invoice could not be sent by email.
invoice_email_recipient_requiredNo email recipient is available for the invoice.
invoice_email_status_not_allowedThe invoice status does not allow email delivery.

InvoiceCancellationErrorCode

CodeDescription
invoice_cancellation_in_progressThe invoice already has a pending cancellation request.
invoice_cancellation_receipt_unavailableThe cancellation receipt is not available.
invoice_cancellation_failedThe invoice could not be canceled.
invoice_cancellation_not_allowedInvoice cancellation is not allowed.
invoice_cancellation_not_foundThe cancellation request was not found.
invoice_cancellation_rfc_mismatchThe RFC does not match for invoice cancellation.
invoice_cancellation_service_unavailableThe cancellation service is unavailable.
invoice_not_cancelableThe invoice cannot be canceled.
invoice_not_cancelable_by_satThe invoice cannot be canceled with SAT.
substitution_invoice_canceledThe substitution invoice is already canceled.
substitution_invoice_not_foundThe substitution invoice was not found.
substitution_invoice_requiredA substitution invoice is required.
substitution_invoice_status_not_allowedThe substitution invoice status is not valid for this operation.

ReceiptErrorCode

CodeDescription
receipt_expiredThe receipt has expired.
receipt_not_foundThe receipt was not found.
receipt_not_openThe receipt is not open.

ReceiptInvoicingErrorCode

CodeDescription
receipt_invoicing_customer_mismatchThe receipts cannot be invoiced together for the same customer.
receipt_invoicing_too_many_itemsThe receipts exceed the allowed item limit.
receipt_keys_not_foundNot all requested receipt keys were found.

ReceiptGlobalInvoiceErrorCode

CodeDescription
global_invoice_too_many_itemsThe global invoice exceeds the allowed item limit.
invalid_global_invoice_periodThe global invoice period is invalid.

RetentionErrorCode

CodeDescription
invalid_retention_complementThe retention complement is invalid.
retention_not_foundThe retention was not found.
retention_not_stampedThe retention has not been stamped.
retention_not_cancelableThe retention cannot be canceled.

RetentionDeliveryErrorCode

CodeDescription
retention_email_delivery_failedThe retention could not be sent by email.
retention_email_recipient_requiredNo email recipient is available for the retention.
retention_email_status_not_allowedThe retention status does not allow email delivery.

RetentionCancellationErrorCode

CodeDescription
retention_cancellation_failedThe retention could not be canceled.
retention_cancellation_service_unavailableThe retention cancellation service is unavailable.

RetentionStampingErrorCode

CodeDescription
retention_stamping_failedThe retention could not be stamped.
retention_stamping_service_unavailableThe retention stamping service is unavailable.
retention_stamping_validation_errorThe retention failed stamping validation.

OrganizationErrorCode

CodeDescription
invalid_operationThe operation is invalid.
invalid_user_idThe user is invalid.
organization_not_foundThe organization was not found.
subscription_active_requiredThe organization requires an active subscription.

OrganizationSettingsErrorCode

CodeDescription
certificate_invalidThe certificate is invalid.
certificate_rfc_mismatchThe certificate RFC does not match the organization.
fiel_invalidThe FIEL is invalid.
fiel_rfc_mismatchThe FIEL RFC does not match the organization.
organization_settings_invalidThe organization settings are invalid.
organization_tax_info_invalidThe organization tax information is invalid.

OrganizationInviteErrorCode

CodeDescription
invite_email_delivery_failedThe invitation could not be sent by email.
invite_email_mismatchThe email address does not match the invitation.
invite_expiredThe invitation has expired.
invite_not_foundThe invitation was not found.
invite_role_unavailableThe invitation role is not available.
user_already_in_organizationThe user already belongs to the organization.

OrganizationAccessErrorCode

CodeDescription
organization_admin_access_cannot_be_removedOrganization admin access cannot be removed.
organization_admin_assignment_cannot_be_editedThe organization admin assignment cannot be edited.
organization_admin_role_cannot_be_deletedThe organization admin role cannot be deleted.
organization_admin_role_cannot_be_editedThe organization admin role cannot be edited.
organization_admin_role_requiredThe organization admin role is required.
organization_id_not_allowedorganizationId is not allowed for this scope.
organization_id_requiredorganizationId is required for this scope.
owner_access_cannot_be_reassignedOwner access cannot be reassigned.
owner_access_cannot_be_removedOwner access cannot be removed.
role_has_assigned_usersThe role cannot be deleted because it has assigned users.
role_template_not_foundThe role template was not found.
role_not_foundThe role was not found.
user_access_not_foundThe user access assignment was not found.

OrganizationSeriesErrorCode

CodeDescription
series_already_existsThe series already exists.
series_not_foundThe series was not found.

WebhookErrorCode

CodeDescription
webhook_delivery_attempt_not_foundThe webhook delivery attempt was not found.
webhook_not_foundThe webhook was not found.
webhook_signature_invalidThe webhook signature is invalid.

ToolErrorCode

CodeDescription
tax_id_validation_failedThe RFC could not be validated.
tax_id_validation_service_unavailableThe RFC validation service is unavailable.

Detail subcodes (errors[].code)

These values appear inside errors[] to explain specific details of the root error. They are not root error codes.

Input validation

These subcodes may appear when the root code is invalid_request.

CodeDescription
invalid_formatThe value does not match the expected format.
invalid_lengthThe value does not match the allowed length.
invalid_typeThe value has the wrong type.
not_allowedThe value is not allowed for this field.
requiredA required field is missing.
too_largeThe value exceeds the allowed limit.
too_smallThe value is below the allowed minimum.
unknown_fieldThe field is not allowed in this request.

External codes

When an external system returns a useful code, Facturapi preserves it in errors[].code and adds errors[].source to indicate how to interpret it. For example, in stamping errors, source: "sat" means errors[].code is a SAT validation code, such as CFDI40145.

External codes are not enumerated here because they belong to the system that emits them. For SAT stamping validation codes, see the CFDI 4.0 error matrix.