# invoices.groups.groupSelected

Group 2 to 100 selected existing invoices as one split bill. Give the project, group name, currency and each invoice id with expectedRevision. Atomically creates a group and ties every selected invoice to that project. Invoices may belong to different businesses but must share the chosen currency and have no existing billing group. Stale invoices or an unavailable project refuse the whole change. Amounts, tax, recipients, payments, numbers, sending schedules and status stay as saved. Returns the saved group; inspect it with invoices.groups.get.

`POST /api/v1/accounting/invoices.groups.groupSelected`

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

MCP tool: `accounting_invoices_groups_group_selected`

## Fields

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `projectId` | string (ID) | Yes | The ID of the related record. |
| `name` | string | Yes | A display name. 1–200 characters. |
| `currency` | string | Yes | Three-letter currency code, such as CAD or USD. |
| `invoices` | array of objects | Yes | 2–100 items. |
| `invoices[].id` | string (ID) | Yes | The record's ID. |
| `invoices[].expectedRevision` | integer | Yes | The record's current revision, from the last time you read it. If someone changed the record since, the request is refused with a conflict so you can reload and check before trying again. at most 9007199254740991; greater than 0. |
| `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.groups.groupSelected \
  -H "Authorization: Bearer $OATMILK_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "projectId": "4d5e6f7a-8b9c-4d0e-8f1a-2b3c4d5e6f7a",
  "name": "Synthetic Ventures Inc.",
  "currency": "CAD",
  "invoices": [
    {
      "id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
      "expectedRevision": 3
    },
    {
      "id": "9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
      "expectedRevision": 3
    }
  ]
}'
```

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