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

# Working with Attachments

> How to add and read file attachments on DualEntry records through the V2 API, including the attachment schema and the lack of a delete endpoint.

Many DualEntry records support file attachments, such as scanned invoices, receipts, and supporting documents. This guide explains the attachment schema, how to add attachments through the V2 API, and which attachment operations are and are not available.

The same pattern applies to every record type that exposes an attachments sub-resource. These include invoices, bills, journal entries, sales orders, purchase orders, customer prepayments, customer deposits, customer refunds, cash sales, vendor refunds, and direct expenses.

## The attachment schema

Each attachment is represented by an `AttachmentSchemaOut` object. The `attachments` field on a record's create and read payloads is an array of these objects.

| Field          | Type           | Required | Notes                               |
| -------------- | -------------- | -------- | ----------------------------------- |
| `id`           | integer        | Yes      | The attachment's unique identifier. |
| `file_name`    | string         | Yes      | The display file name.              |
| `file_size`    | integer        | Yes      | File size in bytes.                 |
| `download_url` | string or null | No       | URL to download the file.           |
| `upload_url`   | string or null | No       | URL to upload the file content.     |
| `category`     | string         | No       | Defaults to `default`.              |

## Add attachments when you create a record

You can include attachments in the `attachments` array when you create a record. For example, a `POST` to `/public/v2/invoices/` accepts an `attachments` array alongside the rest of the invoice payload, where each element follows the `AttachmentSchemaOut` shape above.

The following example creates an invoice with one attachment reference:

```json theme={null}
{
  "attachments": [
    {
      "id": 4821,
      "file_name": "march-invoice.pdf",
      "file_size": 102400,
      "category": "default"
    }
  ]
}
```

## Add attachments to an existing record

To attach files to a record that already exists, send a `POST` to that record's attachments sub-resource. For an invoice, the endpoint is `/public/v2/invoices/{record_number}/attachments/`. Every record type listed above exposes the same `{record_number}/attachments/` pattern, so the call shape is consistent across resources.

```http theme={null}
POST /public/v2/invoices/{record_number}/attachments/
```

## Replacing or deleting attachments

The V2 API does not provide a dedicated endpoint to delete or replace an attachment. The attachments sub-resource supports adding attachments only; there is no delete or replace operation on it.

<Info>
  Because there is no delete-attachment endpoint, plan your integration to add attachments correctly the first time rather than relying on later removal. If your workflow requires removing an attachment from a posted record, raise it with your DualEntry contact so the supported path can be confirmed for your case.
</Info>

For the full request and response shapes, see the [V2 API Reference](../openapi/resources-v2.json). For broader guidance on syncing files as part of an integration, see [Building a Custom Integration](./building-a-custom-integration).
