---
title: "Crear gasto"
description: "Registra un gasto operativo con monto, fecha de negocio, categoría y estado de liquidación."
language: es-MX
canonical_url: "https://exac.mx/docs/api/documents/expenses/create-expense"
md_url: "https://exac.mx/docs/api/documents/expenses/create-expense.md"
---

# Crear gasto

Registra un gasto operativo con monto, fecha de negocio, categoría y estado de liquidación.

## Solicitud

`POST /v1/expenses`

- **Autorización:** Permiso requerido: `expenses: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/expenses",
  "operation": {
    "operationId": "createExpense",
    "tags": [
      "Expenses"
    ],
    "summary": "Crear gasto",
    "description": "Registra un gasto operativo con monto, fecha de negocio, categoría y estado de liquidación.",
    "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": {
              "supplierId": {
                "type": "string"
              },
              "description": {
                "type": "string",
                "minLength": 1
              },
              "amount": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "categoryName": {
                "type": "string",
                "minLength": 1
              },
              "locationId": {
                "type": "string"
              },
              "businessDate": {
                "type": "string",
                "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
              },
              "notes": {
                "type": "string"
              },
              "settlementMode": {
                "type": "string",
                "enum": [
                  "credit",
                  "paid"
                ]
              },
              "paymentForm": {
                "description": "Active SAT payment-form code.",
                "x-exac-sat-catalog": "payment-forms",
                "oneOf": [
                  {
                    "type": "string",
                    "title": "SAT c_FormaPago",
                    "description": "Consulta códigos y nombres vigentes [aquí](/docs/sat-catalogs/invoicing#payment-forms).",
                    "enum": [
                      "12",
                      "13",
                      "14",
                      "15",
                      "17",
                      "23",
                      "24",
                      "25",
                      "26",
                      "27",
                      "28",
                      "29",
                      "30",
                      "31",
                      "99",
                      "02",
                      "06",
                      "01",
                      "05",
                      "04",
                      "03",
                      "08"
                    ]
                  }
                ]
              },
              "settlementTerms": {
                "type": "object",
                "properties": {
                  "installmentCount": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 60
                  },
                  "firstDue": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "transaction_date"
                          }
                        },
                        "required": [
                          "kind"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "months_after_transaction"
                          },
                          "months": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 60
                          }
                        },
                        "required": [
                          "kind",
                          "months"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "fixed_date"
                          },
                          "date": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "date"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "recurrence": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "anchor_day"
                          }
                        },
                        "required": [
                          "kind"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "day_of_month"
                          },
                          "day": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 31
                          }
                        },
                        "required": [
                          "kind",
                          "day"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "last_day"
                          }
                        },
                        "required": [
                          "kind"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  }
                },
                "required": [
                  "installmentCount",
                  "firstDue",
                  "recurrence"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "description",
              "amount",
              "categoryName",
              "businessDate",
              "settlementMode",
              "paymentForm"
            ],
            "additionalProperties": false
          },
          "example": {
            "supplierId": "supplier-example",
            "description": "Licencia anual de diseño",
            "amount": 1200,
            "categoryName": "Software",
            "businessDate": "2026-07-13",
            "settlementMode": "paid",
            "paymentForm": "03"
          }
        }
      }
    },
    "responses": {
      "201": {
        "description": "Operación completada.",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "$ref": "#/components/schemas/Expense"
                }
              },
              "required": [
                "data"
              ],
              "additionalProperties": false
            },
            "example": {
              "data": {
                "category": "expense",
                "description": "Licencia anual de diseño",
                "supplierName": "Nube Clara",
                "expenseCategory": "Software",
                "settlementMode": "paid",
                "paymentForm": "03",
                "total": {
                  "amount": 1200,
                  "currency": "MXN"
                },
                "documentRef": "expense:nube-clara-20260713",
                "occurredAt": "2026-07-15T12:00:00.000Z",
                "businessDate": "2026-07-13"
              }
            }
          }
        }
      },
      "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 `expenses: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
      },
      "Expense": {
        "type": "object",
        "properties": {
          "category": {
            "type": "string",
            "const": "expense"
          },
          "description": {
            "type": "string"
          },
          "supplierName": {
            "type": "string"
          },
          "expenseCategory": {
            "type": "string"
          },
          "locationName": {
            "type": "string"
          },
          "settlementMode": {
            "type": "string",
            "enum": [
              "credit",
              "paid"
            ]
          },
          "paymentForm": {
            "type": "string"
          },
          "total": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number"
              },
              "currency": {
                "type": "string",
                "const": "MXN"
              }
            },
            "required": [
              "amount",
              "currency"
            ],
            "additionalProperties": false
          },
          "notes": {
            "type": "string"
          },
          "documentRef": {
            "type": "string",
            "pattern": "^expense:.+$"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
          },
          "businessDate": {
            "type": "string",
            "format": "date",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
          }
        },
        "required": [
          "category",
          "description",
          "expenseCategory",
          "settlementMode",
          "paymentForm",
          "total",
          "documentRef",
          "occurredAt",
          "businessDate"
        ],
        "additionalProperties": false
      }
    }
  }
}
```

[OpenAPI 3.1](/openapi.json)

## Herramientas MCP equivalentes

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

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