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

# Attachments

> The attachments array shape for AI create endpoints and bank transaction upload.

Several **create** endpoints accept an optional **`attachments`** field: a JSON **array of objects** (not raw strings or bare URLs). Each object describes one file for the AI pipeline.

Endpoints that use this shape include (non-exhaustive): **invoices**, **bills**, **expenses**, **income**, **journals**, **contacts**, **chart of accounts** (`POST /accounts`), and **`POST /bank-transactions/upload`**.

## Attachment object

| Field  | Required    | Type   | Description                                                                                                                                                                                         |
| ------ | ----------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `file` | Yes         | string | Content interpreted per `type` — must be non-empty                                                                                                                                                  |
| `type` | Yes         | string | One of `base64`, `url`, or `raw`. **Always required** — for Base64 file bytes you must send `"type": "base64"`; the API does **not** treat a bare string in `file` as Base64 when `type` is missing |
| `name` | Recommended | string | Original filename **including extension** (e.g. `statement-jan.pdf`, `export.csv`). Used for type detection (PDF, CSV, Excel, images). If omitted, a generic name may break detection               |

### `type` values for `file`

| `type`   | Meaning                                                                                                                     |
| -------- | --------------------------------------------------------------------------------------------------------------------------- |
| `base64` | Standard Base64-encoded file bytes (**no** `data:...;base64,` prefix). You **must** set `"type": "base64"` alongside `file` |
| `url`    | Public `https://` URL the server fetches once (timeout and HTTP success required)                                           |
| `raw`    | Raw binary as string (uncommon in JSON; prefer `base64`)                                                                    |

## Examples

### One PDF as Base64

```json theme={null}
"attachments": [
  {
    "name": "invoice-scan.pdf",
    "type": "base64",
    "file": "JVBERi0xLjQKJeLjz9MKMyAwIG9iago8PC9MZW5ndGggNCAwIFIvRmlsdGVyL0ZsYXRlRGVjb2RlPj4Kc3RyZWFtCnic..."
  }
]
```

### File hosted at a URL

```json theme={null}
"attachments": [
  {
    "name": "statement.csv",
    "type": "url",
    "file": "https://cdn.example.com/statements/jan-2024.csv"
  }
]
```

## Usage notes

* **Base64:** never omit `type`. Sending only a long string in `file` without `"type": "base64"` is invalid for Base64 content.
* **Multiple attachments:** each object is processed; for async jobs, processing is often **one job per attachment**.
* **Omit or empty array:** use `[]` or omit `attachments` when you only send `prompt` and optional `text_attachment`.
* **Bank statement files:** for `POST /bank-transactions/upload`, supported types follow the filename extension: **pdf**, **csv**, **xlsx**, **xls**, and common images (**jpg**, **jpeg**, **png**, **webp**, **gif**, **bmp**). Other AI pipelines may accept different formats per their service rules.

## Related

* [Create bank transactions (AI)](/api-reference/bank-transactions-upload)
* [API overview](/api-reference/overview)
