# Stamp a withholding certificate

`POST https://api.fiscalisto.com/v1/retentions`

Stamps a withholding and payment information certificate (Retenciones 2.0) with the issuer's RET1, RET2… folios. Once per Idempotency-Key; with send_email and email it's sent to the recipient when stamped.

## Before you call

- **An issuer that already stamps.** In production, with its digital seal (CSD) current: [`POST /v1/issuers/{id}/certificates`](https://fiscalisto.com/en/docs/api/referencia/emisores/upload-certificate). In test mode it stamps with SAT's test CSD.
- **The `Idempotency-Key` header**, a new one for each call (for example, the order's id in your system). If the response is lost, repeat the call with the same one and it isn't done twice: [Idempotency](https://fiscalisto.com/en/docs/api/idempotencia).

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | header | yes | A new one per CFDI (8 to 255 characters; your order id works). If the response is lost, repeat the request with the same value: it answers the same and never stamps twice. |

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `issuer` | string |  | Issuer (iss_…). If the key has a single issuer or the account has only one, it can be left out. |
| `code` | string | yes | Withholding key (CveRetenc), c_CveRetenc: 01 professional services, 05 leasing, 14 dividends, 16 interest, 18 payments abroad… Keys 06 and 14 to 24 carry their complement, as SAT's catalog asks (share_sale with 06 and 19, dividends with 14, distributable_remainder with 15, interest, trust_lease, foreign_payment, prize, trust, retirement_plan, mortgage_interest, financial_derivatives); 01, 02, 04 and 05 carry foreign_payment when the recipient is foreign; 26 (technology platforms) carries platform, and its totals and taxes are calculated from the operations. 27 and 28 can't be issued here. |
| `description` | string or null |  | Description of the withholding (DescRetenc); required with key 25 (another type). |
| `recipient` | object | yes | Recipient of the certificate (Receptor): domestic with RFC and postal code, or foreign. |
| `recipient.foreign` | boolean |  | true if the recipient is foreign (without an RFC). |
| `recipient.tax_id` | string or null |  | RFC (Rfc), 12 characters for a persona moral and 13 for a persona física. |
| `recipient.legal_name` | string | yes | Name or razón social exactly as on the constancia de situación fiscal, without the capital regime (without «S.A. de C.V.»). (up to 300 characters) |
| `recipient.zip` | string |  | Postal code of the tax address, 5 digits, as on the constancia de situación fiscal. An issuer's is the place of issue (LugarExpedicion) of its CFDIs. |
| `recipient.curp` | string or null |  | CURP, 18 characters. |
| `period` | object | yes | Period (Periodo): start month, end month and year. |
| `period.year` | integer | yes | Year (Ejercicio). (from 2004 to 2100) |
| `period.month` | integer |  | A single month, from 1 to 12 (MesIni and MesFin the same). (from 1 to 12) |
| `period.from_month` | integer |  | Start month (MesIni), 1 to 12. (from 1 to 12) |
| `period.to_month` | integer |  | End month (MesFin), 1 to 12, in the same year. (from 1 to 12) |
| `totals` | object |  | Totals (Totales). |
| `totals.operation` | number | yes | Total amount of the operation (MontoTotOperacion). (from 0) |
| `totals.taxed` | number |  | Taxed amount (MontoTotGrav). By default, operation minus exempt. (from 0) |
| `totals.exempt` | number |  | Exempt amount (MontoTotExent). 0 by default. (from 0) |
| `taxes` | array of object |  | The CFDI's taxes, by type. (up to 50; default []) |
| `taxes[].tax` | string | yes | Tax: isr, iva or ieps (ImpuestoRet 001, 002, 003). |
| `taxes[].base` | number | yes | Base of the withheld tax (BaseRet). (from 0) |
| `taxes[].amount` | number | yes | Amount withheld (MontoRet). (from 0) |
| `taxes[].payment_type` | string |  | Withholding payment type (TipoPagoRet): 01 final VAT, 02 final IEPS, 03 final ISR, 04 provisional ISR. By default the usual one for each tax. |
| `platform` | object |  | Technology platform services complement (ServiciosPlataformasTecnologicas 1.0), required with code 26: one certificate per month, recipient and service type. totals and taxes are calculated from services with SAT's rates (ISR from LISR 113-A and LIF 2026 art. 25; VAT 50% or 100%; IEPS on betting); if you send them, they must match. |
| `platform.type` | string | yes | Service type (TipoDeServ), c_TipoDeServ: 01 passenger transport, 02 food delivery, 03 goods delivery, 04 lodging, 05 sale of goods, 06 other services, 07 to 09 digital services from foreigners, 11 betting and lotteries (from 2026). |
| `platform.periodicity` | string |  | How often the platform pays (Periodicidad): 01 weekly, 02 monthly (the default), 03 daily, 04 every two weeks, 05 other. (default "02") |
| `platform.isr_definitive` | boolean |  | true if the persona física opted for the withheld ISR to be a final payment (LISR 113-B): TipoPagoRet 03 instead of 04. |
| `platform.foreign_account` | boolean |  | true if they're paid into an account abroad: 100% of the VAT is withheld (LIF 2026 art. 25-IX-c). |
| `platform.services` | array of object | yes | Each operation (DetallesDelServicio), up to 5,000. What was paid in cash (payment_form 01) goes on the certificate but not in the bases. (up to 5000) |
| `platform.services[].date` | string (date) | yes | Date the customer paid (FechaServ), YYYY-MM-DD, within the period's month. |
| `platform.services[].payment_form` | string | yes | Payment form of the operation (FormaPagoServ), c_FormaPagoServ: 01 cash, 02 transfer, 03 credit card, 04 wallet, 05 electronic money, 06 debit, 07 service card, 08 payment intermediary, 09 prizes or rebates. |
| `platform.services[].price` | number | yes | Price without VAT (PrecioServSinIVA). (from 0 to 1000000000) |
| `platform.services[].rate` | number or null |  | Rate of the transferred tax (TasaCuota): 0.16 (the default), 0.08 or 0 of VAT; 0.5 of IEPS only with type 11, where each bet goes twice: one operation with its VAT and another with its IEPS (SAT asks for one tax per operation). No rate on prizes (09), which from 2026 don't add to totals. |
| `platform.services[].subtype` | string or null |  | Subtype (SubTipServ), c_SubTipoServ: with type 01, 01 private (the default), 02 shared, 03 plus or 04 cancellation; with type 11, 08 betting (the default) or 09 lotteries. |
| `platform.services[].authorized_tax_id` | string or null |  | RFC (persona física) of the authorized third party who provided the service (RFCTerceroAutorizado). |
| `platform.services[].commission` | object or null |  | The platform's commission for the operation (ComisionDelServicio): amount greater than zero and optional percent (0.001 to 1). Required on each operation with VAT; it doesn't go on prizes or on IEPS ones. |
| `platform.services[].commission.amount` | number | yes | Amount. (from 0) |
| `platform.services[].commission.percent` | number or null |  | The commission's percentage of the price, from 0.001 to 1 (0.25 is 25%). Optional. |
| `platform.services[].contribution` | object or null |  | Government contribution paid, like the lodging tax (ContribucionGubernamental): amount of at least 1.00 and state (01 to 32). |
| `platform.services[].contribution.amount` | number | yes | Amount. (from 0) |
| `platform.services[].contribution.state` | string | yes | State where they work (ClaveEntFed): JAL, CMX, NLE… |
| `dividends` | object |  | Dividends complement. |
| `dividends.type` | `01`, `02`, `03`, `04`, `05`, `06` | yes | Type of dividend or distributed profit (CveTipDivOUtil), c_TipoDividendoOUtilidadDistribuida. |
| `dividends.isr_mexico` | number | yes | ISR creditable in Mexico (MontISRAcredRetMexico). (from 0) |
| `dividends.isr_foreign` | number | yes | ISR creditable abroad (MontISRAcredRetExtranjero). (from 0) |
| `dividends.foreign_retention` | number or null |  | Withholding abroad on dividends (MontRetExtDivExt). |
| `dividends.company` | `nacional`, `extranjera` | yes | Type of company distributing (TipoSocDistrDiv): domestic or foreign. |
| `dividends.national_credit` | number or null |  | Domestic creditable ISR (MontISRAcredNal). |
| `dividends.accumulated_national` | number or null |  | Domestic cumulative dividend (MontDivAcumNal). |
| `dividends.accumulated_foreign` | number or null |  | Foreign cumulative dividend (MontDivAcumExt). |
| `interest` | object |  | Interest complement. |
| `interest.financial_system` | boolean | yes | true if the interest comes from the financial system (SistFinanciero). |
| `interest.retirement` | boolean | yes | true if the interest was withdrawn in the period (RetiroAORESRetInt). |
| `interest.derivatives` | boolean | yes | true if they're derivative financial operations (OperFinancDerivad). |
| `interest.nominal` | number | yes | Nominal interest (MontIntNominal). |
| `interest.real` | number | yes | Real interest (MontIntReal). |
| `interest.loss` | number | yes | Loss (Perdida). |
| `foreign_payment` | object |  | Payments to foreigners complement: required with code 18, and with 01, 02, 04 and 05 when the recipient is foreign. |
| `foreign_payment.beneficiary` | boolean | yes | true if the one receiving is the beneficial owner (EsBenefEfectDelCobro). |
| `foreign_payment.country` | string or null |  | The foreigner's country of residence (PaisDeResidParaEfecFisc), 2 letters. |
| `foreign_payment.concept` | `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9` | yes | Payment concept (ConceptoPago), c_TipoContribuyenteSujetoRetencion. |
| `foreign_payment.description` | string | yes | Description of the concept (DescripcionConcepto). (up to 255 characters) |
| `foreign_payment.beneficiary_tax_id` | string or null |  | The beneficiary's RFC, if it isn't the one receiving (RFC). |
| `foreign_payment.beneficiary_curp` | string or null |  | The beneficiary's CURP (CURP). |
| `foreign_payment.beneficiary_name` | string or null |  | The beneficiary's name or razón social (NomDenRazSocB). |
| `distributable_remainder` | object |  | Dividends complement with its Remanente node (distributable remainder), required with code 15. If you don't send it, it goes without a share. |
| `distributable_remainder.proportion` | number or null |  | The member's or partner's share of the remainder (ProporcionRem), optional. |
| `trust_lease` | object |  | Lease in trust complement (Arrendamientoenfideicomiso 1.0), required with code 17. |
| `trust_lease.trustee_payment` | number | yes | Provisional payment the trustee made to the lessor in the period (PagProvEfecPorFiduc). (from 0) |
| `trust_lease.income` | number | yes | The period's yield from leasing the assets (RendimFideicom). (from 0) |
| `trust_lease.deductions` | number | yes | The period's leasing deductions (DeduccCorresp). (from 0) |
| `trust_lease.withheld_total` | number or null |  | Total amount withheld from the lease in the period (MontTotRet). |
| `trust_lease.fibra_result` | number or null |  | Tax result distributed by FIBRAS (MontResFiscDistFibras). |
| `trust_lease.other_amount` | number or null |  | Amount of other concepts distributed (MontOtrosConceptDistr). |
| `trust_lease.other_description` | string or null |  | What the other distributed concepts are (DescrMontOtrosConceptDistr); required with other_amount. |
| `share_sale` | object |  | Sale of shares or securities transactions complement (EnajenaciondeAcciones 1.0), required with code 06 and 19. |
| `share_sale.contract` | string | yes | Description of the brokerage contract (ContratoIntermediacion). (up to 300 characters) |
| `share_sale.gain` | number | yes | Gain obtained (Ganancia). (from 0) |
| `share_sale.loss` | number | yes | Loss (Perdida). (from 0) |
| `prize` | object |  | Prizes complement (Premios 1.0), required with code 20. Its amounts are those of totals. |
| `prize.state` | string | yes | State where the prize is paid (EntidadFederativa), c_EntidadesFederativas from catRetenciones: 01 Aguascalientes … 09 Ciudad de México … 32 Zacatecas. |
| `trust` | object |  | Complement for trusts that don't carry out business activities (Fideicomisonoempresarial 1.0), required with code 21. |
| `trust.income` | object | yes | The trust's income or inflows in the period (IngresosOEntradas) and the recipient's share. |
| `trust.income.concept` | string | yes | Concept of the income (IntegracIngresos/Concepto), up to 100 characters. (up to 100 characters) |
| `trust.income.total` | number | yes | The trust's total income in the period (MontTotEntradasPeriodo). (from 0) |
| `trust.income.share` | number | yes | The recipient's proportional share of the cumulative income (PartPropAcumDelFideicom). (from 0) |
| `trust.income.proportion` | number | yes | The recipient's share under the contract (PropDelMontTot). (from 0 to 999.999999) |
| `trust.deductions` | object | yes | The trust's deductions or outflows in the period (DeduccOSalidas) and the recipient's share. |
| `trust.deductions.concept` | string | yes | Concept of the outflows (IntegracEgresos/ConceptoS), up to 100 characters. (up to 100 characters) |
| `trust.deductions.total` | number | yes | The trust's total outflows in the period (MontTotEgresPeriodo). (from 0) |
| `trust.deductions.share` | number | yes | The recipient's proportional share of the authorized deductions (PartPropDelFideicom). (from 0) |
| `trust.deductions.proportion` | number | yes | The recipient's share under the contract (PropDelMontTot). (from 0 to 999.999999) |
| `trust.withholding` | object | yes | Withholding made to the trust (RetEfectFideicomiso). |
| `trust.withholding.amount` | number | yes | Amount of the withholding (MontRetRelPagFideic). (from 0) |
| `trust.withholding.description` | string | yes | Description of the withholding (DescRetRelPagFideic), up to 100 characters. (up to 100 characters) |
| `retirement_plan` | object |  | Personal retirement plans complement (Planesderetiro 1.1), required with code 22: the previous year's figures. |
| `retirement_plan.financial_system` | boolean | yes | true if the plan is from the financial system (SistemaFinanc). |
| `retirement_plan.contributions_last_year` | number or null |  | Updated contributions from the previous year (MontTotAportAnioInmAnterior). |
| `retirement_plan.real_interest` | number | yes | Real interest accrued or received the previous year (MontIntRealesDevengAniooInmAnt). (from 0) |
| `retirement_plan.early_withdrawals` | boolean | yes | true if there were withdrawals before meeting the holding requirements (HuboRetirosAnioInmAntPer). |
| `retirement_plan.early_withdrawn` | number or null |  | Amount withdrawn before meeting the holding period (MontTotRetiradoAnioInmAntPer); required with early_withdrawals. |
| `retirement_plan.exempt_withdrawn` | number or null |  | Exempt amount of what was withdrawn the previous year (MontTotExentRetiradoAnioInmAnt). |
| `retirement_plan.excess_withdrawn` | number or null |  | Excess over the exempt amount of what was withdrawn the previous year (MontTotExedenteAnioInmAnt). |
| `retirement_plan.withdrawals` | boolean | yes | true if there were withdrawals the previous year (HuboRetirosAnioInmAnt). |
| `retirement_plan.withdrawn` | number or null |  | Amount withdrawn the previous year (MontTotRetiradoAnioInmAnt); required with withdrawals. |
| `retirement_plan.reference` | string or null |  | The customer's reference, contract or account number (NumReferencia). |
| `retirement_plan.contributions` | array of object |  | Contributions or deposits (AportacionesODepositos), one per type and up to three. (up to 3) |
| `retirement_plan.contributions[].type` | `a`, `b`, `c` | yes | Type of contribution (TipoAportacionODeposito): a (art. 151 fracc. V LISR), b (art. 185 LISR) or c (art. 258 RLISR, with trustee_rfc). |
| `retirement_plan.contributions[].amount` | number | yes | Amount of the contribution or deposit (MontAportODep). (from 0) |
| `retirement_plan.contributions[].trustee_rfc` | string or null |  | RFC of the trustee that manages the plan (RFCFiduciaria); required with type c. |
| `mortgage_interest` | object |  | Deductible real interest on mortgage loans complement (Intereseshipotecarios 1.0), required with code 23. |
| `mortgage_interest.financial_institution` | boolean | yes | true if the loan was granted by a financial institution (CreditoDeInstFinanc). |
| `mortgage_interest.outstanding_balance` | number | yes | Outstanding balance at December 31 of the previous year, or at the contract date if it's from this year (SaldoInsoluto). (from 0) |
| `mortgage_interest.deductible_proportion` | number or null |  | Deductible share of the loan over the real interest accrued and paid (PropDeducDelCredit). |
| `mortgage_interest.nominal_accrued` | number or null |  | Nominal interest accrued (MontTotIntNominalesDev). |
| `mortgage_interest.nominal_accrued_paid` | number or null |  | Nominal interest accrued and paid (MontTotIntNominalesDevYPag). |
| `mortgage_interest.real_deductible` | number or null |  | Deductible real interest paid (MontTotIntRealPagDeduc). |
| `mortgage_interest.contract` | string or null |  | Mortgage loan contract number (NumContrato). |
| `financial_derivatives` | object |  | Equity derivative financial operations complement (Operacionesconderivados 1.0), required with code 24. |
| `financial_derivatives.gain` | number | yes | Cumulative gain (MontGanAcum). (from 0) |
| `financial_derivatives.loss` | number | yes | Deductible loss (MontPerdDed). (from 0) |
| `replaces` | string |  | Folio fiscal (UUID) of the certificate this one corrects: current, from the same issuer and to the same recipient (issued here or in another system). It goes in CfdiRetenRelacionados (04) and, once this one is stamped, the previous one is canceled with reason 01; `replaced` says whether it was canceled. |
| `send_email` | boolean |  | true to send the PDF and the XML by email when stamping, with Fiscalisto's design. Not sent by default. |
| `email` | string |  | Email to send it to (several separated by commas). Only used if sending is requested. (up to 1000 characters) |
| `metadata` | object |  | Your own data: up to 50 keys of 40 characters with text values of up to 500. They don't go into the CFDI; they come back in the object and in webhooks. |

Example:

```json
{
  "code": "01",
  "recipient": {
    "tax_id": "MASO451221PM4",
    "legal_name": "MARIA OLIVIA MARTINEZ SAGAZ",
    "zip": "80290"
  },
  "period": {
    "year": 2026,
    "month": 9
  },
  "totals": {
    "operation": 10000
  },
  "taxes": [
    {
      "tax": "isr",
      "base": 10000,
      "amount": 1000
    },
    {
      "tax": "iva",
      "base": 10000,
      "amount": 1066.67
    }
  ],
  "metadata": {
    "proveedor": "42"
  }
}
```

## With the TypeScript SDK

```ts
import { Fiscalisto } from "fiscalisto";

// La llave viene de FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const retention = await fiscalisto.retentions.create({
  code: "01",
  recipient: {
    tax_id: "MASO451221PM4",
    legal_name: "MARIA OLIVIA MARTINEZ SAGAZ",
    zip: "80290",
  },
  period: { year: 2026, month: 9 },
  totals: { operation: 10000 },
  taxes: [
    { tax: "isr", base: 10000, amount: 1000 },
    { tax: "iva", base: 10000, amount: 1066.67 },
  ],
  metadata: { proveedor: "42" },
}, { idempotencyKey: "retencion-2026-09-proveedor-42" });
```

## With the Python SDK

```python
from fiscalisto import Fiscalisto

# La llave viene de FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

retention = fiscalisto.retentions.create({
    "code": "01",
    "recipient": {
        "tax_id": "MASO451221PM4",
        "legal_name": "MARIA OLIVIA MARTINEZ SAGAZ",
        "zip": "80290",
    },
    "period": {"year": 2026, "month": 9},
    "totals": {"operation": 10000},
    "taxes": [
        {
            "tax": "isr",
            "base": 10000,
            "amount": 1000,
        },
        {
            "tax": "iva",
            "base": 10000,
            "amount": 1066.67,
        },
    ],
    "metadata": {"proveedor": "42"},
}, idempotency_key="retencion-2026-09-proveedor-42")
```

## With the PHP SDK

```php
<?php

use Fiscalisto\Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$retention = $fiscalisto->retentions->create([
    'code' => '01',
    'recipient' => [
        'tax_id' => 'MASO451221PM4',
        'legal_name' => 'MARIA OLIVIA MARTINEZ SAGAZ',
        'zip' => '80290',
    ],
    'period' => ['year' => 2026, 'month' => 9],
    'totals' => ['operation' => 10000],
    'taxes' => [
        [
            'tax' => 'isr',
            'base' => 10000,
            'amount' => 1000,
        ],
        [
            'tax' => 'iva',
            'base' => 10000,
            'amount' => 1066.67,
        ],
    ],
    'metadata' => ['proveedor' => '42'],
], ['idempotency_key' => 'retencion-2026-09-proveedor-42']);
```

## With the .NET SDK

```csharp
using Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var retention = await fiscalisto.Retentions.CreateAsync(new CreateRetentionParams
{
    Code = "01",
    Recipient = new()
    {
        TaxId = "MASO451221PM4",
        LegalName = "MARIA OLIVIA MARTINEZ SAGAZ",
        Zip = "80290",
    },
    Period = new() { Year = 2026, Month = 9 },
    Totals = new() { Operation = 10000 },
    Taxes = new()
    {
        new() { Tax = "isr", Base = 10000, Amount = 1000 },
        new()
        {
            Tax = "iva",
            Base = 10000,
            Amount = 1066.67m,
        },
    },
    Metadata = new() { ["proveedor"] = "42" },
}, new RequestOptions { IdempotencyKey = "retencion-2026-09-proveedor-42" });
```

## With the Go SDK

```go
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// La llave viene de FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	retention, err := client.Retentions.Create(ctx, &fiscalisto.CreateRetentionParams{
		Code: "01",
		Recipient: fiscalisto.CreateRetentionParamsRecipient{
			TaxID:     fiscalisto.String("MASO451221PM4"),
			LegalName: "MARIA OLIVIA MARTINEZ SAGAZ",
			Zip:       fiscalisto.String("80290"),
		},
		Period: fiscalisto.CreateRetentionParamsPeriod{
			Year:  2026,
			Month: fiscalisto.Int64(9),
		},
		Totals: &fiscalisto.CreateRetentionParamsTotals{Operation: 10000},
		Taxes: []fiscalisto.CreateRetentionParamsTax{
			{Tax: "isr", Base: 10000, Amount: 1000},
			{Tax: "iva", Base: 10000, Amount: 1066.67},
		},
		Metadata: map[string]string{"proveedor": "42"},
	}, fiscalisto.WithIdempotencyKey("retencion-2026-09-proveedor-42"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(retention.ID)
}
```

## With the Java SDK

```java
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.CreateRetentionParams;
import com.fiscalisto.model.CreateRetentionParamsPeriod;
import com.fiscalisto.model.CreateRetentionParamsRecipient;
import com.fiscalisto.model.CreateRetentionParamsTax;
import com.fiscalisto.model.CreateRetentionParamsTotals;
import java.util.List;
import java.util.Map;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var retention = fiscalisto.retentions().create(new CreateRetentionParams()
        .setCode("01")
        .setRecipient(new CreateRetentionParamsRecipient()
                .setTaxId("MASO451221PM4")
                .setLegalName("MARIA OLIVIA MARTINEZ SAGAZ")
                .setZip("80290"))
        .setPeriod(new CreateRetentionParamsPeriod().setYear(2026).setMonth(9))
        .setTotals(new CreateRetentionParamsTotals().setOperation(10000))
        .setTaxes(List.of(
                new CreateRetentionParamsTax()
                        .setTax("isr")
                        .setBase(10000)
                        .setAmount(1000),
                new CreateRetentionParamsTax()
                        .setTax("iva")
                        .setBase(10000)
                        .setAmount(1066.67)
        ))
        .setMetadata(Map.of("proveedor", "42")), RequestOptions.idempotencyKey("retencion-2026-09-proveedor-42"));
System.out.println(retention.getId());
```

## Response 201

OK. Repeating the request with the same Idempotency-Key answers the same, with the same status and the idempotent-replayed: true header.

A `Retention` object:

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"retention"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer (iss_…). |
| `status` | `processing`, `valid`, `rejected`, `canceled` | yes | processing: the PAC hasn't answered. valid: stamped. rejected: the SAT or the PAC didn't accept it (see error). canceled: canceled. |
| `uuid` | string or null | yes | Tax folio the SAT assigns (UUID of the Timbre Fiscal Digital), in uppercase. |
| `folio` | integer or null | yes | The certificate's number in the issuer's series (internal_folio is the printed one, RET1…). |
| `internal_folio` | string or null | yes | Internal folio (FolioInt): RET1, RET2… |
| `date` | string or null | yes | Issue date (Fecha), Mexico City time. |
| `code` | string | yes | Withholding key (CveRetenc), c_CveRetenc: 01 professional services, 05 leasing, 14 dividends, 16 interest, 18 payments abroad… Keys 06 and 14 to 24 carry their complement, as SAT's catalog asks (share_sale with 06 and 19, dividends with 14, distributable_remainder with 15, interest, trust_lease, foreign_payment, prize, trust, retirement_plan, mortgage_interest, financial_derivatives); 01, 02, 04 and 05 carry foreign_payment when the recipient is foreign; 26 (technology platforms) carries platform, and its totals and taxes are calculated from the operations. 27 and 28 can't be issued here. |
| `description` | string or null | yes | Withholding description (DescRetenc). |
| `recipient` | object | yes | Recipient of the certificate (Receptor): domestic with RFC and postal code, or foreign. |
| `recipient.foreign` | boolean | yes | true if the recipient is foreign (without an RFC). |
| `recipient.tax_id` | string or null | yes | RFC (Rfc), 12 characters for a persona moral and 13 for a persona física. |
| `recipient.legal_name` | string or null | yes | Name or razón social exactly as on the constancia de situación fiscal, without the capital regime (without «S.A. de C.V.»). |
| `recipient.zip` | string |  | Postal code of the tax address, 5 digits, as on the constancia de situación fiscal. An issuer's is the place of issue (LugarExpedicion) of its CFDIs. |
| `recipient.curp` | string or null |  | CURP, 18 characters. |
| `period` | object | yes | Period (Periodo): start month, end month and year. |
| `period.year` | integer | yes | Year (Ejercicio). (from -9007199254740991 to 9007199254740991) |
| `period.from_month` | integer | yes | Start month (MesIni), 1 to 12. (from -9007199254740991 to 9007199254740991) |
| `period.to_month` | integer | yes | End month (MesFin), 1 to 12, in the same year. (from -9007199254740991 to 9007199254740991) |
| `totals` | object | yes | Totals (Totales). |
| `totals.operation` | number or null | yes | Total amount of the operation (MontoTotOperacion). |
| `totals.taxed` | number or null | yes | Taxed amount (MontoTotGrav). By default, operation minus exempt. |
| `totals.exempt` | number or null | yes | Exempt amount (MontoTotExent). 0 by default. |
| `totals.withheld` | number or null | yes | Total withheld (MontoTotRet). |
| `taxes` | array of object | yes | The CFDI's taxes, by type. |
| `taxes[].tax` | string | yes | Tax: isr, iva or ieps (ImpuestoRet 001, 002, 003). |
| `taxes[].base` | number | yes | Base of the withheld tax (BaseRet). |
| `taxes[].amount` | number | yes | Amount withheld (MontoRet). |
| `taxes[].payment_type` | string | yes | Withholding payment type (TipoPagoRet): 01 final VAT, 02 final IEPS, 03 final ISR, 04 provisional ISR. By default the usual one for each tax. |
| `dividends` | object |  | Dividends complement. |
| `interest` | object |  | Interest complement. |
| `foreign_payment` | object |  | Payments to foreigners complement: required with code 18, and with 01, 02, 04 and 05 when the recipient is foreign. |
| `distributable_remainder` | object |  | Dividends complement with its Remanente node (distributable remainder), required with code 15. If you don't send it, it goes without a share. |
| `trust_lease` | object |  | Lease in trust complement (Arrendamientoenfideicomiso 1.0), required with code 17. |
| `share_sale` | object |  | Sale of shares or securities transactions complement (EnajenaciondeAcciones 1.0), required with code 06 and 19. |
| `prize` | object |  | Prizes complement (Premios 1.0), required with code 20. Its amounts are those of totals. |
| `trust` | object |  | Complement for trusts that don't carry out business activities (Fideicomisonoempresarial 1.0), required with code 21. |
| `retirement_plan` | object |  | Personal retirement plans complement (Planesderetiro 1.1), required with code 22: the previous year's figures. |
| `mortgage_interest` | object |  | Deductible real interest on mortgage loans complement (Intereseshipotecarios 1.0), required with code 23. |
| `financial_derivatives` | object |  | Equity derivative financial operations complement (Operacionesconderivados 1.0), required with code 24. |
| `platform` | object |  | Technology platform services complement (ServiciosPlataformasTecnologicas 1.0), required with code 26: one certificate per month, recipient and service type. totals and taxes are calculated from services with SAT's rates (ISR from LISR 113-A and LIF 2026 art. 25; VAT 50% or 100%; IEPS on betting); if you send them, they must match. |
| `cancellation` | object or null | yes | The cancellation, if requested: status, reason, replacement and when. |
| `cancellation.status` | string | yes | pending (the SAT has it: it finishes it in minutes or waits for the customer's answer), accepted (canceled), rejected (the customer rejected it), lapsed (it expired; you can request it again), scheduled (Fiscalisto requests it again on its own) or failed (Fiscalisto stopped trying; request it again). |
| `cancellation.motive` | string or null | yes | Cancellation reason (c_MotivoCancelacion): 01 with errors, related (carries substitution), 02 with errors, not related (the default), 03 didn't take place, 04 only on a global invoice, when an included sale was invoiced in the customer's name. |
| `cancellation.canceled_at` | string (date-time) or null | yes | When it was canceled. |
| `email` | object or null | yes | The email send: to whom, cc to whom and when (null if it hasn't been sent). |
| `email.to` | string or null | yes | To whom (emails separated by commas). |
| `email.sent_at` | string (date-time) or null | yes | When it was sent. |
| `error` | object or null | yes | Why the SAT or the PAC didn't accept it: message, SAT code and original text. |
| `error.message` | string | yes | What happened and how to fix it, for a person. |
| `error.sat_code` | string or null | yes | SAT or PAC code (CFDI40xxx). |
| `error.raw` | string | yes | The PAC's original text. |
| `created_at` | string (date-time) or null | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |
| `metadata` | object | yes | Your own data: up to 50 keys of 40 characters with text values of up to 500. They don't go into the CFDI; they come back in the object and in webhooks. |
| `warnings` | array of string |  | Warnings that didn't prevent stamping (for example, the XML will be saved later). |
| `email_error` | string |  | Why the email couldn't be sent; the receipt was stamped. |
| `replaced` | object |  | Only when stamping with `replaces`: the certificate it corrects and whether it was canceled (reason 01). If not, `error` says why and it is canceled with POST /v1/sat_retentions/{id}/cancel. |
| `replaced.uuid` | string | yes | Tax folio the SAT assigns (UUID of the Timbre Fiscal Digital), in uppercase. |
| `replaced.canceled` | boolean | yes | true if the replaced one is already canceled. false isn't final: see substitutes.cancellation. |
| `replaced.error` | string or null | yes | Why the previous one couldn't be canceled; `null` if it was canceled. |

```json
{
  "id": "ret_OufpKqnrvx9p5tENFcmUXpXJ58XxnF67kv",
  "object": "retention",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "status": "valid",
  "uuid": "9A6F6BF3-6786-4747-800A-C9964E6509AE",
  "folio": 1,
  "internal_folio": "RET1",
  "date": "2026-10-24T10:15:42",
  "code": "01",
  "description": null,
  "recipient": {
    "foreign": false,
    "tax_id": "MASO451221PM4",
    "legal_name": "MARIA OLIVIA MARTINEZ SAGAZ",
    "zip": "80290",
    "curp": null
  },
  "period": {
    "year": 2026,
    "from_month": 9,
    "to_month": 9
  },
  "totals": {
    "operation": 10000,
    "taxed": 10000,
    "exempt": 0,
    "withheld": 2066.67
  },
  "taxes": [
    {
      "tax": "isr",
      "base": 10000,
      "amount": 1000,
      "payment_type": "04"
    },
    {
      "tax": "iva",
      "base": 10000,
      "amount": 1066.67,
      "payment_type": "01"
    }
  ],
  "cancellation": null,
  "email": null,
  "error": null,
  "created_at": "2026-10-24T10:15:42-06:00",
  "metadata": {
    "proveedor": "42"
  }
}
```

## Response 202

The PAC didn't answer in time: the CFDI stays in processing and is stamped on its own in a few moments. Listen for the *.stamped event or look it up with GET; repeating the request with the same Idempotency-Key answers its status without stamping again.

A `Retention` object:

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"retention"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer (iss_…). |
| `status` | `processing`, `valid`, `rejected`, `canceled` | yes | processing: the PAC hasn't answered. valid: stamped. rejected: the SAT or the PAC didn't accept it (see error). canceled: canceled. |
| `uuid` | string or null | yes | Tax folio the SAT assigns (UUID of the Timbre Fiscal Digital), in uppercase. |
| `folio` | integer or null | yes | The certificate's number in the issuer's series (internal_folio is the printed one, RET1…). |
| `internal_folio` | string or null | yes | Internal folio (FolioInt): RET1, RET2… |
| `date` | string or null | yes | Issue date (Fecha), Mexico City time. |
| `code` | string | yes | Withholding key (CveRetenc), c_CveRetenc: 01 professional services, 05 leasing, 14 dividends, 16 interest, 18 payments abroad… Keys 06 and 14 to 24 carry their complement, as SAT's catalog asks (share_sale with 06 and 19, dividends with 14, distributable_remainder with 15, interest, trust_lease, foreign_payment, prize, trust, retirement_plan, mortgage_interest, financial_derivatives); 01, 02, 04 and 05 carry foreign_payment when the recipient is foreign; 26 (technology platforms) carries platform, and its totals and taxes are calculated from the operations. 27 and 28 can't be issued here. |
| `description` | string or null | yes | Withholding description (DescRetenc). |
| `recipient` | object | yes | Recipient of the certificate (Receptor): domestic with RFC and postal code, or foreign. |
| `recipient.foreign` | boolean | yes | true if the recipient is foreign (without an RFC). |
| `recipient.tax_id` | string or null | yes | RFC (Rfc), 12 characters for a persona moral and 13 for a persona física. |
| `recipient.legal_name` | string or null | yes | Name or razón social exactly as on the constancia de situación fiscal, without the capital regime (without «S.A. de C.V.»). |
| `recipient.zip` | string |  | Postal code of the tax address, 5 digits, as on the constancia de situación fiscal. An issuer's is the place of issue (LugarExpedicion) of its CFDIs. |
| `recipient.curp` | string or null |  | CURP, 18 characters. |
| `period` | object | yes | Period (Periodo): start month, end month and year. |
| `period.year` | integer | yes | Year (Ejercicio). (from -9007199254740991 to 9007199254740991) |
| `period.from_month` | integer | yes | Start month (MesIni), 1 to 12. (from -9007199254740991 to 9007199254740991) |
| `period.to_month` | integer | yes | End month (MesFin), 1 to 12, in the same year. (from -9007199254740991 to 9007199254740991) |
| `totals` | object | yes | Totals (Totales). |
| `totals.operation` | number or null | yes | Total amount of the operation (MontoTotOperacion). |
| `totals.taxed` | number or null | yes | Taxed amount (MontoTotGrav). By default, operation minus exempt. |
| `totals.exempt` | number or null | yes | Exempt amount (MontoTotExent). 0 by default. |
| `totals.withheld` | number or null | yes | Total withheld (MontoTotRet). |
| `taxes` | array of object | yes | The CFDI's taxes, by type. |
| `taxes[].tax` | string | yes | Tax: isr, iva or ieps (ImpuestoRet 001, 002, 003). |
| `taxes[].base` | number | yes | Base of the withheld tax (BaseRet). |
| `taxes[].amount` | number | yes | Amount withheld (MontoRet). |
| `taxes[].payment_type` | string | yes | Withholding payment type (TipoPagoRet): 01 final VAT, 02 final IEPS, 03 final ISR, 04 provisional ISR. By default the usual one for each tax. |
| `dividends` | object |  | Dividends complement. |
| `interest` | object |  | Interest complement. |
| `foreign_payment` | object |  | Payments to foreigners complement: required with code 18, and with 01, 02, 04 and 05 when the recipient is foreign. |
| `distributable_remainder` | object |  | Dividends complement with its Remanente node (distributable remainder), required with code 15. If you don't send it, it goes without a share. |
| `trust_lease` | object |  | Lease in trust complement (Arrendamientoenfideicomiso 1.0), required with code 17. |
| `share_sale` | object |  | Sale of shares or securities transactions complement (EnajenaciondeAcciones 1.0), required with code 06 and 19. |
| `prize` | object |  | Prizes complement (Premios 1.0), required with code 20. Its amounts are those of totals. |
| `trust` | object |  | Complement for trusts that don't carry out business activities (Fideicomisonoempresarial 1.0), required with code 21. |
| `retirement_plan` | object |  | Personal retirement plans complement (Planesderetiro 1.1), required with code 22: the previous year's figures. |
| `mortgage_interest` | object |  | Deductible real interest on mortgage loans complement (Intereseshipotecarios 1.0), required with code 23. |
| `financial_derivatives` | object |  | Equity derivative financial operations complement (Operacionesconderivados 1.0), required with code 24. |
| `platform` | object |  | Technology platform services complement (ServiciosPlataformasTecnologicas 1.0), required with code 26: one certificate per month, recipient and service type. totals and taxes are calculated from services with SAT's rates (ISR from LISR 113-A and LIF 2026 art. 25; VAT 50% or 100%; IEPS on betting); if you send them, they must match. |
| `cancellation` | object or null | yes | The cancellation, if requested: status, reason, replacement and when. |
| `cancellation.status` | string | yes | pending (the SAT has it: it finishes it in minutes or waits for the customer's answer), accepted (canceled), rejected (the customer rejected it), lapsed (it expired; you can request it again), scheduled (Fiscalisto requests it again on its own) or failed (Fiscalisto stopped trying; request it again). |
| `cancellation.motive` | string or null | yes | Cancellation reason (c_MotivoCancelacion): 01 with errors, related (carries substitution), 02 with errors, not related (the default), 03 didn't take place, 04 only on a global invoice, when an included sale was invoiced in the customer's name. |
| `cancellation.canceled_at` | string (date-time) or null | yes | When it was canceled. |
| `email` | object or null | yes | The email send: to whom, cc to whom and when (null if it hasn't been sent). |
| `email.to` | string or null | yes | To whom (emails separated by commas). |
| `email.sent_at` | string (date-time) or null | yes | When it was sent. |
| `error` | object or null | yes | Why the SAT or the PAC didn't accept it: message, SAT code and original text. |
| `error.message` | string | yes | What happened and how to fix it, for a person. |
| `error.sat_code` | string or null | yes | SAT or PAC code (CFDI40xxx). |
| `error.raw` | string | yes | The PAC's original text. |
| `created_at` | string (date-time) or null | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |
| `metadata` | object | yes | Your own data: up to 50 keys of 40 characters with text values of up to 500. They don't go into the CFDI; they come back in the object and in webhooks. |
| `warnings` | array of string |  | Warnings that didn't prevent stamping (for example, the XML will be saved later). |
| `email_error` | string |  | Why the email couldn't be sent; the receipt was stamped. |
| `replaced` | object |  | Only when stamping with `replaces`: the certificate it corrects and whether it was canceled (reason 01). If not, `error` says why and it is canceled with POST /v1/sat_retentions/{id}/cancel. |
| `replaced.uuid` | string | yes | Tax folio the SAT assigns (UUID of the Timbre Fiscal Digital), in uppercase. |
| `replaced.canceled` | boolean | yes | true if the replaced one is already canceled. false isn't final: see substitutes.cancellation. |
| `replaced.error` | string or null | yes | Why the previous one couldn't be canceled; `null` if it was canceled. |

```json
{
  "id": "ret_OufpKqnrvx9p5tENFcmUXpXJ58XxnF67kv",
  "object": "retention",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "status": "processing",
  "uuid": null,
  "folio": 1,
  "internal_folio": "RET1",
  "date": "2026-10-24T10:15:42",
  "code": "01",
  "description": null,
  "recipient": {
    "foreign": false,
    "tax_id": "MASO451221PM4",
    "legal_name": "MARIA OLIVIA MARTINEZ SAGAZ",
    "zip": "80290",
    "curp": null
  },
  "period": {
    "year": 2026,
    "from_month": 9,
    "to_month": 9
  },
  "totals": {
    "operation": 10000,
    "taxed": 10000,
    "exempt": 0,
    "withheld": 2066.67
  },
  "taxes": [
    {
      "tax": "isr",
      "base": 10000,
      "amount": 1000,
      "payment_type": "04"
    },
    {
      "tax": "iva",
      "base": 10000,
      "amount": 1066.67,
      "payment_type": "01"
    }
  ],
  "cancellation": null,
  "email": null,
  "error": null,
  "created_at": "2026-10-24T10:15:42-06:00",
  "metadata": {
    "proveedor": "42"
  }
}
```

## Errors

- `daily_limit` (429): You reached today's limit of something not paid with stamps. Retry-After says how many seconds until midnight in Mexico City.
- `feature_not_in_plan` (403): Live, this part of the API (inventario, portal de proveedores, pedidos, comprobación de gastos) follows the empresa's plan, as in the app: it comes with Operaciones (added to any paid plan; included in Corporativo). The books (the /v1/accounting routes except DIOT, cross checks, IVA refunds and fixed assets) come with Contabilidad (added to Independiente, Emprendedor or Negocio; included in Despacho and Corporativo): without it, changing the books answers this error, and reading them works only up to the last month it had it. Add either in Ajustes › Plan y pagos; test mode has everything.
- `idempotency_key_missing` (400): Stamping requires the Idempotency-Key header (8 to 255 characters, a new one per document), so a retry never stamps twice.
- `insufficient_balance` (402): The account has no live stamps left: to stamp, check RFCs against SAT's lists, look up constancias, request SAT downloads or fetch declarations, the compliance opinion or the mailbox from SAT. Buy a pack in Desarrolladores › Timbres y pagos, or turn on auto-recharge. Never happens in test mode.
- `issuer_archived` (400): The issuer is archived and no longer stamps. Its documents can still be read and canceled.
- `issuer_linked_empresa` (403): That issuer is an empresa of the app connected to your account: through the API it only offers its Portal de proveedores (/v1/portal_suppliers and /v1/supplier_invoices) and, once someone who may pay suppliers and change Configurar pagos turned them on, its supplier payouts (/v1/payouts and /v1/payroll_payouts). It also stops when whoever connected it (or turned its payouts on) no longer has that permission in the empresa: message_es says which. Do everything else in the app.
- `issuer_missing` (404): There is no such issuer in the account (or it belongs to the other mode).
- `issuer_not_allowed` (403): This key can't use that issuer.
- `issuer_required` (400): The account has several issuers and the request doesn't say which: send `issuer` (iss_…).
- `livemode_mismatch` (400): The object belongs to the other mode: an fk_test_ key only sees test data and an fk_live_ key only live data.
- `request_in_progress` (409): Another request with the same Idempotency-Key is still running. Repeat it in a moment with the same key: it will answer the same.
- `resource_missing` (404): There's no object with that id (or it belongs to another issuer or the other mode).
- `retention_invalid` (422): The retentions certificate breaks a SAT rule. No stamp was used.
- `retention_rejected` (422): The PAC or the SAT didn't accept the certificate; `sat_code` has their code.
- `stamp_rate_limit` (429): Too many stamps in a row for the same issuer. Wait what Retry-After says; for many invoices use POST /v1/invoice_batches, for a payroll run POST /v1/payroll_batches.

Plus those of any call (key, fields, limits): https://fiscalisto.com/en/docs/api/errores.md.
