Get sub accounts
List the ids of the sub-accounts this session can use.
On this page
Agent prompt
Write a small program that calls `account.get_sub_accounts` on Grvt {environment} {using}.
Target environment: {environment} (chain ID {chainId}). Recorded signing cases keep their original environment.
{executionGuidance}
Read this first: {origin}/bundle/reference/rpc/get_sub_accounts.md (~52 KB, plain Markdown: this page plus the AGENTS.md rules, Authentication and sessions, Errors and retries, Python SDK, Environments).
Fetch other pages from the index at {origin}/llms.txt only as you need them. {origin}/downloads/contract.json is a machine-readable contract for tools, not for reading.
Rules: follow AGENTS.md; do not send requests without the user asking you to; read credentials from environment variables; never retry writes automatically; show me the code and how to run it. URLs and generated code samples on this page: Testnet (chain ID 326). Other code on this page doesn't change: it stays on testnet until you switch it in your code. Tutorials, signing cases and live tools always use testnet.
| SDK | client. |
|---|---|
| HTTP | POST https:/, or / for lite names (the SDKs' default) |
| WebSocket | method v1/get_sub_accounts on wss:/, or /ws/lite for lite names |
| Auth | Session required (Authentication) |
| Retries | Read: the SDKs retry retryable errors (rules) |
| Contract id | account. (RPCGetSubAccountsV1) |
Request
Body type EmptyRequest. Fields the server fills are left out.
No fields.
Response
Body type ApiGetSubAccountsResponse (the same object is the JSON-RPC result over WebSocket).
- List of sub-account IDs accessible to the session
Errors
Errors come back as {"code", "message", "status"} (lite {"c", "m", "s"}) with the HTTP status. Codes this call can return (all error codes):
Example
Example code
import os
from grvt import Grvt
with Grvt(
env=os.environ.get("GRVT_ENV", "testnet"),
api_key=os.environ["GRVT_API_KEY"],
) as client:
resp = client.get_sub_accounts()
print(resp)
Raw HTTP (set GRVT_DOMAIN, see Environments; GRVT_COOKIE and GRVT_ACCOUNT_ID come from login):
With full field names:
curl -sS "https://trades.testnet.grvt.io/full/v1/get_sub_accounts" \
-H "Content-Type: application/json" \
-H "Cookie: gravity=$GRVT_COOKIE" \
-H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
--data '{}'With lite field names:
curl -sS "https://trades.testnet.grvt.io/lite/v1/get_sub_accounts" \
-H "Content-Type: application/json" \
-H "Cookie: gravity=$GRVT_COOKIE" \
-H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
--data '{}'Build request
Not sent from the docsThis call needs a logged-in session on the trading gateway. The docs only build the request: you see exactly what your code would send, and nothing is sent. See Authentication.