---
title: "Crear retención"
description: "Crea y timbra una retención a partir de su periodo, monto de operación e impuestos retenidos."
language: es-MX
canonical_url: "https://exac.mx/docs/api/documents/withholding-documents/create-withholding"
md_url: "https://exac.mx/docs/api/documents/withholding-documents/create-withholding.md"
---

# Crear retención

Crea y timbra una retención a partir de su periodo, monto de operación e impuestos retenidos.

## Solicitud

`POST /v1/withholdings`

- **Autorización:** Permiso requerido: `invoices:manage`.

- **Entornos:** Producción y prueba

- **Idempotencia:** Requerida

## Contrato canónico para máquinas

Este fragmento se genera desde la operación canónica y los contratos Zod que utiliza la ruta.

```json
{
  "method": "POST",
  "path": "/v1/withholdings",
  "operation": {
    "operationId": "createWithholding",
    "tags": [
      "Withholding documents"
    ],
    "summary": "Crear retención",
    "description": "Crea y timbra una retención a partir de su periodo, monto de operación e impuestos retenidos.",
    "security": [
      {
        "bearerAuth": []
      }
    ],
    "parameters": [
      {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": "Clave estable para reintentar exactamente la misma solicitud sin duplicar efectos."
      }
    ],
    "requestBody": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "customerId": {
                "type": "string",
                "minLength": 1
              },
              "withholdingTypeCode": {
                "description": "Active SAT withholding-type code.",
                "x-exac-sat-catalog": "withholding-types",
                "oneOf": [
                  {
                    "type": "string",
                    "title": "SAT c_ClaveRetenc",
                    "description": "Consulta códigos y nombres vigentes [aquí](/docs/sat-catalogs/withholdings#withholding-types).",
                    "enum": [
                      "10",
                      "11",
                      "12",
                      "13",
                      "14",
                      "15",
                      "16",
                      "17",
                      "18",
                      "19",
                      "20",
                      "21",
                      "22",
                      "23",
                      "24",
                      "25",
                      "26",
                      "27",
                      "28",
                      "01",
                      "02",
                      "03",
                      "04",
                      "05",
                      "06",
                      "07",
                      "08",
                      "09"
                    ]
                  }
                ]
              },
              "period": {
                "type": "object",
                "properties": {
                  "fromMonth": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 12
                  },
                  "toMonth": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 12
                  },
                  "year": {
                    "type": "integer",
                    "minimum": 2000,
                    "maximum": 2100
                  }
                },
                "required": [
                  "fromMonth",
                  "toMonth",
                  "year"
                ],
                "additionalProperties": false
              },
              "operationAmount": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Operation amount in pesos"
              },
              "exemptAmount": {
                "description": "Exempt amount in pesos; defaults to zero",
                "type": "number",
                "minimum": 0
              },
              "taxes": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "tax": {
                      "type": "string",
                      "enum": [
                        "isr",
                        "iva",
                        "ieps"
                      ]
                    },
                    "amount": {
                      "type": "number",
                      "exclusiveMinimum": 0,
                      "description": "Amount retained in pesos"
                    },
                    "paymentType": {
                      "type": "string",
                      "enum": [
                        "definitive",
                        "provisional"
                      ]
                    }
                  },
                  "required": [
                    "tax",
                    "amount",
                    "paymentType"
                  ],
                  "additionalProperties": false
                }
              },
              "issuedLocalDateTime": {
                "type": "string",
                "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,9}))?$"
              },
              "description": {
                "description": "Required when withholdingTypeCode is 25",
                "type": "string",
                "minLength": 1
              },
              "internalFolio": {
                "type": "string",
                "minLength": 1
              },
              "pdfCustomSection": {
                "type": "string"
              }
            },
            "required": [
              "customerId",
              "withholdingTypeCode",
              "period",
              "operationAmount",
              "taxes"
            ],
            "additionalProperties": false
          },
          "example": {
            "customerId": "customer-example",
            "withholdingTypeCode": "01",
            "period": {
              "fromMonth": 6,
              "toMonth": 6,
              "year": 2026
            },
            "operationAmount": 1000,
            "taxes": [
              {
                "tax": "iva",
                "amount": 160,
                "paymentType": "definitive"
              }
            ]
          },
          "examples": {
            "withholding": {
              "summary": "Withholding document",
              "value": {
                "customerId": "customer-example",
                "withholdingTypeCode": "01",
                "period": {
                  "fromMonth": 6,
                  "toMonth": 6,
                  "year": 2026
                },
                "operationAmount": 1000,
                "taxes": [
                  {
                    "tax": "iva",
                    "amount": 160,
                    "paymentType": "definitive"
                  }
                ]
              }
            }
          }
        }
      }
    },
    "responses": {
      "201": {
        "description": "Operación completada.",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "$ref": "#/components/schemas/WithholdingDocument"
                }
              },
              "required": [
                "data"
              ],
              "additionalProperties": false
            },
            "example": {
              "data": {
                "direction": "issued",
                "status": "valid",
                "archived": false,
                "counterpartyName": "Cliente Ejemplo",
                "total": {
                  "amount": 160,
                  "currency": "MXN"
                },
                "documentRef": "withholding:withholding-example",
                "category": "withholding",
                "withholding": {
                  "withholdingTypeCode": "01",
                  "period": {
                    "fromMonth": 6,
                    "toMonth": 6,
                    "year": 2026
                  },
                  "totals": {
                    "operation": 1000,
                    "retained": 160
                  },
                  "taxes": [
                    {
                      "tax": "iva",
                      "amount": 160
                    }
                  ]
                },
                "detail": {
                  "availability": "complete"
                }
              }
            }
          }
        }
      },
      "400": {
        "description": "Solicitud inválida.\n\n`validation_error`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "401": {
        "description": "Credencial inválida o ausente.\n\n`unauthenticated`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "WWW-Authenticate": {
            "$ref": "#/components/headers/WWWAuthenticate"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "403": {
        "description": "La credencial no incluye el permiso `invoices:manage`.\n\n`forbidden`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "WWW-Authenticate": {
            "$ref": "#/components/headers/WWWAuthenticate"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "404": {
        "description": "Recurso no encontrado.\n\n`not_found`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "405": {
        "description": "Método no permitido.\n\n`method_not_allowed`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Allow": {
            "$ref": "#/components/headers/Allow"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "409": {
        "description": "La operación entra en conflicto con su estado actual o con la clave de idempotencia.\n\nCódigos posibles: `conflict`, `idempotency_conflict`, `operation_in_progress`, `recovery_required`.",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "429": {
        "description": "Demasiadas solicitudes.\n\n`rate_limited`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "500": {
        "description": "Error interno del servidor.\n\n`internal`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "503": {
        "description": "Servicio temporalmente no disponible.\n\n`provider_unavailable`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      }
    },
    "x-exac-environments": [
      "production",
      "sandbox"
    ]
  },
  "components": {
    "schemas": {
      "ApiError": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ProgrammaticError"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "ProgrammaticError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "validation_error",
              "unauthenticated",
              "forbidden",
              "not_found",
              "method_not_allowed",
              "conflict",
              "idempotency_conflict",
              "operation_in_progress",
              "recovery_required",
              "rate_limited",
              "provider_unavailable",
              "internal"
            ],
            "description": "Acción recomendada por código:\n\n- `validation_error` — Corrige cada elemento de details.issues usando su path y código estable.\n- `unauthenticated` — Proporciona una API key o un token de acceso OAuth válido.\n- `forbidden` — Usa una credencial con el permiso requerido.\n- `not_found` — Verifica el identificador del recurso dentro de la organización.\n- `method_not_allowed` — Usa el método HTTP documentado.\n- `conflict` — Actualiza el recurso y resuelve su estado actual.\n- `idempotency_conflict` — Usa otra clave de idempotencia para una solicitud modificada.\n- `operation_in_progress` — Espera el tiempo de Retry-After y repite la misma solicitud.\n- `recovery_required` — No reintentes automáticamente; reconcilia el resultado del proveedor.\n- `rate_limited` — Espera el tiempo de Retry-After antes de reintentar.\n- `provider_unavailable` — Reintenta solo cuando la respuesta marque la falla como reintentable.\n- `internal` — Reintenta después y contacta a soporte si el error persiste."
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "properties": {
              "issues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "path": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "number"
                          }
                        ]
                      }
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "path",
                    "message"
                  ],
                  "additionalProperties": false
                }
              },
              "retryable": {
                "type": "boolean"
              },
              "retryAfterSeconds": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              }
            },
            "additionalProperties": false
          },
          "status": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "code",
          "message",
          "status"
        ],
        "additionalProperties": false
      },
      "WithholdingDocument": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/WithholdingComplete"
          },
          {
            "$ref": "#/components/schemas/WithholdingPartial"
          }
        ]
      },
      "WithholdingPartial": {
        "type": "object",
        "properties": {
          "direction": {
            "type": "string",
            "enum": [
              "issued",
              "received"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "valid",
              "canceled"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "uuid": {
            "type": "string"
          },
          "counterpartyName": {
            "type": "string"
          },
          "total": {
            "$ref": "#/components/schemas/Money"
          },
          "documentRef": {
            "type": "string",
            "pattern": "^withholding:.+$"
          },
          "category": {
            "type": "string",
            "const": "withholding"
          },
          "issuedLocalDateTime": {
            "type": "string",
            "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,9}))?$"
          },
          "detail": {
            "type": "object",
            "properties": {
              "availability": {
                "type": "string",
                "const": "partial"
              },
              "missing": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              }
            },
            "required": [
              "availability",
              "missing"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "direction",
          "status",
          "archived",
          "total",
          "documentRef",
          "category",
          "detail"
        ],
        "additionalProperties": false
      },
      "Money": {
        "type": "object",
        "properties": {
          "amount": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          }
        },
        "required": [
          "amount",
          "currency"
        ],
        "additionalProperties": false
      },
      "WithholdingComplete": {
        "type": "object",
        "properties": {
          "direction": {
            "type": "string",
            "enum": [
              "issued",
              "received"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "valid",
              "canceled"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "uuid": {
            "type": "string"
          },
          "counterpartyName": {
            "type": "string"
          },
          "total": {
            "$ref": "#/components/schemas/Money"
          },
          "documentRef": {
            "type": "string",
            "pattern": "^withholding:.+$"
          },
          "category": {
            "type": "string",
            "const": "withholding"
          },
          "issuedLocalDateTime": {
            "type": "string",
            "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,9}))?$"
          },
          "withholding": {
            "type": "object",
            "properties": {
              "withholdingTypeCode": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "internalFolio": {
                "type": "string"
              },
              "period": {
                "type": "object",
                "properties": {
                  "fromMonth": {
                    "type": "number"
                  },
                  "toMonth": {
                    "type": "number"
                  },
                  "year": {
                    "type": "number"
                  }
                },
                "required": [
                  "fromMonth",
                  "toMonth",
                  "year"
                ],
                "additionalProperties": false
              },
              "totals": {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "number"
                  },
                  "gravable": {
                    "type": "number"
                  },
                  "exempt": {
                    "type": "number"
                  },
                  "retained": {
                    "type": "number"
                  }
                },
                "additionalProperties": false
              },
              "taxes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "tax": {
                      "type": "string"
                    },
                    "amount": {
                      "type": "number"
                    },
                    "paymentType": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "tax",
                    "amount"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "withholdingTypeCode",
              "period",
              "totals",
              "taxes"
            ],
            "additionalProperties": false
          },
          "detail": {
            "type": "object",
            "properties": {
              "availability": {
                "type": "string",
                "const": "complete"
              }
            },
            "required": [
              "availability"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "direction",
          "status",
          "archived",
          "total",
          "documentRef",
          "category",
          "withholding",
          "detail"
        ],
        "additionalProperties": false
      }
    }
  }
}
```

[OpenAPI 3.1](/openapi.json)

## Herramientas MCP equivalentes

- [`create_withholding`](/docs/mcp/tools/create_withholding.md)

Documentación completa: https://exac.mx/docs.md
Índice para agentes: https://exac.mx/docs/llms.txt
