Runbook: Session Key setup
Use this runbook to create the key that sesame uses to read your Polymarket account and to trade. The key is a Polymarket Session Key: it can place and cancel orders for your Deposit Wallet, but it is not the account’s owner key. The owner key never goes into this app. For combos, the key also needs the combos scope (section 8). The words this page uses are in the deploy guide’s Words used in these pages. Each setting is in the configuration reference. Background: Polymarket venue notes §10, secrets and logging policy, ADR 0009 and ADR 0012. Official Polymarket documentation:- Session Keys: https://docs.polymarket.com/trading/session-keys
- Wallets and authentication: https://docs.polymarket.com/trading/wallets-auth
- API authentication: https://docs.polymarket.com/getting-started/api
1. Before you start
You need these things:
Session Keys are in beta. Polymarket can change the steps. Read the official page before each
rotation.
CAUTION: Do not put the Session Key on the development server. That server is in a blocked
location (security finding F8). Development there uses the fake venue (
task dev:fake).
What a Session Key can and cannot do:
2. Create the key
2.1 Make the key pair on the app host
-
On the app host, make a new key pair. Any standard tool can do this. With Foundry, type:
The command shows an address and a private key.
- Keep the private key on the app host. You need it in section 3.
- Copy only the address to the owner machine.
2.2 Authorise the key from the owner machine
-
On the owner machine, use the official TypeScript SDK (
@polymarket/client) or the Python SDK (polymarket). With the TypeScript SDK, run this code: - Write down the expiry date: 180 days from today. You must rotate the key before that date (section 5).
- Always give
scopes. If you do not, the SDK usesALL. - Without combos, give
CLOBonly. For combos, giveCLOBandCOMBOSRFQ, notALL(section 8).ALLalso covers each venue Polymarket adds later (security finding P8-11). - The key works when it is in the wallet’s list of session signers. The SDK waits for this.
- The environment variable names in the code are for the owner machine only. Never put the owner key or the Builder API key in this app’s settings.
3. Configure the app
-
On the server, open the settings file:
-
Add these lines, with your values:
- Save the file and close the editor.
-
On your computer, restart the app:
The command ends with a table that lists the
sesameandcaddyservices. - Do the checks in section 4.
.env file in the repository root. Make the file
readable only by the account that runs the app: mode 0600 on Linux, or icacls on Windows.
The deploy guide gives the full go-live steps in
Go live, step 3.
- Leave the three
POLYMARKET_CLOB_*settings empty. At each start, the app makes the CLOB API credentials from the Session Key. It keeps them in memory only, never on disk, in the database or in the log (ADR 0009). If you set them, the app uses them and makes none. Set all three or none. - The old name is refused. If the file has a
POLYMARKET_PRIVATE_KEYline, even an empty one, the app does not start. Rename it toPOLYMARKET_SESSION_KEY. Make sure that the value is a Session Key, not the owner key. - Other refused lines. The app also does not start with
GEOBLOCK_URL, or with a name that starts withPOLYMARKET_RELAYER_,POLYMARKET_BRIDGE_URL,POLY_BUILDER_orPOLYMARKET_BUILDER_. The Builder API key stays on the owner machine.
4. Check that it worked
-
The app starts. If a setting is wrong, the app does not start and its log names the
setting. The log never shows the key. The app stops when:
- the Session Key is not 64 hex characters, with or without
0x, or is not a valid private key - an address is not 40 hex characters, with or without
0x - the Session Key’s address,
POLYMARKET_SIGNER_ADDRESSor the wallet address is the same asPOLYMARKET_OWNER_ADDRESS - the wallet address is the same as the Session Key’s address
- a Session Key or CLOB credentials are set without
POLYMARKET_WALLET_ADDRESS - only some of the three
POLYMARKET_CLOB_*settings are set, or a refused line is in the file
- the Session Key is not 64 hex characters, with or without
-
The start log confirms the key. On your computer, read the log:
Find the line
session key confirmed. Itssignerfield is the Session Key’s address. ItsvalidUntilfield is the expiry. Itsscopesfield lists the scopes, for exampleCLOB. -
Settings shows the account. In the app, open Settings > Account. Make sure that:
- Credentials shows Connected
- Signer address (Session Key) is the address from step 2.1, not the owner’s address
- Wallet address (Deposit Wallet) is the Deposit Wallet address
The top bar shows the same label beside Cash when the state is not Connected. -
The figures match. Compare the top bar with polymarket.com:
- Positions and cash must be the same.
- The app shows only the orders that this Session Key placed. Orders placed on polymarket.com do not show in the app.
5. Rotation
Rotate the key before its 180 days end. Rotate it at once if the key may be exposed: in a log, a commit, a screenshot, a chat or an agent session, or on a host that may be compromised.- Make a new key pair on the app host (2.1).
- Authorise it from the owner machine (2.2).
- Put the new key in
POLYMARKET_SESSION_KEY(section 3). - If you set the
POLYMARKET_CLOB_*settings, clear them. They belong to the old key. - Restart the app.
- Make sure that Settings > Account shows the new signer address and Connected (section 4).
- Revoke the old key from the owner machine (section 6).
6. Revocation
-
On the owner machine, use the same SDK client as in step 2.2:
- Wait for the call to return. The key is then not active.
- Revocation stops the key from trading and cancels its open orders. It does not change the orders of other Session Keys or of the owner.
- Polymarket finishes the cancels and the on-chain step after the call returns.
- After revocation, the app’s next call with the credentials gets status 401. The app then
checks its clock and tries to make new credentials. When that fails, the credentials show
Account error with
auth_rejected. If the clock is more than 2 seconds wrong, the reason isclock_skew.
- In the app, click Cancel all.
- Set the switch to Safe.
- Set
LIVE_TRADING=falsein the settings file and restart the app. - Revoke the Session Key from the owner machine (step 1 above). It is not enough to revoke the CLOB credentials, because the key can make new ones. The key may be able to move funds (ADR 0012). If the relayer is not available, use the owner-only emergency path in ADR 0012: pause, wait one hour, then revoke.
- On polymarket.com, look for trades in your positions and history that the app did not make.
- Follow the compromise steps in the secrets and logging policy.
7. Troubleshooting
When the credentials fail, Settings > Account showsAccount credentials failed: <reason>.
The reason is a fixed code. Polymarket’s own error text goes only to the app’s log.
For
wallet_mismatch:
- Make sure that
POLYMARKET_WALLET_ADDRESSis the Deposit Wallet that you authorised the key for in step 2.2. - Make sure that the key has the
CLOBorALLscope and that you did not revoke it. A key withCOMBOSRFQalone gives this reason, because the app needsCLOBtoo. - Make sure that the key is not expired. If it is, make a new key (section 5).
- Read the log for
session signers listed for another wallet. If you find it, Polymarket answered for another wallet. ItswalletandvenueWalletfields show the two addresses, with only the first 6 and last 4 characters. EitherPOLYMARKET_WALLET_ADDRESSholds another address, such as the owner’s, or you authorised the key for another account.
8. Combos scope
Combos get quotes from Polymarket’s market makers. To accept a quote, the app signs an order. The app sends these requests with the Session Key’s credentials. Polymarket accepts them only from a key with theCOMBOSRFQ or ALL scope
(ADR 0014). A key with CLOB alone can still trade
other markets, but combos stay off.
8.1 How a CLOB-only key shows
The app reads the scopes from Polymarket when it starts. After you change the key, restart the
app.
8.2 Issue a key with the combos scope
This makes a new key, then revokes the old one, as in a rotation (section 5).- In the app, click Cancel all.
- Set the switch to Safe.
- On polymarket.com, make sure that no order from the app is still open. The new key cannot see the orders of the old key, and revocation cancels them.
- Make a new key pair on the app host (2.1).
-
On the owner machine, authorise it with the same client as in step 2.2, with both scopes:
-
Put the new key in
POLYMARKET_SESSION_KEY. Clear thePOLYMARKET_CLOB_*settings if you set them (section 3). - Restart the app.
-
Make sure that:
- Settings > Account shows the new signer address and Connected
- the
session key confirmedlog line listsCLOBandCOMBOSRFQinscopes GET /api/accountshowscredentials.scopesas["trading","combos"]GET /api/tradingdoes not listcombos_unavailableincombos_reasons. While the app is Safe, it listsnot_armed. You can get a quote while the app is Safe
- Revoke the old key from the owner machine (section 6). Do this only after the new key shows Connected, so that the app always has a key that works.
- Use
CLOBandCOMBOSRFQ, notALL(security finding P8-11).ALLalso works, but it covers each venue Polymarket adds later. - Do not use
COMBOSRFQalone. The app needsCLOBtoo and shows such a key aswallet_mismatch(section 7). - The choice does not change what a leaked key can do on-chain (ADR 0012). The working-balance limit in ADR 0013 stays the same.
- The new key is valid for 180 days.
8.3 Exchange approvals
A combo buy spends pUSD through Polymarket’s Combos exchange (Exchange V3). A combo sell gives combo shares to that exchange. Both need the wallet’s approval of the exchange: pUSD for buys, combo positions for sells.- Set both approvals on polymarket.com, as the owner.
Rejected · not enough cash or allowance (venue_balance).