---
title: "Archive withholding"
description: "Archives or restores a withholding document without changing its fiscal status."
language: en
canonical_url: "https://exac.mx/docs/en/api/documents/withholding-documents/archive-withholding"
md_url: "https://exac.mx/docs/en/api/documents/withholding-documents/archive-withholding.md"
---

# Archive withholding

Archives or restores a withholding document without changing its fiscal status.

## Request

`PUT /v1/withholdings/{documentRef}/archive`

- **Authorization:** Required permission: `invoices:manage`.

- **Environments:** Production and sandbox

- **Idempotency:** Required

## Canonical machine contract

This fragment is generated from the canonical operation and Zod contracts used by the route.

```json
{
  "method": "PUT",
  "path": "/v1/withholdings/{documentRef}/archive",
  "operation": {
    "operationId": "archiveWithholding",
    "tags": [
      "Withholding documents"
    ],
    "summary": "Archive withholding",
    "description": "Archives or restores a withholding document without changing its fiscal status.",
    "security": [
      {
        "bearerAuth": []
      }
    ],
    "parameters": [
      {
        "name": "documentRef",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^withholding:.+$"
        }
      },
      {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "description": "Unique retry key for this exact operation. Reuse it only when retrying the same request."
      }
    ],
    "requestBody": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "archived": {
                "type": "boolean",
                "description": "true archives a fiscal document; false restores it"
              }
            },
            "required": [
              "archived"
            ],
            "additionalProperties": false
          },
          "example": {
            "archived": true
          }
        }
      }
    },
    "responses": {
      "200": {
        "description": "Operation completed.",
        "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": true,
                "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": "Invalid request.\n\n`validation_error`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "401": {
        "description": "Missing or invalid credential.\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": "The credential does not include the `invoices:manage` permission.\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": "Resource not found.\n\n`not_found`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "405": {
        "description": "Method not allowed.\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": "The operation conflicts with its current state or idempotency key.\n\nPossible codes: `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": "Too many requests.\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": "Internal server error.\n\n`internal`",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "503": {
        "description": "Service temporarily unavailable.\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": "Recommended action by code:\n\n- `validation_error` — Correct each details.issues entry using its path and stable issue code.\n- `unauthenticated` — Provide a valid API key or OAuth access token.\n- `forbidden` — Use a credential with the required permission.\n- `not_found` — Check the organization-scoped resource identifier.\n- `method_not_allowed` — Use the documented HTTP method.\n- `conflict` — Refresh the resource and resolve its current state.\n- `idempotency_conflict` — Use a new idempotency key for a changed request.\n- `operation_in_progress` — Wait for Retry-After, then repeat the exact request.\n- `recovery_required` — Do not retry automatically; reconcile the provider outcome.\n- `rate_limited` — Wait for Retry-After before retrying.\n- `provider_unavailable` — Retry only when the response marks the failure as retryable.\n- `internal` — Retry later and contact support if the error persists."
          },
          "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)

## Equivalent MCP tools

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

Complete documentation: https://exac.mx/docs/en.md
Agent documentation index: https://exac.mx/docs/en/llms.txt
