> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pacifica.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Subaccount

> This endpoint allows regular accounts to create subaccounts with a secure authentication scheme. Both the main account and subaccount must sign to establish the relationship.

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

```http theme={null}
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 theme={null}
{
  "main_account": "42trU9A5...",
  "subaccount": "69trU9A5...",
  "main_signature": "5j1Vy9Uq...",
  "sub_signature": "4k2Wx8Zq...",
  "timestamp": 1716200000000,
  "expiry_window": 30000
}
```

#### Response

* Status 200: Subaccount created successfully

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

* Status 400: Bad request

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

* Status 500: Internal server error
