Create a key
- Sign in at 4casters.io and open My Account → Security → API Keys → Manage, or go straight to 4casters.io/account/api-keys.
- Click Create Key. Give it a name, optionally restrict it to IP ranges, and optionally give it an expiry.
- Copy the key from the confirmation. It is shown once. 4casters stores only a hash of it; if you lose it, revoke it and create another.
Anatomy of a key
Treat the whole string as the credential. Keep it out of source control, client-side code and logs.
Use a key
Send the key in theAuthorization header, exactly where a login token goes. The Bearer prefix is optional. Nothing else changes: the same endpoints, the same messages, the same responses.
- REST API
- Orders WebSocket
- Streaming WebSocket
Allowed IPs
A key can be restricted to a list of client addresses: IPv4 or IPv6, single addresses or CIDR ranges, mixed freely. A request from any other address is refused with403 ApiKeyIpNotAllowed, on every request, so a key that leaves its network stops working at once. An empty list means the key works from anywhere.
The address checked is the one your request reaches 4casters from. If your program sits behind NAT or a proxy, that is the proxy’s public address. You can change a key’s allowed IPs at any time from the account page; the key itself does not change.
Expiry
Optional, chosen when the key is created: never, 30, 90 or 365 days. An expired key is refused with401 ApiKeyExpired and stays listed on the account page marked Expired until you revoke it.
What a key can and cannot do
A key acts as your account on the exchange: read your bets and positions, read markets, place, edit and cancel orders over REST or the Orders WebSocket, subscribe to the Streaming feeds, and everything else a login token can do, except account administration. These need a signed-in website session and answer403 LoginSessionRequired to a key:
- Creating, renaming, changing or revoking API keys
- Changing your password, name or phone number
- Two-factor authentication setup
- Withdrawals and withdrawal addresses
Manage keys
From My Account → Security → API Keys, each key’s menu offers:- Rename
- Edit Allowed IPs
- Revoke. Takes effect on the next request, and any open WebSocket on that key is closed within a minute. Anything still using the key gets
401 InvalidCredentials.