> For the complete documentation index, see [llms.txt](https://www.aevo.xyz/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.aevo.xyz/docs/api-reference/urls/private-api/postsubaccountsarchive.md).

# POST /subaccounts/archive

Archive one of the authenticated main account's subaccounts. See [Subaccounts](/docs/api-reference/subaccounts.md).

`POST https://api.aevo.xyz/subaccounts/archive`

> **Authentication required.** Include your `AEVO-KEY` and `AEVO-SECRET` headers. See [Authentication](/docs/api-reference/urls/authentication.md). Call it with the main account's API key and no `AEVO-SUBACCOUNT` header. Read-only API keys can't call this endpoint.

The subaccount must be empty: no balances, positions, open orders or pending withdrawals. Archiving frees a slot under the subaccount limit. An archived subaccount can't be selected with `AEVO-SUBACCOUNT` and can't receive transfers. It still appears in [`GET /subaccounts`](/docs/api-reference/urls/private-api/getsubaccounts.md) with `archived: true`.

## Body Parameters

| Field        | Type   | Required | Description                                                   |
| ------------ | ------ | -------- | ------------------------------------------------------------- |
| `subaccount` | string | Yes      | The subaccount to archive. Example: `0xYourSubaccountAddress` |

## Example Request

```bash
curl --request POST \
     --url https://api.aevo.xyz/subaccounts/archive \
     --header 'accept: application/json' \
     --header 'AEVO-KEY: <your-api-key>' \
     --header 'AEVO-SECRET: <your-api-secret>' \
     --header 'content-type: application/json' \
     --data '{ "subaccount": "0xYourSubaccountAddress" }'
```

## Responses

**`200`** — The subaccount was archived.

| Field        | Type    | Required | Description                                           |
| ------------ | ------- | -------- | ----------------------------------------------------- |
| `parent`     | string  | Yes      | The main account. Example: `0xYourMainAccountAddress` |
| `subaccount` | string  | Yes      | The subaccount. Example: `0xYourSubaccountAddress`    |
| `archived`   | boolean | Yes      | Always `true`. Example: `true`                        |

**`400`** — Bad request.

| Field   | Type   | Required | Description                                                                                                             |
| ------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `error` | string | Yes      | Error message: `SUBACCOUNT_NOT_FOUND`, `SUBACCOUNT_ARCHIVED` or `SUBACCOUNT_NOT_EMPTY`. Example: `SUBACCOUNT_NOT_EMPTY` |

**`401`** — Unauthorized.

| Field   | Type   | Required | Description                            |
| ------- | ------ | -------- | -------------------------------------- |
| `error` | string | Yes      | Error message. Example: `UNAUTHORIZED` |

**`429`** — Rate limit exceeded.

| Field   | Type   | Required | Description                                   |
| ------- | ------ | -------- | --------------------------------------------- |
| `error` | string | Yes      | Error message. Example: `RATE_LIMIT_EXCEEDED` |

**`500`** — Internal server error.

| Field   | Type   | Required | Description                              |
| ------- | ------ | -------- | ---------------------------------------- |
| `error` | string | Yes      | Error message. Example: `INTERNAL_ERROR` |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.aevo.xyz/docs/api-reference/urls/private-api/postsubaccountsarchive.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
