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

# Create subaccount

The subaccount creation process follows the below steps.

1. The main account must authorize the creation of a subaccount under its control
2. The subaccount must consent to being controlled by the main account
3. The API server must verify both signatures to prevent unauthorized subaccount creation<br>

Valid addresses must be used in order to establish main/subaccount relationships via API:

* Neither account can be a subaccount of another account.
* The subaccount address cannot have any deposit/trade history

Please refer to the [Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/create_subaccount.py) for a comprehensive guide on subaccount creation via API

```
POST /api/v1/account/subaccount/create
```

#### Request Body

<table><thead><tr><th width="176">Field</th><th width="98">Type</th><th width="95">Need</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>"main_account"</code></td><td>string</td><td>required</td><td>Main account wallet address</td><td><code>42trU9A5...</code></td></tr><tr><td><code>"subaccount"</code></td><td>string</td><td>required</td><td>Subaccount wallet address</td><td><code>69trU9A5...</code></td></tr><tr><td><code>"timestamp"</code></td><td>integer</td><td>required</td><td>Current timestamp in milliseconds</td><td><code>1716200000000</code></td></tr><tr><td><code>"main_signature"</code></td><td>string</td><td>required</td><td>Main account signature</td><td><code>5j1Vy9Uq...</code></td></tr><tr><td><code>"sub_signature"</code></td><td>string</td><td>required</td><td>Subaccount signature</td><td><code>4k2Wx8Zq...</code></td></tr><tr><td><code>"expiry_window"</code></td><td>integer</td><td>optional</td><td>Signature expiry in milliseconds</td><td><code>30000</code></td></tr></tbody></table>

```json
{
  "main_account": "42trU9A5...",
  "subaccount": "69trU9A5...",
  "main_signature": "5j1Vy9Uq...",
  "sub_signature": "4k2Wx8Zq...",
  "timestamp": 1716200000000,
  "expiry_window": 30000
}
```

#### Response

* Status 200: Subaccount created successfully

```json
{
  "success": true,
  "data": null,
  "error": null,
  "code": null,
}
```

* Status 400: Bad request

```json
{
  "success": false,
  "data": null,
  "error": "Account already exists: CRTxBM...",
  "code": 2
}
```

* Status 500: Internal server error
