> ## 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, icon = "🪢"}) => <div style={{
  backgroundColor: 'var(--recommended-bg)',
  borderLeft: '4px solid #f63b92',
  borderRadius: '10px',
  padding: '18px 22px',
  marginBottom: '20px',
  boxShadow: '1px 1px 3px rgba(0,0,0,0.06)'
}}>
    <div style={{
  display: 'flex',
  alignItems: 'flex-start',
  gap: '14px'
}}>
      <span style={{
  fontSize: '22px',
  lineHeight: '1',
  flexShrink: 0
}}>
        {icon}
      </span>
      <div>
        {title && <div style={{
  fontSize: '16px',
  fontWeight: 600,
  color: 'var(--recommended-title)',
  marginBottom: '6px'
}}>
            {title}
          </div>}
        <div style={{
  fontSize: '14px',
  lineHeight: 1.65
}}>
          {children}
        </div>
      </div>
    </div>
  </div>;

export const NoteCallout = ({title, children, icon = "💡"}) => <div style={{
  backgroundColor: 'var(--recommended-bg)',
  borderLeft: '4px solid #3beaf6',
  borderRadius: '10px',
  padding: '18px 22px',
  marginBottom: '20px',
  boxShadow: '1px 1px 3px rgba(0,0,0,0.06)'
}}>
    <div style={{
  display: 'flex',
  alignItems: 'flex-start',
  gap: '14px'
}}>
      <span style={{
  fontSize: '22px',
  lineHeight: '1',
  flexShrink: 0
}}>
        {icon}
      </span>
      <div>
        {title && <div style={{
  fontSize: '16px',
  fontWeight: 600,
  color: 'var(--recommended-title)',
  marginBottom: '6px'
}}>
            {title}
          </div>}
        <div style={{
  fontSize: '14px',
  lineHeight: 1.65
}}>
          {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)

***
