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

# How to Create Multiple Accounts in a Single Request

export const RememberCallout = ({title, children}) => <div className="callout-box callout-remember">
    <div className="callout-row">
      <span className="callout-icon">
        <svg width="22" height="22" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M229.66,98.34,172.39,155.8c11.46,22.93-1.72,45.86-10.11,57a8,8,0,0,1-12,.83L42.34,105.76A8,8,0,0,1,43,93.85c29.65-23.92,57.4-10,57.4-10l57.27-57.46a8,8,0,0,1,11.31,0L229.66,87A8,8,0,0,1,229.66,98.34Z" opacity="0.2" /><path d="M235.32,81.37,174.63,20.69a16,16,0,0,0-22.63,0L98.37,74.49c-10.66-3.34-35-7.37-60.4,13.14a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33c19.64-26.1,17.75-47.32,13.19-60L235.33,104A16,16,0,0,0,235.32,81.37ZM224,92.69h0l-57.27,57.46a8,8,0,0,0-1.49,9.22c9.46,18.93-1.8,38.59-9.34,48.62L48,100.08c12.08-9.74,23.64-12.31,32.48-12.31A40.13,40.13,0,0,1,96.81,91a8,8,0,0,0,9.25-1.51L163.32,32,224,92.68Z" /></svg>
      </span>
      <div>
        {title && <div className="callout-title">
            {title}
          </div>}
        <div className="callout-body">
          {children}
        </div>
      </div>
    </div>
  </div>;

export const NoteCallout = ({title, children}) => <div className="callout-box callout-note">
    <div className="callout-row">
      <span className="callout-icon">
        <svg width="22" height="22" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M208,104a79.86,79.86,0,0,1-30.59,62.92A24.29,24.29,0,0,0,168,186v6a8,8,0,0,1-8,8H96a8,8,0,0,1-8-8v-6a24.11,24.11,0,0,0-9.3-19A79.87,79.87,0,0,1,48,104.45C47.76,61.09,82.72,25,126.07,24A80,80,0,0,1,208,104Z" opacity="0.2" /><path d="M176,232a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,232Zm40-128a87.55,87.55,0,0,1-33.64,69.21A16.24,16.24,0,0,0,176,186v6a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16v-6a16,16,0,0,0-6.23-12.66A87.59,87.59,0,0,1,40,104.49C39.74,56.83,78.26,17.14,125.88,16A88,88,0,0,1,216,104Zm-16,0a72,72,0,0,0-73.74-72c-39,.92-70.47,33.39-70.26,72.39a71.65,71.65,0,0,0,27.64,56.3A32,32,0,0,1,96,186v6h64v-6a32.15,32.15,0,0,1,12.47-25.35A71.65,71.65,0,0,0,200,104Zm-16.11-9.34a57.6,57.6,0,0,0-46.56-46.55,8,8,0,0,0-2.66,15.78c16.57,2.79,30.63,16.85,33.44,33.45A8,8,0,0,0,176,104a9,9,0,0,0,1.35-.11A8,8,0,0,0,183.89,94.66Z" /></svg>
      </span>
      <div>
        {title && <div className="callout-title">
            {title}
          </div>}
        <div className="callout-body">
          {children}
        </div>
      </div>
    </div>
  </div>;

The Chart of Accounts API supports creating up to 1000 Accounts in a single request using the batch endpoint. This is more efficient than individual creates when your sync produces a large number of new accounts, and helps keep API call volume within rate limit targets.

This how-to covers the batch create step only. For update, unarchive, and archive operations, use the individual PUT endpoint as described in [How to Create, Update, and Archive Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-create-update-archive-accounts).

## When to Use This

The batch endpoint is useful when:

* Running an initial sync where many accounts need to be created from scratch.
* A large number of new accounts have been added to the AS since the last sync cycle.

For small numbers of new accounts, the single-create endpoint works fine.

## Prerequisites

Before you begin:

* You have completed [How to Sync Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-sync-accounts) and identified which accounts need to be created in Pleo.
* Your integration is authenticated using one of the [supported authentication methods](/docs/current/integration-design/auth/integration-design-auth-overview#authentication-policy-overview).
* Your integration can call Pleo's Chart of Accounts API endpoints.

## Steps

### 1. Build the Batch Request

**API Endpoint**: POST [`/v1/chart-of-accounts/batch`](/reference/accounts/create-multiple-accounts-in-a-single-request)

Collect all accounts that need to be created and include them as `items` in the request body. Each item requires `externalId`, `name`, and `archived`. The `code` and `taxCodeExternalId` fields are optional.

A single request can include between 1 and 1000 accounts. If you have more than 1000 accounts to create, split them across multiple requests.

**Example Pseudo:**

```pseudo theme={null}
newAccounts = [account for account in activeASAccounts if not matchedInPleo]

for batch in chunks(newAccounts, size=1000):
    items = []
    for account in batch:
        items.append({
            externalId: account.externalId,
            code:       account.code,
            name:       account.name,
            archived:   false
        })
    POST /v1/chart-of-accounts/batch with { companyId, items }
```

#### Example Request

<Tabs>
  <Tab title="OAuth 2.0">
    ```bash theme={null}
    curl -X POST "https://external.staging.pleo.io/v1/chart-of-accounts/batch" \
      -H "Authorization: Bearer <access_token>" \
      -H "Content-Type: application/json" \
      -d '{
            "companyId": "12abc3d4-e567-890e-1234-abc56e78fabc",
            "items": [
              {
                "externalId": "ext-3000",
                "code": "3000",
                "name": "Software",
                "archived": false
              },
              {
                "externalId": "ext-6000",
                "code": "6000",
                "name": "Consulting",
                "archived": false
              },
              {
                "externalId": "ext-7000",
                "code": "7000",
                "name": "Equipment",
                "archived": false
              }
            ]
          }'
    ```
  </Tab>

  <Tab title="API Key">
    ```bash theme={null}
    curl --request POST \
      -u "pls_1ab2cd3e4f5g6h7a89b012c34de56f78_gabc90:" \
      -H "Accept: application/json;charset=UTF-8" \
      -H "Content-Type: application/json" \
      "https://external.staging.pleo.io/v1/chart-of-accounts/batch" \
      -d '{
            "companyId": "12abc3d4-e567-890e-1234-abc56e78fabc",
            "items": [
              {
                "externalId": "ext-3000",
                "code": "3000",
                "name": "Software",
                "archived": false
              },
              {
                "externalId": "ext-6000",
                "code": "6000",
                "name": "Consulting",
                "archived": false
              },
              {
                "externalId": "ext-7000",
                "code": "7000",
                "name": "Equipment",
                "archived": false
              }
            ]
          }' \
    | jq
    ```
  </Tab>
</Tabs>

***

### 2. Handle the Response

The API returns a `201` even when some items fail. Always check both the `created` and `failed` arrays in the response.

#### Example Response

```json theme={null}
{
  "data": {
    "created": [
      {
        "id": "f1a2b3c4-d5e6-7f89-abcd-ef1234567890",
        "companyId": "12abc3d4-e567-890e-1234-abc56e78fabc",
        "externalId": "ext-3000",
        "code": "3000",
        "name": "Software",
        "archived": false
      },
      {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567891",
        "companyId": "12abc3d4-e567-890e-1234-abc56e78fabc",
        "externalId": "ext-6000",
        "code": "6000",
        "name": "Consulting",
        "archived": false
      },
      {
        "id": "b2c3d4e5-f6a7-8901-bcde-f12345678912",
        "companyId": "12abc3d4-e567-890e-1234-abc56e78fabc",
        "externalId": "ext-7000",
        "code": "7000",
        "name": "Equipment",
        "archived": false
      }
    ],
    "failed": []
  }
}
```

#### Handling Failures

Items that fail validation are returned in the `failed` array with a `reasons` field explaining what went wrong. Successfully validated items are still created: the batch does not roll back.

```json theme={null}
{
  "data": {
    "created": [...],
    "failed": [
      {
        "reasons": ["EXTERNAL_ID_ALREADY_EXISTS"],
        "request": {
          "externalId": "ext-3000",
          "code": "3000",
          "name": "Software",
          "archived": false
        }
      }
    ]
  }
}
```

<RememberCallout title="Remember">
  A `201` response does not mean all accounts were created. Always inspect the `failed` array and handle any failures, for example by logging them or retrying with corrected data.
</RememberCallout>

***

## Related Reading

* [How to Create, Update, and Archive Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-create-update-archive-accounts)
* [How to Sync Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-sync-accounts)
* [Chart of Accounts Sync Periodicity and Scheduling](/docs/current/integration-design/accounting-integrations/imports/accounts/integration-design-accounts-periodicity)

***
