> ## 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 Delete an Account

> How-to article for deleting a Pleo Account (Chart of Accounts entry) with the Chart of Accounts API (DELETE /v1/chart-of-accounts). Use it to remove test Accounts while building and testing an integration, for example when testing a high-volume Chart of Accounts. Deleting is permanent. Pleo does not check Category mappings or the accounting entries (expenses) that use the Account, and it never returns a 409. Exported accounting entries show a Missing account number error. In production, archive instead, see How to Create, Update, and Archive Accounts. For syncing Accounts see How to Sync Accounts. For the 11,000 active Account limit see How to Handle a High-Volume Chart of Accounts.

DANGER

**Destructive operation. Use with caution.** The Delete endpoint permanently removes an Account. Pleo does not check whether the Account is mapped to a Pleo Category or used on accounting entries (expense items), and a deleted Account cannot be recovered. See [Impact of Deleting an Account](#impact-of-deleting-an-account). In production, archive Accounts instead.

This how-to explains how to delete an Account (Chart of Accounts entry) in Pleo. The examples use the staging environment, but the steps are the same in production.

Unlike archiving, deleting also removes the Account's mappings to Pleo Categories. The effect reaches expenses in the Pleo web app, even those that were already exported and appear in the Accounting > Export > Exported tab. Archiving is reversible and leaves both the mappings and the expenses unchanged.

For this reason, we recommend that you [archive Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-create-update-archive-accounts.md#3-archive-accounts-with-no-matching-as-entry) in production instead of deleting them. In staging, use the Delete endpoint to remove Accounts while you build and test your integration, for example:

* To remove test Accounts that you created while building the integration.
* To stay below the 11,000 active Account limit while you test a high-volume Chart of Accounts. See [How to Handle a High-Volume Chart of Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-handle-high-volume-accounts.md).

Remember

Chart of Accounts Sync never deletes Accounts, so do not add delete to your sync logic. See [How to Sync Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-sync-accounts.md).

## Impact of Deleting an Account

Pleo deletes the Account immediately. It does not check the Account against Pleo Categories or expense items first. As a result:

* **Pleo never returns a `409`.** The request returns `204`, even when the Account is mapped to a Pleo Category or used on expense items.
* **Category mappings are cleared.** Pleo Categories that were mapped to the deleted Account no longer show an Account in the Pleo web app (Settings > Accounting > Categories).
* **Exported expenses are affected.** Expenses that used the Account through a Category show a **Missing account number** error in the Pleo web app. This includes expenses that were already exported and appear in the Accounting > Export > Exported tab.
* **Recreating the Account does not restore the mappings.** A recreated Account gets a new `id`, so you must reconfigure the Category mappings and the Accounts on the affected expenses.
* **The deletion cannot be undone.** A deleted Account cannot be restored.

## Prerequisites

Before you begin:

* You have the `id` of the Account to delete. You receive it when you create the Account, or you can retrieve it as described in [How to Sync Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-sync-accounts.md#2-retrieve-all-accounts-from-pleo)
* Your integration is authenticated using one of the [supported authentication methods](/docs/current/integration-design/auth/integration-design-auth-overview.md#authentication-policy-overview)
* Your integration can call Pleo's Chart of Accounts API endpoints

## Steps

Note

In the pseudocode on this page, `camelCase` names (for example `externalId`, `companyId`, `code`, `name`, `archived`) are real Pleo API fields. `snake_case` names are this example's own variables, not fields you'd see in a request or response.

### 1. Delete the Account

**API Endpoint**: DELETE [`/v1/chart-of-accounts/{accountId}`](/reference/accounts/delete-an-account)

When a test Account is no longer needed in staging, send a `DELETE` request with the Account's `id` in the path. The request has no body. You can delete an Account whether it is active or archived.

**Example Pseudo:**

```pseudo theme={null}
response = DELETE /v1/chart-of-accounts/{account.id}

if response.status == 204:
    log "Account deleted"
else if response.status == 404:
    log "Account not found or already deleted"
else:
    log error with response.status
```

#### Example Request

**OAuth 2.0**

```bash theme={null}
curl -X DELETE "https://external.staging.pleo.io/v1/chart-of-accounts/e5f6g7h8-i901-234i-5678-efg90i12defg" \
  -H "Authorization: Bearer <access_token>"
```

**API Key**

```bash theme={null}
curl --request DELETE \
  -u "pls_1ab2cd3e4f5g6h7a89b012c34de56f78_gabc90:" \
  -H "Accept: application/json;charset=UTF-8" \
  "https://external.staging.pleo.io/v1/chart-of-accounts/e5f6g7h8-i901-234i-5678-efg90i12defg" \
  -w "%{http_code}\n"
```

#### Example Response

A successful request returns `204 No Content` with an empty body.

```text theme={null}
HTTP/1.1 204 No Content
```

Remember

Pleo does not return a `409`, even when the Account is mapped to a Pleo Category or used on expense items. The request succeeds with a `204`, and the Account is deleted.

### 2. Confirm the Account Is Gone (Optional)

**API Endpoint**: GET [`/v1/chart-of-accounts/{accountId}`](/reference/accounts/retrieve-an-account-in-pleo-by-its-id)

To confirm the deletion, retrieve the Account by its `id`. After a `204`, the request returns `404`. The Account also no longer appears in search results, even when you set `includeArchived: true`.

**OAuth 2.0**

```bash theme={null}
curl -X GET "https://external.staging.pleo.io/v1/chart-of-accounts/e5f6g7h8-i901-234i-5678-efg90i12defg" \
  -H "Authorization: Bearer <access_token>"
```

**API Key**

```bash theme={null}
curl --request GET \
  -u "pls_1ab2cd3e4f5g6h7a89b012c34de56f78_gabc90:" \
  -H "Accept: application/json;charset=UTF-8" \
  "https://external.staging.pleo.io/v1/chart-of-accounts/e5f6g7h8-i901-234i-5678-efg90i12defg"
```

```json theme={null}
{
  "error": {
    "type": "ENTITY_NOT_FOUND_EXCEPTION",
    "message": "BookkeepingAccount not found for account 'e5f6g7h8-i901-234i-5678-efg90i12defg'"
  }
}
```

***

## Error Codes

| Scenario | HTTP Status | Notes |
| - | - | - |
| Account deleted | `204` | Empty response body. Pleo returns this even when the Account is mapped to a Pleo Category or used on expense items |
| `accountId` does not exist, or was already deleted | `404` | `ENTITY_NOT_FOUND_EXCEPTION` |
| `accountId` is not a valid UUID | `400` | `BAD_REQUEST`: "Invalid UUID string" |
| Invalid API key | `401` | The API key is not valid. See [Authentication](/docs/current/integration-design/auth/integration-design-auth-overview.md) |
| Missing credentials, or missing scope | `403` | The request has no credentials, or the API key or token does not have the `accounts:write` scope. A missing scope returns `ACCESS_DENIED`. See [API Scopes](/docs/current/authentication/api-scopes.md) and [Chart of Accounts API Scopes](/reference/accounts/chart-of-accounts-api-scopes.md) |
| Too many requests in a short period | `429` | Pleo rate limits the request. The response includes a `Retry-After` header with the number of seconds to wait. Wait that long, then retry |

***

## Related Reading

* [How to Create, Update, and Archive Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-create-update-archive-accounts.md)
* [How to Sync Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-sync-accounts.md)
* [How to Handle a High-Volume Chart of Accounts](/docs/current/how-tos/accounting-integrations/imports/accounts/how-to-handle-high-volume-accounts.md)
* [Account Limits and High-Volume Sync Guidance](/docs/current/integration-design/accounting-integrations/imports/accounts/integration-design-accounts-limits.md)
* [Delete an Account (API reference)](/reference/accounts/delete-an-account.md)

***
