# Create Account Group

Creates a new group (sub-organization) within your organization. Account groups can be used to organize different merchants or business units under a single parent entity.

Pass `account_codes` to attach existing accounts to the group in the same request. A new group is always created as a root; to nest it under another group, set `parent_code` with [Update Account Group](/reference/organizations/update-account-group).

**POST** `/organizations/account-groups`

Base URL: `https://api-sandbox.whitelabel.com/v1`

Creates a new group (sub-organization).

## Authorization

- PUBLIC-API-KEY (apiKey in header)
- PRIVATE-SECRET-KEY (apiKey in header)

## Body

Content type: `application/json`

- `name` (string, required)
  Account group name (min=1, max=255).
- `merchant_id` (string, required)
  Unique identifier used by the merchant in their systems (min=1, max=255).
- `account_codes` (string<uuid>[])
  Optional. `id`s of existing accounts to attach to the new group in the same transaction. An account belongs to one group at a time, so an account that is already in another group is moved to the new one. If any code does not match an active account of the organization the whole request fails and no group is created. Defaults to an empty list.

Example:

```json
{
  "name": "string",
  "merchant_id": "string",
  "account_codes": [
    "00000000-0000-0000-0000-000000000000"
  ]
}
```

## Responses

### 201

Created

- `id` (string<uuid>)
  The unique identifier of the account group.
- `name` (string)
- `merchant_id` (string)
- `parent_code` (string,null<uuid>)
  The `id` of the group this group is nested under. Always `null` on creation: a new group is created as a root and nested afterwards with Update Account Group.
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)

Example:

```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "string",
  "merchant_id": "string",
  "parent_code": null,
  "created_at": "1970-01-01T00:00:00.000Z",
  "updated_at": "1970-01-01T00:00:00.000Z"
}
```