> ## Documentation Index
> Fetch the complete documentation index at: https://docs.matil.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Documents

> How to send documents to Matil — URLs, base64, or plain text.

Every processing request in Matil includes one or more documents. A document is the input you want to process — an invoice, a contract, an ID card, or any other file.

Matil accepts documents in several formats, so you can integrate regardless of how your files are stored or received.

## Supported file types

Matil can process a wide range of document formats:

| Category         | Formats                                                   |
| ---------------- | --------------------------------------------------------- |
| **PDF**          | `.pdf`                                                    |
| **Images**       | `.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`, `.tiff`, `.bmp` |
| **Spreadsheets** | `.xlsx`, `.xls`, `.ods`, `.csv`                           |
| **Text**         | `.txt`, `.html`, `.xml`, `.json`                          |

The maximum file size is **50 MB**.

## Input formats

### URL

Point to a document hosted online. Matil downloads and processes it automatically. This is the most common way to send documents.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "type": "url",
  "url": "https://example.com/invoice.pdf"
}
```

### Base64 encoded

Send binary files directly in the request body. Useful when you have files in memory.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "type": "base64",
  "content": "JVBERi0xLjQK...",
  "mime_type": "application/pdf"
}
```

Here's how to encode a file in Python:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import base64

with open("document.pdf", "rb") as f:
    encoded = base64.b64encode(f.read()).decode("utf-8")

document = {
    "type": "base64",
    "content": encoded,
    "mime_type": "application/pdf"
}
```

### Plain text

Send raw text content directly. Useful when you already have the text extracted.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "type": "text",
  "text": "INVOICE\n\nInvoice Number: INV-2024-001\nDate: January 15, 2024\nTotal: $150.00"
}
```

## Multiple documents

You can send multiple documents in a single request. Matil processes them together as a single unit — useful for multi-page documents that arrive as separate files.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "documents": [
    {"type": "url", "url": "https://example.com/page1.pdf"},
    {"type": "url", "url": "https://example.com/page2.pdf"}
  ]
}
```

## Adding metadata

You can attach custom metadata to any request. This metadata is stored with the result and returned in responses and webhooks — useful for correlating results with your system.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "documents": [
    {"type": "url", "url": "https://example.com/invoice.pdf"}
  ],
  "metadata": {
    "order_id": "ORD-12345",
    "source": "email-inbox",
    "customer_id": "cust_abc"
  }
}
```

<Tip>
  Use metadata to link Matil results back to records in your own database. This makes it easy to match processed entries with their source.
</Tip>

## Next steps

<CardGroup cols={2}>
  <Card title="Processing modes" href="/en/api-reference/processing">
    Process many documents efficiently with batch mode.
  </Card>

  <Card title="Structures" href="/en/guides/structures">
    Learn how to extract structured data from your documents.
  </Card>
</CardGroup>
