> For the complete documentation index, see [llms.txt](https://docs.txn.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.txn.io/accounts/creating-subaccount.md).

# Creating subaccount

<mark style="color:green;">`POST`</mark> `/api/public/v1/accounts/:account_id/subaccounts`

Creates a subaccount under the specified master account. The subaccount inherits the master account's currency.

**Headers**

| Name          | Value                      |
| ------------- | -------------------------- |
| Content-Type  | `application/vnd.api+json` |
| Authorization | `Bearer <api_key>`         |

**Path Parameters**

| Name        | Type   | Description        |
| ----------- | ------ | ------------------ |
| account\_id | string | Master account ID. |

**Body**

<table><thead><tr><th>Name</th><th width="116">Type</th><th>Description</th></tr></thead><tbody><tr><td>data</td><td>object</td><td>Request data object.</td></tr><tr><td>data.type</td><td>string</td><td>Resource type. Always <code>accounts</code>.</td></tr><tr><td>data.attributes</td><td>object</td><td>Subaccount attributes.</td></tr><tr><td>data.attributes.label</td><td>string</td><td>Subaccount label. Use a human-readable value so you can recognize it later.</td></tr></tbody></table>

**Request JSON**

```json
{
  "data": {
    "type": "accounts",
    "attributes": {
      "label": "Sub-account Adam Goodman"
    }
  }
}
```

**Response**

{% tabs %}
{% tab title="HTTP 200" %}

```json
{
  "data": {
    "id": "dc9c1c6e-3fa6-4fce-8c5f-714dfcecf3ee",
    "type": "accounts",
    "attributes": {
      "master": false,
      "currencyCode": "USDT",
      "label": "Sub-account Adam Goodman",
      "bankReference": "BDR7013714686525702",
      "balance": "0.000000",
      "totalBalance": "0.000000",
      "bankWithdrawalAvailable": false,
      "currencyType": "crypto"
    },
    "relationships": {
      "company": {
        "meta": {
          "included": false
        }
      },
      "networks": {
        "meta": {
          "included": false
        }
      }
    }
  },
  "meta": {},
  "jsonapi": {
    "version": "1.0"
  }
}
```

{% endtab %}

{% tab title="HTTP 404" %}

```json
{
  "errors": [
    {
      "status": 404,
      "title": "Record not found",
      "code": "account_not_found",
      "detail": "Account not found"
    }
  ]
}
```

The master account in the path does not exist.
{% endtab %}
{% endtabs %}

**Response Body**

| Name                                      | Type    | Description                                                     |
| ----------------------------------------- | ------- | --------------------------------------------------------------- |
| `data.id`                                 | string  | Subaccount ID.                                                  |
| `data.type`                               | string  | Entity type returned. Always `accounts`.                        |
| `data.attributes.master`                  | boolean | Always `false` for a subaccount.                                |
| `data.attributes.currencyCode`            | string  | Currency code, inherited from the master account.               |
| `data.attributes.label`                   | string  | Subaccount label, as set in the request.                        |
| `data.attributes.bankReference`           | string  | Unique bank deposit reference assigned to the subaccount.       |
| `data.attributes.balance`                 | string  | Subaccount balance. A new subaccount starts at zero.            |
| `data.attributes.totalBalance`            | string  | Matches `balance` for subaccounts.                              |
| `data.attributes.bankWithdrawalAvailable` | boolean | If `true`, bank withdrawals can be initiated from this account. |
| `data.attributes.currencyType`            | string  | Currency type. Either `fiat` or `crypto`.                       |


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.txn.io/accounts/creating-subaccount.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
