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

# Sub-Accounts

## Create Sub-Account

> Create a UniX-generated sub-account under the main account.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Sub-Accounts"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/account/create-sub":{"post":{"tags":["Sub-Accounts"],"summary":"Create Sub-Account","operationId":"createSubAccount","description":"Create a UniX-generated sub-account under the main account.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["label","address","nonce","expires_after","signature"],"properties":{"label":{"type":"string","description":"Unique within the main account."},"address":{"type":"string"},"nonce":{"type":"integer","format":"int64"},"expires_after":{"type":"integer","format":"int64"},"signature":{"$ref":"#/components/schemas/Signature"}}}}}},"responses":{"200":{"description":"Sub-account created","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"tx_hash":{"type":"string"},"sub_address":{"type":"string"},"label":{"type":"string"}}}}}]}}}},"422":{"description":"Errors: `20014` (signer cannot create sub), `20015` (label exists), `20017` (limit)"}}}}},"components":{"schemas":{"Signature":{"type":"object","description":"ECDSA signature components `(r, s, v)` over the EIP-712 signing hash.","required":["r","s","v"],"properties":{"r":{"type":"string","description":"32-byte hex string with `0x` prefix."},"s":{"type":"string","description":"32-byte hex string with `0x` prefix."},"v":{"type":"integer","description":"Recovery identifier — typically 27 or 28.","enum":[27,28]}}},"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}}}}}
```

## List Children (Sub-Accounts)

> Return the sub-accounts currently controlled by a main account.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Sub-Accounts"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/account/children":{"get":{"tags":["Sub-Accounts"],"summary":"List Children (Sub-Accounts)","operationId":"listChildren","description":"Return the sub-accounts currently controlled by a main account.","parameters":[{"$ref":"#/components/parameters/AddressQuery"}],"responses":{"200":{"description":"Children list","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"list":{"type":"array","items":{"$ref":"#/components/schemas/AccountChild"}}}}}}]}}}}}}}},"components":{"parameters":{"AddressQuery":{"name":"address","in":"query","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"description":"Account address (`0x`-prefixed hex)."}},"schemas":{"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}},"AccountChild":{"type":"object","properties":{"address":{"type":"string"},"type":{"type":"string","enum":["sub"]},"label":{"type":"string","description":"Sub-account label (only present when `type=sub`)."},"linked_at":{"type":"integer","format":"int64"}}}}}}
```

## Get Main Account

> Return the main account that controls a given sub-account, or null when none exists.

```json
{"openapi":"3.0.3","info":{"title":"UniX API","version":"1.11.0"},"tags":[{"name":"Sub-Accounts"}],"servers":[{"url":"https://api.unixtrade.pro/v1","description":"Production"}],"paths":{"/account/main":{"get":{"tags":["Sub-Accounts"],"summary":"Get Main Account","operationId":"getMainAccount","description":"Return the main account that controls a given sub-account, or null when none exists.","parameters":[{"$ref":"#/components/parameters/AddressQuery"}],"responses":{"200":{"description":"Main account (or null)","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ResponseEnvelope"},{"type":"object","properties":{"data":{"type":"object","properties":{"main_address":{"type":"string","nullable":true},"type":{"type":"string","nullable":true,"enum":["sub",null]}}}}}]}}}}}}}},"components":{"parameters":{"AddressQuery":{"name":"address","in":"query","required":true,"schema":{"type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"description":"Account address (`0x`-prefixed hex)."}},"schemas":{"ResponseEnvelope":{"type":"object","description":"Standard response envelope shared by every endpoint.","required":["code","msg","data"],"properties":{"code":{"type":"string","description":"`\"0\"` for success. Non-zero indicates an error code — see [Error Codes](/reference/error-codes)."},"msg":{"type":"string","description":"Empty on success; human-readable error description on failure."},"data":{"description":"Endpoint-specific payload on success; `null` on failure.","nullable":true},"trace_code":{"type":"string","description":"Backend trace identifier. Empty on success; populated on failure for support diagnostics."}}}}}}
```


---

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

```
GET https://docs.unix.market/rest-api/sub-accounts.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.
