Docs
MCP serverAvailable tools

Create withholding document

Create and immediately stamp a SAT withholding document.

MCP toolcreate_withholding

Purpose

Use when
A withholding document is ready for issuance.
Do not use when
You need a draft CFDI or a normal income/receipt document.
Required permissions
invoices:manage
Side effects
Destructive and external
Idempotency
Idempotent

Input schema

JSON Schema
{  "type": "object",  "properties": {    "idempotencyKey": {      "type": "string",      "minLength": 1,      "maxLength": 200,      "description": "Unique retry key for this exact operation. Reuse it only when retrying the same request."    },    "input": {      "type": "object",      "properties": {        "description": {          "description": "Required when withholdingTypeCode is 25",          "allOf": [            {              "type": "string",              "minLength": 1,              "maxLength": 100            }          ]        },        "internalFolio": {          "type": "string",          "pattern": "^[0-9A-Za-z]{1,20}$"        },        "customerId": {          "type": "string",          "minLength": 1        },        "withholdingTypeCode": {          "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"          ],          "description": "Known SAT withholding-type code.",          "x-exac-sat-catalog": "withholding-types"        },        "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",          "allOf": [            {              "type": "number",              "minimum": 0            }          ]        },        "taxes": {          "minItems": 1,          "type": "array",          "items": {            "type": "object",            "properties": {              "tax": {                "enum": [                  "isr",                  "iva",                  "ieps"                ]              },              "amount": {                "type": "number",                "exclusiveMinimum": 0,                "description": "Amount retained in pesos"              },              "paymentType": {                "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}))?$"        },        "pdfCustomSection": {          "type": "string"        }      },      "required": [        "customerId",        "withholdingTypeCode",        "period",        "operationAmount",        "taxes"      ],      "additionalProperties": false    }  },  "required": [    "idempotencyKey",    "input"  ],  "$schema": "http://json-schema.org/draft-07/schema#",  "additionalProperties": false}

Output schema

JSON Schema
{  "type": "object",  "properties": {    "data": {      "type": "object",      "properties": {        "simulated": {          "allOf": [            {              "type": "boolean",              "const": true            }          ]        },        "documentRef": {          "type": "string",          "pattern": "^withholding:.+$"        },        "status": {          "const": "valid"        }      },      "required": [        "documentRef",        "status"      ],      "additionalProperties": false    },    "error": {      "$schema": "http://json-schema.org/draft-07/schema#",      "type": "object",      "properties": {        "code": {          "enum": [            "validation_error",            "unauthenticated",            "forbidden",            "payment_required",            "not_found",            "method_not_allowed",            "conflict",            "idempotency_conflict",            "operation_in_progress",            "recovery_required",            "migration_required",            "rate_limited",            "provider_unavailable",            "internal"          ]        },        "message": {          "type": "string"        },        "details": {          "type": "object",          "properties": {            "document": {              "type": "object",              "properties": {                "documentRef": {                  "type": "string",                  "pattern": "^(invoice|withholding|sales_receipt|declaration|tax_compliance_opinion|sales_receipt_refund):.+$"                },                "editable": {                  "type": "boolean"                }              },              "required": [                "documentRef",                "editable"              ],              "additionalProperties": false            },            "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            },            "reason": {              "type": "string"            },            "balanceMinor": {              "type": "integer",              "minimum": 0,              "maximum": 9007199254740991            },            "topUpUrl": {              "type": "string"            }          },          "additionalProperties": false        }      },      "required": [        "code",        "message"      ],      "additionalProperties": false    }  },  "$schema": "http://json-schema.org/draft-07/schema#",  "additionalProperties": false,  "oneOf": [    {      "required": [        "data"      ]    },    {      "required": [        "error"      ]    }  ]}

Related workflow

See the canonical workflows in Quickstart

Related tools