Skip to main content

Error handling

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. Today, API messages are returned in Spanish. They may change to improve clarity or support localization, so avoid using them for branching logic.

Error object

{
"ok": false,
"message": "El campo \"customer.email\" es requerido.",
"status": 400,
"code": "invalid_request",
"location": "body",
"path": "customer.email",
"errors": [
{
"message": "El campo \"customer.email\" es requerido.",
"code": "required",
"source": "facturapi",
"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.
errorsarrayActionable details to correct the request or understand an external response. It can include multiple items when multiple issues are detected.
errors[].messagestringHuman-readable message for a detail.
errors[].codestringDetail subcode. Facturapi validation errors use an input-validation or tax-information-validation subcode; external errors may use 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[].sourcestringSource of the detail. It can be facturapi, sat, or pac.

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.

The errors[] array appears when the response needs to explain one or more details in addition to the main outcome: for example, multiple invalid fields in the same request or reasons returned by an external provider. Its codes are detail subcodes and do not replace the root code. When source is facturapi, the subcode and message are defined by Facturapi. When source is external, the subcode may be the original code from the indicated system.

When an error uses its default root message, message repeats the first detail message in errors[]. This preserves a useful message for integrations that do not yet process structured details; for programmatic logic, always use code, errors[].code, and path.

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 source: "facturapi", 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 the root 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 that Facturapi cannot classify reliably, they are included in errors[] with the original code:

{
"message": "No se encontró el RFC [AAA010101AAA] en la Lista de Contribuyentes Obligados.",
"status": 400,
"code": "invoice_stamping_validation_error",
"errors": [
{
"message": "No se encontró el RFC [AAA010101AAA] en la Lista de Contribuyentes Obligados.",
"code": "402",
"source": "pac"
}
],
"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 (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.

TaxInfoValidationCode

These codes describe tax-information errors validated by Facturapi. When a customer or organization tax-information validation detects a single issue, it appears in code. Input validations and the customer tax-information validation endpoint return them in errors[].code.

CodeDescription
legal_name_mismatchThe name or business name does not match the RFC in SAT records. Verify that it exactly matches the Tax Status Certificate (Constancia de Situación Fiscal).
tax_address_zip_mismatchThe fiscal zip code does not match the RFC in SAT records. Verify that it matches the Tax Status Certificate (Constancia de Situación Fiscal).
tax_id_not_foundThe receiver RFC does not exist in SAT's list of registered, non-cancelled RFCs.
tax_system_not_allowed_for_tax_idThe tax regime is not allowed for the RFC in SAT records.
tax_system_not_in_catalogThe tax regime does not belong to the SAT catalog.

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_address_mismatchAll receipts must have the same expedition address to be invoiced together.
receipt_invoicing_customer_mismatchSend a customer or select receipts that already belong to the same customer.
receipt_invoicing_too_many_itemsThe receipts exceed the maximum of 5,000 supported items. Split the receipts into multiple invoices.
receipt_keys_not_foundThe requested receipts were not found. When only some keys are missing, errors[] may point to their position with path: "keys.N".

ReceiptGlobalInvoiceErrorCode

CodeDescription
global_invoice_too_many_itemsThe global invoice exceeds the maximum of 5,000 supported items. Create multiple global invoices using smaller date ranges or receipt subsets.
invalid_global_invoice_periodThe date range must be within the same billing period: {period}.

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_expiredThe certificate has expired.
certificate_file_requiredWe could not find a file named "cer" in your request. Make sure your request uses multipart/form-data and uses "cer" as the field name.
certificate_files_invalidThe certificate or private key is invalid, incomplete, or damaged.
certificate_files_requiredWe could not find any files in your request.
certificate_fiel_rfc_mismatchThe certificate RFC does not match the FIEL RFC.
certificate_invalidThe certificate is invalid.
certificate_not_yet_validThe certificate cannot be used yet.
certificate_previous_rfc_mismatchThe certificate RFC does not match the previous certificate.
csd_requiredThe certificate is not a CSD. Make sure you are not sending a FIEL.
fiel_invalidThe FIEL is invalid.
fiel_rfc_mismatchThe FIEL RFC does not match the CSD certificate RFC.
fiel_requiredThe certificate is not a FIEL. Make sure you are not sending a CSD.
organization_domain_change_not_allowedThe invoicing domain cannot be changed after it has been selected. Contact us to change it.
organization_domain_unavailableThe invoicing domain is not available.
organization_settings_invalidThe organization settings are invalid.
organization_support_email_requiredA support email is required to select an invoicing domain.
organization_tax_info_invalidThe organization tax information is invalid.
private_key_certificate_mismatchThe private key does not match the certificate.
private_key_file_requiredWe could not find a file named "key" in your request. Make sure your request uses multipart/form-data and uses "key" as the field name.
private_key_password_incorrectThe private key password is incorrect.

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

When a request has multiple invalid fields or values, errors[] includes one detail for each. These subcodes identify the problem in each detail.

Interpret the subcode together with path, location, and the original request. Subcodes are intentionally generic and do not change based on the field type or endpoint flow.

CodeDescription
amount_exceeds_related_document_balanceThe paid amount cannot exceed the related document's previous balance.
exchange_rate_too_largeThe exchange rate must be less than or equal to 1 when the payment is in MXN and the related document is in USD.
exchange_rate_too_smallThe exchange rate must be greater than or equal to 1 when the payment is in USD and the related document is in MXN.
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_foundThe value references a resource that does not exist.
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.
invalid_valueThe value is invalid.

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.