Skip to main content
An authenticated session is a two-way authenticated communication channel with the Perps system that allows your app to place orders, read private Perps account data, and receive private real-time updates.

Set Up Perps Access

1

Create a Secure Client

Create a SecureClient for the Polymarket wallet that owns the Perps account, using the signer that controls it.
This example uses Viem for wallet signing. See the TypeScript tooling guide for other wallet library integrations.
2

Open a Perps Session

Open a Perps session. By default, delegated Perps credentials expire after one week.
You can also set the session lifetime and label explicitly. expiresIn is measured in milliseconds.

Session Lifecycle

Open an authenticated session to start trading, read private Perps account data, and receive private real-time updates.
1

Listen for Session Events

After opening a Perps session, iterate over it to receive private real-time updates.
This example handles a few common session events. order and fill are the core trading updates, while portfolio provides periodic account-level snapshots for margin, equity, positions, and withdrawable balance.See Reconcile Trade State for how to use these events to keep local trading state in sync.
2

Close the Session

You can close the session at any time by calling session.close(). Closing a session releases local resources; stored credentials can still be resumed until they expire.

Resume a Session

Resume a session when stored credentials are still valid and a Perps workflow needs to continue in a new runtime context.
Read session.credentials after opening a session and store the object in secure credential storage.
where PerpsCredentials is:
Pass stored credentials back to openPerpsSession() while they are still valid. The SDK validates them and resumes the session.