Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Trading with a subaccount

This guide shows how to trade a subaccount through the API, end to end: place an order, read it back, cancel it, and do the same over the websocket.

What you need

Subaccounts don't have API keys or signing keys of their own. You use the main account's credentials for everything, and name the subaccount on each request:

You need
From
Used for

Main account API key and secret

Authenticating every request

Main account signing key

Enable Trading in the app, or POST /register

Signing orders (the main wallet also works)

The subaccount's address

The AEVO-SUBACCOUNT header, and the order's maker

Two rules make an order act on a subaccount:

  1. Select the subaccount on the request: the AEVO-SUBACCOUNT header on REST, or subaccount when you authenticate on the websocket.

  2. Set maker to the subaccount's address in the signed order, and sign with the main account's signing key.

If either is missing, the request acts on the main account instead, or is rejected.

Step 1. Find your subaccount's address

Call GET /subaccounts with the main account's key and no AEVO-SUBACCOUNT header:

{
  "account": "0xYourMainAccountAddress",
  "max_subaccounts": 10,
  "subaccounts": [
    { "subaccount": "0xYourSubaccountAddress", "name": "Market Making", "archived": false, "balances": [], "positions": [] }
  ]
}

Use the subaccount value exactly as returned. It is checksummed (mixed case), and the header must match it exactly.

Step 2. Sign requests for the subaccount

With signature (HMAC) authentication, the subaccount is part of what you sign. Append it as a sixth field:

  • path is the URL path without the query string. For GET /orders?instrument_id=1 you sign /orders.

  • body is the exact JSON string you send, or empty for a GET.

  • Without a subaccount, it is the usual five-field message, so the same helper works for the main account.

If you authenticate with AEVO-KEY and AEVO-SECRET instead of a signature, just add the AEVO-SUBACCOUNT header. Nothing else changes.

Step 3. Sign an order for the subaccount

Use the normal Order type (see Signing Orders) with maker set to the subaccount's address, and sign it with the main account's signing key. The subaccount's address is inside the signed order, so the signature can't be reused for any other account.

Full example (REST)

Every private endpoint works the same way with the header, including GET /account, GET /trade-history, POST /batch-orders, DELETE /orders-all, RFQ quotes and the account settings endpoints (leverage, margin mode, portfolio margin).

Full example (websocket)

A websocket connection acts as one account. Add subaccount when you authenticate, and every order, cancel and private channel on that connection is for the subaccount. Open one connection per account you trade.

To authenticate with a signature instead of the secret, add subaccount to the auth data and sign apiKey,timestamp,ws,auth,,subaccount. For per-message authentication, add subaccount to the message's auth object and sign apiKey,timestamp,ws,op,data,subaccount. See Subaccounts.

Trading several subaccounts at once

  • REST: one set of credentials covers every subaccount. Change the AEVO-SUBACCOUNT header per request.

  • Websocket: one connection per subaccount (and one for the main account if you trade it too), each authenticated with its own subaccount value.

  • Rate limits are shared by the main account and all its subaccounts, so adding subaccounts doesn't add capacity. See Rate Limits.

  • Your own accounts never trade against each other. If an order would fill against the main account or another of its subaccounts, the incoming order is cancelled. See Shared rules.

Moving funds with the API

Trading uses the main account's keys, but a transfer out of a subaccount must be signed by the subaccount's own key (Transfer type, account = the subaccount). Re-derive it from the main wallet as described in Creating subaccounts, then call POST /transfer with the AEVO-SUBACCOUNT header. A subaccount can only transfer to its main account or another of its subaccounts, and can never withdraw.

Common errors

Error
Cause
Fix

SUBACCOUNT_NOT_FOUND

The header isn't one of this main account's active subaccounts, or its casing doesn't match

Copy the address exactly from GET /subaccounts

SUBACCOUNT_ARCHIVED

The subaccount is archived

Use an active subaccount

INVALID_SIGNATURE (on auth)

The HMAC didn't include the subaccount as the sixth field, or signed the path with its query string

Sign apiKey,timestamp,method,path,body,subaccount with the bare path

UNAUTHORIZED (on POST /orders)

The order's maker isn't the account the request acts on

Set maker to the same subaccount as the AEVO-SUBACCOUNT header

ORDER_INVALID_SIGNATURE

The order wasn't signed by the main account's signing key or wallet

Sign the order with the main signing key

SUBACCOUNT_TRANSFER_OUTSIDE_FAMILY

A transfer from or to a subaccount crossed families

Transfer only between the main account and its subaccounts

SUBACCOUNT_WITHDRAW_NOT_ALLOWED

Withdrawal from a subaccount

Transfer to the main account, then withdraw

Last updated

Was this helpful?