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
Example Request:
Create Retention
Tax Object:
tax(string, required) - Tax type:ISR,IVA, orIEPS. 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 to03(provisional) for ISR and01(definitivo) for IVA/IEPS.
Required combinations per retention key
A miss is a hard400.
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_keyis a string, not a number."16"matches;16does not, and the complement check silently does not apply.- The extra rule on key
26is easy to miss: an IVA-onlytaxesarray 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.
Example: Basic Retention (Dividends)
Example: Retention with Interest Complement (Key 16)
Example: Platform Services Retention (Key 26)
Example: Custom Retention Type (Key 25)
Get Retention
Get Retention Files
file_type(string, optional) - Filter by file type:pdforxml. Returns both if omitted.team(string, optional) - gigstack Connect: Target team ID.
Cancel Retention
Example Request:
Retention Structure
Retention Keys (Types)
Theretention_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
Complement-Specific Fields
Interest Complement (Key 16)
Required whenretention_key is "16". Provides details about financial interest payments.
Platform Services Complement (Key 26)
Required whenretention_key is "26". Details technology platform service transactions.
Custom Retention Description (Key 25)
Required whenretention_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
- Use the correct retention key - Each type of withholding operation has a specific key. Using the wrong key will cause SAT validation errors.
- Provide complement data when required - Keys 16, 25, and 26 require additional fields. The API will reject requests missing required complement data.
- Verify client fiscal data - The receiver’s RFC and tax system must be valid and registered with SAT.
- 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. - Match fiscal periods accurately - The
period_start,period_end, andperiod_yearmust correspond to the actual period covered by the retention. - Review before stamping - Unlike draft invoices, retentions are stamped immediately on creation. Verify all data before submitting.
- Keep metadata organized - Use metadata to link retentions to internal records (resolutions, contracts, account numbers).
Related Resources
- Clients API - Manage retention recipients
- Invoices API - Standard CFDI invoicing
- Teams API - Configure team SAT certificates
- CFDI Errors Reference - Error codes for stamping failures
Retry and outcome checks
HTTP201 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 always400 and the offending rule is spelled out verbatim in error.message:
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
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