# invoices.archive

Archive or restore up to 100 invoices at once with ids and archived (true to archive, false to restore). Archived invoices leave the invoice lists and counts but stay in the customer's history, reports and payments. Drafts and prepared invoices without a send date, paid, written-off and cancelled invoices can be archived; an invoice that is still owed or set to go out on a date is skipped with a reason (record the payment or write off the balance, or clear the send date, first). An archived invoice can't be approved, sent, paid, edited or cancelled until it is restored. Returns the invoices changed and, for each one left alone, why.

`POST /api/v1/accounting/invoices.archive`

Permissions: `accounting:read`, `accounting:write` · Roles: admin, finance · Idempotency key required

MCP tool: `accounting_invoices_archive`

## Fields

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `ids` | array of strings (ID) | Yes | 1–100 items. |
| `archived` | boolean |  | Whether the record is archived. Default `true`. |
| `idempotencyKey` | string | Yes | Any unique text you generate once per intended change, so a retried request only happens once. Send it as the Idempotency-Key header instead if you prefer; if you send both they must match. 8–200 characters. |

## Example request

```bash
curl https://app.getoatmilk.com/api/v1/accounting/invoices.archive \
  -H "Authorization: Bearer $OATMILK_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "ids": [
    "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"
  ]
}'
```

Reference page: https://app.getoatmilk.com/docs/api/invoices.archive
