Skip to main content
Create, manage, and cancel CFDI retention documents (Constancias de Retenciones e Informacion de Pagos) with full SAT compliance. The Retentions API handles the complete lifecycle of withholding tax certificates required by Mexican tax law.

Overview

Retentions are CFDI documents that certify taxes withheld by a payer on behalf of a recipient. They are required in scenarios such as interest payments, technology platform services, dividends, royalties, and other transactions where the payer is legally obligated to withhold taxes (ISR, IVA, IEPS) and report them to SAT. Unlike standard invoices, retentions have a distinct structure: they are organized by retention key (type of operation), fiscal period, and withheld tax amounts rather than line items.

Key Features

  • SAT Retention Keys - Support for all 26 retention types (01-26)
  • Automatic Tax Mapping - Friendly names (ISR, IVA, IEPS) mapped to SAT codes
  • Auto-Calculated Totals - Taxable, exempt, and retained amounts computed automatically
  • Complement Support - Built-in handling for Intereses (key 16), Plataformas Tecnologicas (key 26), and Otro tipo (key 25)
  • Folio Management - Automatic folio generation and stamping
  • File Generation - PDF and XML files generated on stamp
  • Cancellation - SAT-compliant cancellation with motive codes

Endpoints

List Retentions

Retrieve a paginated list of retention documents with filtering capabilities. Query Parameters: Example Request:
Example Response:

Create Retention

Create and stamp a new retention CFDI document. The retention is normalized, stamped with SAT, and saved in a single operation. Request Body: Tax Object:
  • tax (string, required) - Tax type: ISR, IVA, or IEPS. Mapped automatically to SAT codes (001, 002, 003).
  • base (number, required) - Taxable base amount.
  • amount (number, required) - Amount retained.
  • payment_type (string, optional) - SAT payment type code. Defaults to 03 (provisional) for ISR and 01 (definitivo) for IVA/IEPS.
Common Retention Keys:

Required combinations per retention key

A miss is a hard 400. Three retention keys carry a complement, and the API validates the combination before anything is sent to the PAC. Nothing is stamped, nothing is charged, and the response is 400 with the exact message below in error.message: Notes that catch people out:
  • retention_key is a string, not a number. "16" matches; 16 does not, and the complement check silently does not apply.
  • The extra rule on key 26 is easy to miss: an IVA-only taxes array passes the schema and is then rejected by the validator. A Plataformas Tecnológicas retention is expected to retain ISR (and may also retain IVA), so send both.
  • These three fields are schema-optional at the top level precisely because they are conditional — the schema will not catch a missing one, only this validator will.
  • Every other key (01, 02, 06, 14, …) needs no complement; sending one anyway is simply ignored for that key.
Worked examples for all three follow: key 16, key 25, key 26.

Example: Basic Retention (Dividends)

Example: Retention with Interest Complement (Key 16)

Example: Platform Services Retention (Key 26)

Example: Custom Retention Type (Key 25)

Response (201):

Get Retention

Retrieve a specific retention document by its UUID. Example Request:

Get Retention Files

Retrieve the PDF and XML files for a stamped retention. Query Parameters:
  • file_type (string, optional) - Filter by file type: pdf or xml. Returns both if omitted.
  • team (string, optional) - gigstack Connect: Target team ID.
Example Request:
Example Response:

Cancel Retention

Cancel a stamped retention with SAT. Requires a cancellation motive. Request Body:
Cancellation Motives: Example Request:
Example Response:

Retention Structure

Retention Keys (Types)

The retention_key identifies the type of operation that requires tax withholding. Common keys include:

Tax Types

Auto-Calculated Fields

When creating a retention, the following fields are computed automatically:
  • total_taxable = total_operation - total_exempt
  • total_retained = sum of all taxes[].amount
You do not need to send these values; they are derived from the input.

Complement-Specific Fields

Interest Complement (Key 16)

Required when retention_key is "16". Provides details about financial interest payments.

Platform Services Complement (Key 26)

Required when retention_key is "26". Details technology platform service transactions.
Periodicity Codes:

Custom Retention Description (Key 25)

Required when retention_key is "25". A free-text description of the retention type.

Use Cases

1. Dividend Distribution

A company distributes dividends to shareholders and must issue retention certificates for the ISR withheld.

2. Technology Platform (Uber, Rappi, etc.)

A technology platform withholds taxes on behalf of service providers and must issue monthly retention certificates.

3. Professional Services Withholding

A company paying a freelance consultant withholds ISR and IVA as required by law.

4. Bank Interest Payments

A financial institution issues retention certificates for interest paid to account holders.

Best Practices

  1. Use the correct retention key - Each type of withholding operation has a specific key. Using the wrong key will cause SAT validation errors.
  2. Provide complement data when required - Keys 16, 25, and 26 require additional fields. The API will reject requests missing required complement data.
  3. Verify client fiscal data - The receiver’s RFC and tax system must be valid and registered with SAT.
  4. Reconcile uncertain issuance - Retention creation accepts idempotency_key, but the reviewed retention stamping path does not perform the income endpoint’s key claim/replay checks. After a timeout or server error, reconcile the retention and provider result before issuing again; a new request can take another folio.
  5. Match fiscal periods accurately - The period_start, period_end, and period_year must correspond to the actual period covered by the retention.
  6. Review before stamping - Unlike draft invoices, retentions are stamped immediately on creation. Verify all data before submitting.
  7. Keep metadata organized - Use metadata to link retentions to internal records (resolutions, contracts, account numbers).

Retry and outcome checks

HTTP 201 returns the created retention in data. Retain its ID and UUID, then use the get/files routes to retrieve it. If a response is lost after stamping, do not assume the accepted idempotency_key field makes resubmission safe: the current retention path does not implement the income-invoice key claim/replay workflow. Search/list the appropriate team and mode and reconcile with the provider or support before another creation. A validation error returned before provider submission can be corrected without implying that a fiscal document already exists.

Error Handling

Missing Required Fields

Invalid Retention Key

Missing Complement Data (400)

Returned by the conditional-requirements check described under Required combinations. The status is always 400 and the offending rule is spelled out verbatim in error.message:
The other three messages you can get here:
  • retention_description is required for retention key 25 (Otro tipo de retenciones)
  • platform_services object is required for retention key 26 (Plataformas Tecnológicas)
  • At least one non-IVA tax (ISR or IEPS) is required for Plataformas Tecnológicas
What to do: add the missing field and retry with the same idempotency_key — the request never reached the PAC, so no folio was consumed and no document exists.

Retention Not Found

Already Canceled

Stamping Error


For additional assistance, contact support@gigstack.io