# Creating subaccount

## Create subaccount

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

This endpoint creates a new subaccount for the specified master account ID.

**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>Object with exchange request data.</td></tr><tr><td>data.type</td><td>string</td><td>Exchange request type. Always <code>accounts</code>.</td></tr><tr><td>data.attributes</td><td>object</td><td>A set of exchange request attributes.</td></tr><tr><td>data.attributes.label</td><td>string</td><td>Subaccount label. Keep it human-readable so that you can recognize it later.</td></tr></tbody></table>

**Request JSON**

```json
{
  "data": {
    "type": "accounts",
    "attributes": {
      "label": "Sub-account Christian Whitney"
    }
  }
}
```

**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 422" %}

```json
{
  "errors": [
    {
      "status": 422,
      "title": "Invalid attribute",
      "code": "address_invalid",
      "detail": "Network does not match account currency",
      "source": {
        "pointer": "/data/attributes/networkId"
      }
    }
  ]
}
```

{% endtab %}

{% tab title="HTTP 404" %}

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
