---
title: "Get document file"
description: "Retrieve one document file as an MCP binary resource. Use preview_pdf to render an unstamped CFDI draft before stamping; the preview has no fiscal validity. CFDIs also support pdf, xml, zip, cancellation_pdf, and cancellation_xml; withholdings support pdf, xml, and zip; sales receipts and quotes support pdf; declarations support pdf, payment_pdf, and full_pdf; opinions support pdf."
language: en
canonical_url: "https://exac.mx/docs/en/mcp/tools/get_document_file"
md_url: "https://exac.mx/docs/en/mcp/tools/get_document_file.md"
---

# Get document file

Retrieve one document file as an MCP binary resource. Use preview_pdf to render an unstamped CFDI draft before stamping; the preview has no fiscal validity. CFDIs also support pdf, xml, zip, cancellation_pdf, and cancellation_xml; withholdings support pdf, xml, and zip; sales receipts and quotes support pdf; declarations support pdf, payment_pdf, and full_pdf; opinions support pdf.

Tool: `get_document_file`

## Purpose

Retrieve one available document file as an MCP binary resource.

### Use when

You have a public documentRef and need an available file, including a preview_pdf for an unstamped CFDI draft.

### Do not use when

You need document metadata or a file for an unsupported document family.

| Detail | Value |
| --- | --- |
| Permissions | invoices:read / receipts:read / quotes:read / sat:read |
| Side effects | None |
| Idempotency | Idempotent |

## Input schema

```json
{
  "type": "object",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "documentRef": {
          "type": "string",
          "pattern": "^cfdi:.+$",
          "description": "CFDI documentRef returned by search_documents"
        },
        "file": {
          "type": "string",
          "enum": [
            "pdf",
            "xml",
            "zip",
            "preview_pdf",
            "cancellation_pdf",
            "cancellation_xml"
          ]
        }
      },
      "required": [
        "documentRef",
        "file"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "documentRef": {
          "type": "string",
          "pattern": "^withholding:.+$",
          "description": "Withholding documentRef returned by search_documents"
        },
        "file": {
          "type": "string",
          "enum": [
            "pdf",
            "xml",
            "zip"
          ]
        }
      },
      "required": [
        "documentRef",
        "file"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "documentRef": {
          "type": "string",
          "pattern": "^sales_receipt:.+$"
        },
        "file": {
          "type": "string",
          "const": "pdf"
        }
      },
      "required": [
        "documentRef",
        "file"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "documentRef": {
          "type": "string",
          "pattern": "^quote:.+$"
        },
        "file": {
          "type": "string",
          "const": "pdf"
        }
      },
      "required": [
        "documentRef",
        "file"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "documentRef": {
          "type": "string",
          "pattern": "^declaration:.+$"
        },
        "file": {
          "type": "string",
          "enum": [
            "pdf",
            "payment_pdf",
            "full_pdf"
          ]
        }
      },
      "required": [
        "documentRef",
        "file"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "documentRef": {
          "type": "string",
          "pattern": "^tax_compliance_opinion:.+$"
        },
        "file": {
          "type": "string",
          "const": "pdf"
        }
      },
      "required": [
        "documentRef",
        "file"
      ],
      "additionalProperties": false
    }
  ]
}
```

## Related tools

- [`search_documents`](/docs/en/mcp/tools/search_documents.md) — **Search documents**: Search one public document family at a time. Use cfdi for income, credit-note, transfer, payroll, and payment-complement documents; use withholding, sales_receipt, quote, expense, declaration, tax_compliance_opinion, or sales_receipt_refund for the other families.

- [`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.

- [`send_document`](/docs/en/mcp/tools/send_document.md) — **Send document**: Send a document to a recipient. CFDI documents support the document or cancellation_receipt attachment set; sales receipts and quotes support document only.

## Related workflow

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

## Equivalent REST operations

- [`GET /v1/documents/{documentRef}/files/{file}`](/docs/en/api/documents/files-and-delivery/download-document-file.md)

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