Skip to navigation

Create a Session

Build a session grant, have the owner sign it, open the session and sign in with the session key

Opening a session takes one owner signature and one unauthenticated request. The steps below describe the raw API. The TypeScript and Python SDKs build, validate and sign the grant for you.

1. Generate a session key

Generate a new Stark key pair for every session. The public key goes into the grant as sessionKey; keep the private key in your app. A key that has ever belonged to the account, including the key of a revoked or expired session, is refused with SESSION_KEY_IN_USE.

2. Build the grant

A SessionGrant has these fields. Field names are camelCase and the order shown is the signed order.

FieldTypeDescription
paradexChainstringThe Paradex chain id, the starknet_chain_id value from GET /v1/system/config
environmentstringmainnet or testnet
accountstringThe main account the session is anchored to, as 0x hex
sessionKeystringThe session public key, as 0x hex
labelstringA name the owner sees for the session, at most 64 printable ASCII characters. May be empty.
scopesstring[]The scopes the session gets beyond reading. May be empty for a read only session.
limitsLimitsPer session trading limits. See Limits.
builderBuilderA builder fee approval. See Builder.
subaccountsstring[]Subaccounts of account the session may also trade, as 0x hex. See Subaccounts.
noncestringA random nonzero value of at most 128 bits, as lowercase 0x hex without leading zeros
issuedAtuint64When the grant was created, in Unix seconds
expiresAtuint64When the session ends, in Unix seconds

Lifetime

issuedAt must be within the last 24 hours, which leaves time for multisig owners to collect signatures, and no more than 5 minutes ahead of server time. expiresAt must be in the future and at most 30 days after the earlier of issuedAt and the time the server receives the grant. A grant that lists trade:block or account:settings lasts at most 7 days. Seven days is a sensible default for a browser session.

Limits

Limits is part of the signed message and every field must be present:

FieldType
maxOrderNotionalstring
maxOpenNotionalstring
dailyNotionalstring
maxLossstring
maxLeveragestring
marketsstring[]

Session limits are not enforced at launch, so the server only accepts a grant that states no limit: every amount set to "none" and markets set to ["*"]. Any other value returns LIMIT_INVALID. The fields exist so that grants keep the same shape if limits are introduced later. Until then a session can trade up to whatever the account itself can.

{
"maxOrderNotional": "none",
"maxOpenNotional": "none",
"dailyNotional": "none",
"maxLoss": "none",
"maxLeverage": "none",
"markets": ["*"]
}

Builder

Builder is also part of every grant. A grant that approves no builder sends the empty builder:

{ "account": "0x0", "maxFeeRate": "0", "expiresAt": 0 }

An EVM owned account can instead approve a builder, a front end that may add its own fee to the orders the session places. Builder approvals may be limited during rollout.

  • account is the builder’s Paradex account, which cannot be the granting account.
  • maxFeeRate is the highest fee the builder may charge, as a decimal fraction above 0 with at most 8 decimal places, and at most 0.01. Each order’s builder fee is also held to the cap Paradex sets for its market kind, which can be lower.
  • expiresAt is 0 for the approval to expire when the session would, or a future time no later than the grant’s expiresAt.
  • The grant cannot list trade:block or account:settings.
  • The approval is recorded on every account the grant covers, and outlives the session: revoking the session does not revoke it.

Subaccounts

An EVM owned account can list up to 32 of its EVM subaccounts, and the session key then signs in to each one separately. A listed address must be an onboarded subaccount that the owner’s wallet created under account and has not archived. Any other address, including a Starknet subaccount, returns ACCOUNT_NOT_ELIGIBLE after the owner has signed, so check the list first. Archiving a subaccount does not end sessions that already cover it.

  • The owner’s main key session creates an EVM subaccount with POST /v2/account/subaccounts, which takes no body and returns its address and index. Access may be limited during rollout.
  • GET /v2/onboarding/subaccounts?eth_address=<wallet> lists a wallet’s EVM subaccounts, lowest index first, without a JWT, so an app can fill in the grant before it signs in. Archived subaccounts are left out.

Grants from Starknet owned accounts cannot list subaccounts, and neither can a grant that opens a new account. Only a main account can anchor a grant; a vault operator account can hold a session for itself alone, from a grant with no subaccounts and no builder.

3. Sign the grant

The owner signs the grant as typed data. Both encodings use the domain name Paradex Session and version 1, which differ from the Paradex domain used for orders and auth, so a grant prompt never looks like an order.

The domain chainId is the chain the wallet is currently connected to, so the wallet never needs to switch networks. The Paradex chain and environment are bound inside the message instead. Sign with eth_signTypedData_v4.

{
"types": {
"EIP712Domain": [
{ "name": "name", "type": "string" },
{ "name": "version", "type": "string" },
{ "name": "chainId", "type": "uint256" }
],
"SessionGrant": [
{ "name": "paradexChain", "type": "string" },
{ "name": "environment", "type": "string" },
{ "name": "account", "type": "string" },
{ "name": "sessionKey", "type": "string" },
{ "name": "label", "type": "string" },
{ "name": "scopes", "type": "string[]" },
{ "name": "limits", "type": "Limits" },
{ "name": "builder", "type": "Builder" },
{ "name": "subaccounts", "type": "string[]" },
{ "name": "nonce", "type": "string" },
{ "name": "issuedAt", "type": "uint64" },
{ "name": "expiresAt", "type": "uint64" }
],
"Limits": [
{ "name": "maxOrderNotional", "type": "string" },
{ "name": "maxOpenNotional", "type": "string" },
{ "name": "dailyNotional", "type": "string" },
{ "name": "maxLoss", "type": "string" },
{ "name": "maxLeverage", "type": "string" },
{ "name": "markets", "type": "string[]" }
],
"Builder": [
{ "name": "account", "type": "string" },
{ "name": "maxFeeRate", "type": "string" },
{ "name": "expiresAt", "type": "uint64" }
]
},
"primaryType": "SessionGrant",
"domain": { "name": "Paradex Session", "version": "1", "chainId": 1 },
"message": {
"paradexChain": "<starknet_chain_id>",
"environment": "mainnet",
"account": "0x<account>",
"sessionKey": "0x<session public key>",
"label": "My trading app",
"scopes": ["trade"],
"limits": {
"maxOrderNotional": "none",
"maxOpenNotional": "none",
"dailyNotional": "none",
"maxLoss": "none",
"maxLeverage": "none",
"markets": ["*"]
},
"builder": { "account": "0x0", "maxFeeRate": "0", "expiresAt": 0 },
"subaccounts": [],
"nonce": "0x<random nonce>",
"issuedAt": 1767225600,
"expiresAt": 1767830400
}
}

Only signatures from externally owned accounts are accepted: a 65 byte r || s || v signature with a canonical (low) s. Smart contract wallet signatures are refused.

Addresses, keys and the nonce must be 0x hex. Labels and other string fields must be printable ASCII. These rules keep a grant’s meaning identical in both encodings.

The grant id

The grant id identifies the session in every later request. POST /v2/sessions returns it, and you can compute it yourself:

  • for an EVM owned account, the EIP-712 struct hash of the SessionGrant message. It does not include the domain, so it does not depend on the chain the wallet signed on;
  • for a Starknet owned account, the SNIP-12 message hash.

Either way it is written as 0x followed by 64 lowercase hex characters.

4. Open the session

POST /v2/sessions needs no JWT: the owner’s signature is the authentication.

POST /v2/sessions
Content-Type: application/json
FieldTypeDescription
grantobjectThe SessionGrant message as signed, with its camelCase field names. Each field must appear once. Send issuedAt, expiresAt and builder.expiresAt as JSON integers, including for snip12, where the signed message writes them as decimal strings.
signaturestringFor eip712, the 0x hex signature: r, s and v concatenated. For snip12, the string '["0xr","0xs"]', as orders carry it. A bare ["0xr", "0xs"] array is also accepted.
signature_typestringeip712 for EVM owned accounts, snip12 for Starknet owned accounts
signature_chain_idintegerThe EIP-712 domain chainId the wallet signed with. Required for eip712, ignored for snip12.
referral_codestringOptional. Read only when the grant opens a new account.
marketing_codestringOptional. Read only when the grant opens a new account.
utmobjectOptional source, campaign and type. Read only when the grant opens a new account.
{
"grant": { "paradexChain": "...", "environment": "mainnet", "...": "..." },
"signature": "0x<130 hex characters>",
"signature_type": "eip712",
"signature_chain_id": 1
}

Response 200

FieldTypeDescription
grant_idstringThe grant id
expires_atintegerWhen the session expires, in milliseconds
accountsstring[]Every account the session can trade: the anchor account, then each listed subaccount
{
"grant_id": "0x5f1c0a4e2b7d9e3f6a8c1b0d2e4f6a8c0b2d4e6f8a0c2e4b6d8f0a2c4e6b8d0f",
"expires_at": 1767830400000,
"accounts": ["0x<account>"]
}

Check that grant_id, accounts and expires_at match the grant you signed before you rely on the session.

Each grant can be used once. Sending the same grant again, or another grant with the same nonce, returns NONCE_REUSED.

Open a new account with the first grant

An EVM wallet that has no Paradex account yet can open one with its first session grant, with no separate onboarding call. Sign the grant as usual, with account set to the address the server derives for the wallet, and send it to POST /v2/sessions. GET /v1/onboarding?account_signer_type=eip191&eth_address=<wallet> returns that address, without a JWT. Any other address returns INVALID_SIGNATURE after the wallet has signed. The server opens the account and the session together.

  • The account is deployed on chain when it is first funded. Until then, RFQ requests return 400 NOT_ONBOARDED.
  • referral_code, marketing_code and utm work as they do for POST /v2/onboarding. They are not part of what the wallet signs, and are ignored for an account that already exists and for a grant that approves a builder.
  • The grant cannot list subaccounts.
  • The wallet must be an externally owned account. Smart contract wallets cannot sign a grant, so they onboard the usual way.
  • The request runs the same checks as onboarding, so it can also return the onboarding errors below.

Errors

StatusErrorMeaning
400INVALID_SIGNATUREThe signature is not the account owner’s (a smart contract wallet’s never is), does not match signature_type, or names an account that cannot be verified
400GRANT_EXPIREDexpiresAt has passed, or issuedAt is outside the accepted window
400INVALID_ENVIRONMENTThe grant is for another environment
400INVALID_CHAINThe grant is for another Paradex chain
400SCOPE_NOT_ALLOWEDA scope is unknown, reserved or repeated, or not allowed on a grant that approves a builder
400LIMIT_INVALIDA limit is missing, malformed or not none, markets is not ["*"], or the expiry is longer than allowed
400NONCE_REUSEDThe grant or its nonce was already used
400ACCOUNT_NOT_ELIGIBLEThe account or a listed subaccount cannot hold sessions, or a Starknet owned account approves a builder
400INVALID_GRANTThe grant does not match the SessionGrant schema, or its builder is invalid
400SESSION_KEY_IN_USEThe session key is, or was, a key of a listed account
400SESSION_LIMIT_REACHEDThe account holds the most active sessions it may. Revoke one first.
400BUILDER_APPROVAL_LIMIT_REACHEDA covered account already holds the most live builder approvals it may
400BUILDER_APPROVAL_STALEThe builder’s approval was revoked after the grant was signed, or a live approval for the same builder has other terms. Sign a new grant.
403SESSIONS_DISABLEDSessions, or builder approvals for a grant that approves a builder, are not available for this account yet

When the grant opens a new account it can also return:

StatusErrorMeaning
400INVALID_MARKETING_CODEmarketing_code is not a known code
400INVALID_REQUEST_PARAMETERmarketing_code is not in the form campaign:code, or utm lacks source or campaign
400INSUFFICIENT_MIN_CHAIN_BALANCEThe wallet does not hold the minimum balance onboarding requires
400ETHEREUM_ADDRESS_BLOCKEDThe wallet or account is blocked.
400PARENT_ADDRESS_ALREADY_ONBOARDEDThe wallet already owns a different account
400ACCOUNT_NOT_ELIGIBLEThe grant lists subaccounts, or a new account cannot be opened with a grant
429ONBOARDING_RATE_LIMITEDToo many new accounts from this IP address. Try again later.

5. Sign in with the session key

The session key signs in like a subkey: call POST /v1/auth/{public_key} with the session public key in the path, the account address in PARADEX-STARKNET-ACCOUNT, and PARADEX-STARKNET-SIGNATURE signed by the session private key. Repeat for each account in accounts to get one JWT per account.

The public key in the path is required. POST /v1/auth without it checks the signature against the account’s main key, so it refuses a session key’s signature.

  • Sign and send both PARADEX-TIMESTAMP and PARADEX-SIGNATURE-EXPIRATION. The expiration must be at most 15 minutes after the timestamp and no later than the session’s expiry.
  • A session JWT lasts at most 15 minutes and never outlives its session. Sign in again to refresh it.
  • Once the session is revoked or expired, /auth returns SESSION_REVOKED or SESSION_EXPIRED.
  • If the owner has set an IP allowlist for the session, sign in and every later request must come from an allowed IP, or they return 403 IP_NOT_ALLOWED.

Use the JWT and the session key for REST and WebSocket calls exactly as you would a subkey’s: send the JWT as the bearer token, and sign orders with the session private key. Every request is held to the grant’s scopes.