Skip to content

Mint a token and make your first call

Every REST call is authenticated with a short-lived bearer token you mint yourself from a long-lived credential. You end up with a token, the one header every later call needs, and a response that proves it resolved.

  1. POST /api/auth/api-token takes { apiKey, apiSecret } and returns a 24-hour HS256 JWT in token. The credential pair itself is issued out of band — by an operator in the admin console, or by self-serve tenant signup where that is enabled. See Credentials & tokens.

    Terminal window
    curl -s https://api.troncharts.xyz/api/auth/api-token \
    -H 'content-type: application/json' \
    -d '{"apiKey":"'"$TC_API_KEY"'","apiSecret":"'"$TC_API_SECRET"'"}'
    # → { "token": "eyJ…", "tier": "fullTrading", "accountId": "…",
    # "expiresAt": 1754300000000, "enabledTools": null, … }

    tier is snapshotted at mint, but every call re-reads the credential: a downgrade takes effect on the next request, while an upgrade needs a fresh token.

  2. GET /api/v1/accounts lists every account the credential can reach and gives you the accountId that every /api/v1/accounts/{id}/* read needs. A 200 here is the proof that the token resolved: the tenant comes from the credential itself, so no tenant header is needed on a bearer call. A missing or broken token answers 401 (see Credentials & tokens).

    Terminal window
    curl -s https://api.troncharts.xyz/api/v1/accounts \
    -H "authorization: Bearer $TOKEN"
    # → { rootAccountId, activeAccountId,
    # accounts: [ { accountId, accountNumber, kind, capitalModel,
    # displayName, baseCurrency, wallets: [...] } ] }

    Revoke a token before its 24 hours are up with POST /api/auth/api-token/revoke and { token }.

Next: Create a paper account · Read balance, positions and open orders · Scopes & tiers