# Withholding certificates

> Stamp the withholding and payment information certificate (CFDI de Retenciones 2.0) for what you withheld from a supplier: professional fees, rent, dividends, interest or payments abroad.

When a company pays an individual for professional fees or rent, it withholds ISR and IVA and must give them a **withholding certificate**: a CFDI de Retenciones 2.0, different from an invoice, with what it paid and what it withheld in the period. With the API you stamp it with the same folios (RET1, RET2…), checks and timbres as **Retenciones** in the app. Each certificate uses one timbre; cancelling it is free.

## Stamp one

What was withheld in September from a lawyer for $10,000 in fees: 10% ISR and two thirds of the IVA.

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/retentions \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ret-2026-09-gora" \
  -d '{
    "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 }
    ],
    "send_email": true,
    "email": "ana@example.com"
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from 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 },
  ],
  send_email: true,
  email: "ana@example.com",
}, { idempotencyKey: "ret-2026-09-gora" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from 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,
        },
    ],
    "send_email": True,
    "email": "ana@example.com",
}, idempotency_key="ret-2026-09-gora")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from 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,
        ],
    ],
    'send_email' => true,
    'email' => 'ana@example.com',
], ['idempotency_key' => 'ret-2026-09-gora']);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from 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},
		},
		SendEmail: fiscalisto.Bool(true),
		Email:     fiscalisto.String("ana@example.com"),
	}, fiscalisto.WithIdempotencyKey("ret-2026-09-gora"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(retention.ID)
}
```

```java tab="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;

// The key comes from 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)
        ))
        .setSendEmail(true)
        .setEmail("ana@example.com"), RequestOptions.idempotencyKey("ret-2026-09-gora"));
System.out.println(retention.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from 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,
        },
    },
    SendEmail = true,
    Email = "ana@example.com",
}, new RequestOptions { IdempotencyKey = "ret-2026-09-gora" });
```

The response is the certificate (`ret_…`) with `status: "valid"`, its `uuid`, its folio in `internal_folio` and the total withheld in `totals.withheld`. The `retention.stamped` webhook also arrives. With `send_email` the receiver gets the PDF and the XML at `email`. If the stamping answer was lost and the certificate stamps later, the email goes out on its own once it's confirmed, only once.

| Field | What it is |
| --- | --- |
| `code` | The withholding's key (c_CveRetenc): `01` professional services, `05` rent, `14` dividends, `16` interest, `18` payments to non-residents, `25` other (with `description`), and the rest of the catalog. The ones that carry a complement are below. |
| `recipient` | Who was withheld from: their RFC, name and postal code as on their constancia de situación fiscal (SAT compares them). A non-resident goes with `foreign: true`, their tax identification number in `tax_id` and no postal code. |
| `period` | The month (`month`) or months (`from_month` and `to_month`) of the year it covers, already finished or the current one. A supplier's annual certificate goes with `from_month: 1` and `to_month: 12`. |
| `totals` | The operation's amount; `taxed` and `exempt` if part of it is exempt (without them, everything is taxed). |
| `taxes` | Each tax withheld: `isr`, `iva` or `ieps`, its base and the amount. `payment_type` is SAT's payment type (c_TipoPagoRet); by default `04` for ISR (provisional payment), `01` for IVA and `02` for IEPS. |

The keys SAT requires with a complement carry their object, with the reference's names:

| `code` | Object | SAT complement |
| --- | --- | --- |
| `01`, `02`, `04`, `05` with `recipient.foreign` | `foreign_payment` | Pagos a extranjeros 1.0 |
| `06` | `share_sale` | Enajenación de acciones 1.0 |
| `14` | `dividends` | Dividendos 1.0 |
| `15` | `distributable_remainder` | Dividendos 1.0, with its Remanente node (`proportion` optional; without the object it goes without a proportion) |
| `16` | `interest` | Intereses 1.0 |
| `17` | `trust_lease` | Arrendamiento en fideicomiso 1.0 |
| `18` | `foreign_payment` | Pagos a extranjeros 1.0 |
| `19` | `share_sale` | Enajenación de acciones 1.0 |
| `20` | `prize` | Premios 1.0 (`state` and the amounts in `totals`) |
| `21` | `trust` | Fideicomiso no empresarial 1.0 |
| `22` | `retirement_plan` | Planes de retiro 1.1 |
| `23` | `mortgage_interest` | Intereses hipotecarios 1.0 |
| `24` | `financial_derivatives` | Operaciones con derivados 1.0 |
| `26` | `platform` | Servicios de plataformas tecnológicas 1.0 (see below) |

That is what SAT's key catalog (c_CveRetenc) asks for, and SAT refuses the certificate without its complement (Reten20107). Each object only goes with its key; with another it returns `400`. Without it, the certificate returns `422` `retention_invalid` and says what's missing. Keys `27` (financial sector) and `28` (RIF taxpayers) can't be issued through the API: `GET /v1/sat_catalogs/retention_codes` lists them with `supported: false`.

```json
{
  "code": "20",
  "recipient": { "tax_id": "MASO451221PM4", "legal_name": "MARIA OLIVIA MARTINEZ SAGAZ", "zip": "80290" },
  "period": { "year": 2026, "month": 9 },
  "totals": { "operation": 50000 },
  "taxes": [{ "tax": "isr", "base": 50000, "amount": 500, "payment_type": "03" }],
  "prize": { "state": "09" }
}
```

### Digital platforms (key 26)

A digital platform (transport, delivery, lodging, sale of goods, digital services, betting) sends each month to whoever sells through it a certificate with `code: "26"` and each operation in `platform.services`. Don't send `totals` or `taxes`: Fiscalisto calculates them from the operations as SAT requires (what was collected in cash outside the base, ISR at the rate for the service type and year, half or all of the IVA, truncated to the cent). If you send them, they must match.

| Field | What it is |
| --- | --- |
| `platform.type` | The service type (c_TipoDeServ): `01` transport, `02` delivery, `03` other transport, `04` lodging, `05` sale of goods, `06` other services, `07` to `09` digital services to foreigners, `11` betting and raffles (from 2026). One per certificate. |
| `platform.periodicity` | How often the platform pays them (c_Periodicidad): `01` weekly, `02` monthly (default), `03` daily, `04` fortnightly, `05` other. |
| `platform.isr_definitive` | `true` if the individual chose for the ISR to be a definitive payment (LISR 113-B): the ISR goes with `payment_type` `03`. |
| `platform.foreign_account` | `true` if they're paid into an account abroad: 100% of the IVA is withheld. |
| `services[].date` | The day the customer paid (`YYYY-MM-DD`), within the certificate's month. |
| `services[].payment_form` | Payment form (c_FormaPagoServ): `01` cash, `03` transfer, `04` credit card… `09` prizes or rebates (no tax or commission, they don't add to the total). |
| `services[].price` | The price before IVA. |
| `services[].rate` | The transferred tax rate: `0.16` (default), `0.08`, `0` or `0.5` (IEPS, betting only). |
| `services[].subtype` | Transport: `01` personal (default), `02` shared, `03` plus, `04` cancellation. Betting: `08` games with bets (default), `09` raffles. |
| `services[].commission` | What the platform charged (`amount`) and, if you know it, its `percent`. It goes on each operation with IVA; not on prizes or IEPS ones. |
| `services[].contribution` | A government contribution paid (for example the lodging tax): `amount` and the `state` (01 to 32). |
| `services[].authorized_tax_id` | The authorized third party's RFC (an individual), if any. |

Up to 5,000 operations per certificate, from a single month. Betting and raffles carry two operations per sale: one with IVA and another with `rate: 0.5` (IEPS).

```json
{
  "code": "26",
  "recipient": { "tax_id": "MASO451221PM4", "legal_name": "MARIA OLIVIA MARTINEZ SAGAZ", "zip": "80290" },
  "period": { "year": 2026, "month": 10 },
  "platform": {
    "type": "01",
    "services": [
      { "date": "2026-10-03", "payment_form": "04", "price": 300, "commission": { "amount": 75 } },
      { "date": "2026-10-31", "payment_form": "01", "price": 120, "commission": { "amount": 30 } }
    ]
  }
}
```

The certificate returns with `totals` and `taxes` already calculated: here ISR of $6.30 (2.1% of the $300 the platform collected) and withheld IVA of $24.00 (half of the $48.00 transferred outside cash).

The same `Idempotency-Key` again returns the same certificate, without stamping another. If SAT rejects it, it returns `422` `retention_rejected` with its code in `sat_code`, and `retention.failed` arrives.

## Email it later

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/retentions/ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D/send \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "to": "ana@example.com, contabilidad@example.com" }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const retention = await fiscalisto.retentions.send("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", {
  to: "ana@example.com, contabilidad@example.com",
});
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

retention = fiscalisto.retentions.send("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", {
    "to": "ana@example.com, contabilidad@example.com",
})
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$retention = $fiscalisto->retentions->send('ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D', [
    'to' => 'ana@example.com, contabilidad@example.com',
]);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	retention, err := client.Retentions.Send(ctx, "ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", &fiscalisto.SendRetentionParams{
		To: fiscalisto.String("ana@example.com, contabilidad@example.com"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(retention.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.SendRetentionParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var retention = fiscalisto.retentions().send("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", new SendRetentionParams()
        .setTo("ana@example.com, contabilidad@example.com"));
System.out.println(retention.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var retention = await fiscalisto.Retentions.SendAsync("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", new SendRetentionParams
{
    To = "ana@example.com, contabilidad@example.com",
});
```

Without `to`, it goes to the receiver's saved email. If it couldn't be sent, it returns `email_failed` and says why; two simultaneous sends of the same certificate do too (the second isn't sent).

## Download it

[`GET /v1/retentions/{id}/pdf`](https://fiscalisto.com/en/docs/api/referencia/retenciones/get-retention-pdf) gives the PDF and [`/xml`](https://fiscalisto.com/en/docs/api/referencia/retenciones/get-retention-xml) the stamped XML. [`GET /v1/retentions`](https://fiscalisto.com/en/docs/api/referencia/retenciones/list-retentions) lists them, newest first, and filters by `status` (`valid`, `canceled`, `rejected`, `processing`), by `recipient` (an RFC) and by `year`.

## Cancel it

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/retentions/ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D/cancel \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "motive": "02" }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const retention = await fiscalisto.retentions.cancel("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", { motive: "02" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

retention = fiscalisto.retentions.cancel("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", {"motive": "02"})
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$retention = $fiscalisto->retentions->cancel('ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D', ['motive' => '02']);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	retention, err := client.Retentions.Cancel(ctx, "ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", &fiscalisto.CancelRetentionParams{
		Motive: fiscalisto.String("02"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(retention.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.CancelRetentionParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var retention = fiscalisto.retentions().cancel("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", new CancelRetentionParams().setMotive("02"));
System.out.println(retention.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var retention = await fiscalisto.Retentions.CancelAsync("ret_PhBIUaMpw23r7krC5Vs3pDT6dB7C2wuY0D", new CancelRetentionParams { Motive = "02" });
```

A certificate is cancelled right away: the receiver doesn't have to accept it. `retention.canceled` arrives. With reason `01` (it had errors and another replaces it), stamp the correct one first and send it in `substitution` (its `ret_…` or its UUID): it must be another current certificate of the same issuer.

To correct one in a single step, stamp the correct one with `replaces`, the UUID of the one it replaces: the new one carries the relation to it (`TipoRelacion` `04`) and, once stamped, Fiscalisto cancels the old one with reason `01`. It also works for one that came from the SAT and wasn't stamped in Fiscalisto, if it has the same issuer and the same receiver. The response has `replaced`: the UUID, `canceled` and, if it couldn't be cancelled, `error`; then the new one stays stamped and you cancel the old one with `01` as above.
