Docs
Servidor MCPHerramientas disponibles

Crear retención

Crea y timbra inmediatamente un documento de retención del SAT.

Herramienta MCPcreate_withholding

Propósito

Crea y timbra inmediatamente un documento de retención del SAT.

Usar cuando
Una retención está lista para emitirse.
No usar cuando
Necesitas un borrador CFDI o un ingreso normal.
Permisos requeridos
invoices:manage
Efectos secundarios
Destructivo y externo
Idempotencia
Idempotente

Esquema de entrada

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": {        "customerId": {          "$ref": "#/definitions/__schema0"        },        "withholdingTypeCode": {          "$ref": "#/definitions/__schema1"        },        "period": {          "$ref": "#/definitions/__schema2"        },        "operationAmount": {          "$ref": "#/definitions/__schema6"        },        "exemptAmount": {          "$ref": "#/definitions/__schema7"        },        "taxes": {          "$ref": "#/definitions/__schema9"        },        "issuedLocalDateTime": {          "$ref": "#/definitions/__schema14"        },        "description": {          "$ref": "#/definitions/__schema15"        },        "internalFolio": {          "$ref": "#/definitions/__schema17"        },        "pdfCustomSection": {          "$ref": "#/definitions/__schema18"        }      },      "required": [        "customerId",        "withholdingTypeCode",        "period",        "operationAmount",        "taxes"      ],      "additionalProperties": false    }  },  "required": [    "idempotencyKey",    "input"  ],  "$schema": "http://json-schema.org/draft-07/schema#",  "additionalProperties": false,  "definitions": {    "__schema0": {      "type": "string",      "minLength": 1    },    "__schema1": {      "type": "string",      "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": "Active SAT withholding-type code.",      "x-exac-sat-catalog": "withholding-types"    },    "__schema2": {      "type": "object",      "properties": {        "fromMonth": {          "$ref": "#/definitions/__schema3"        },        "toMonth": {          "$ref": "#/definitions/__schema4"        },        "year": {          "$ref": "#/definitions/__schema5"        }      },      "required": [        "fromMonth",        "toMonth",        "year"      ],      "additionalProperties": false    },    "__schema3": {      "type": "integer",      "minimum": 1,      "maximum": 12    },    "__schema4": {      "type": "integer",      "minimum": 1,      "maximum": 12    },    "__schema5": {      "type": "integer",      "minimum": 2000,      "maximum": 2100    },    "__schema6": {      "type": "number",      "exclusiveMinimum": 0,      "description": "Operation amount in pesos"    },    "__schema7": {      "description": "Exempt amount in pesos; defaults to zero",      "allOf": [        {          "$ref": "#/definitions/__schema8"        }      ]    },    "__schema8": {      "type": "number",      "minimum": 0    },    "__schema9": {      "minItems": 1,      "type": "array",      "items": {        "$ref": "#/definitions/__schema10"      }    },    "__schema10": {      "type": "object",      "properties": {        "tax": {          "$ref": "#/definitions/__schema11"        },        "amount": {          "$ref": "#/definitions/__schema12"        },        "paymentType": {          "$ref": "#/definitions/__schema13"        }      },      "required": [        "tax",        "amount",        "paymentType"      ],      "additionalProperties": false    },    "__schema11": {      "type": "string",      "enum": [        "isr",        "iva",        "ieps"      ]    },    "__schema12": {      "type": "number",      "exclusiveMinimum": 0,      "description": "Amount retained in pesos"    },    "__schema13": {      "type": "string",      "enum": [        "definitive",        "provisional"      ]    },    "__schema14": {      "type": "string",      "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,9}))?$"    },    "__schema15": {      "description": "Required when withholdingTypeCode is 25",      "allOf": [        {          "$ref": "#/definitions/__schema16"        }      ]    },    "__schema16": {      "type": "string",      "minLength": 1    },    "__schema17": {      "type": "string",      "minLength": 1    },    "__schema18": {      "type": "string"    }  }}

Esquema de salida

JSON Schema
{  "type": "object",  "properties": {    "data": {      "type": "object",      "properties": {        "documentRef": {          "type": "string",          "pattern": "^withholding:.+$"        },        "status": {          "type": "string",          "const": "valid"        }      },      "required": [        "documentRef",        "status"      ],      "additionalProperties": false    },    "error": {      "$schema": "http://json-schema.org/draft-07/schema#",      "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"          ]        },        "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        }      },      "required": [        "code",        "message"      ],      "additionalProperties": false    }  },  "$schema": "http://json-schema.org/draft-07/schema#",  "additionalProperties": false,  "oneOf": [    {      "required": [        "data"      ]    },    {      "required": [        "error"      ]    }  ]}

Flujo relacionado

Consulta los flujos canónicos en la introducción

Herramientas relacionadas