---
title: "Archive fiscal document"
description: "Archive or restore a CFDI or withholding document without deleting its fiscal or authoring history."
language: en
canonical_url: "https://exac.mx/docs/en/mcp/tools/archive_fiscal_document"
md_url: "https://exac.mx/docs/en/mcp/tools/archive_fiscal_document.md"
---

# Archive fiscal document

Archive or restore a CFDI or withholding document without deleting its fiscal or authoring history.

Tool: `archive_fiscal_document`

## Purpose

Archive or restore a CFDI or withholding document without deleting its history.

### Use when

A fiscal document should be hidden from normal working views.

### Do not use when

You need SAT cancellation or the document is still being authored.

| Detail | Value |
| --- | --- |
| Permissions | invoices:manage |
| Side effects | Writes data |
| Idempotency | Idempotent |

## Input schema

```json
{
  "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": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "archived": {
              "$ref": "#/definitions/__schema0"
            },
            "documentRef": {
              "type": "string",
              "pattern": "^cfdi:.+$"
            }
          },
          "required": [
            "archived",
            "documentRef"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "archived": {
              "$ref": "#/definitions/__schema0"
            },
            "documentRef": {
              "type": "string",
              "pattern": "^withholding:.+$"
            }
          },
          "required": [
            "archived",
            "documentRef"
          ],
          "additionalProperties": false
        }
      ]
    }
  },
  "required": [
    "idempotencyKey",
    "input"
  ],
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false,
  "definitions": {
    "__schema0": {
      "type": "boolean",
      "description": "true archives a fiscal document; false restores it"
    }
  }
}
```

## Output schema

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "documentRef": {
          "type": "string",
          "pattern": "^(cfdi|withholding|sales_receipt|quote|expense|declaration|tax_compliance_opinion|sales_receipt_refund):.+$"
        },
        "archived": {
          "type": "boolean"
        }
      },
      "required": [
        "documentRef",
        "archived"
      ],
      "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"
      ]
    }
  ]
}
```

## Related tools

- [`get_document`](/docs/en/mcp/tools/get_document.md) — **Get document**: Retrieve one document by its public documentRef. Sales receipt details include stable lineRef values and remaining refundable amounts for sales receipt refunds.

- [`cancel_fiscal_document`](/docs/en/mcp/tools/cancel_fiscal_document.md) — **Cancel fiscal document**: Request SAT cancellation for a stamped CFDI or withholding document. Drafts should be archived instead.

## Related workflow

[See the canonical workflows in the introduction](/docs/en.md)

## Equivalent REST operations

- [`PUT /v1/cfdis/{documentRef}/archive`](/docs/en/api/documents/cfdi/archive-cfdi.md)

- [`PUT /v1/withholdings/{documentRef}/archive`](/docs/en/api/documents/withholding-documents/archive-withholding.md)

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