Register a session key
const url = 'https://example.com/api/user/me/session-keys';const options = { method: 'POST', headers: { 'INF-ACCESS-KEY': '<INF-ACCESS-KEY>', 'INF-ACCESS-TIMESTAMP': '<INF-ACCESS-TIMESTAMP>', 'INF-ACCESS-SIGNATURE': '<INF-ACCESS-SIGNATURE>', 'Content-Type': 'application/json' }, body: '{"session_key":"example","public_key":"example","expires_at_ms":1,"grant":{"wallet":"example","issued_at_ms":1,"issued_at_token":"example","signature":"example"},"password":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/user/me/session-keys \ --header 'Content-Type: application/json' \ --header 'INF-ACCESS-KEY: <INF-ACCESS-KEY>' \ --header 'INF-ACCESS-SIGNATURE: <INF-ACCESS-SIGNATURE>' \ --header 'INF-ACCESS-TIMESTAMP: <INF-ACCESS-TIMESTAMP>' \ --data '{ "session_key": "example", "public_key": "example", "expires_at_ms": 1, "grant": { "wallet": "example", "issued_at_ms": 1, "issued_at_token": "example", "signature": "example" }, "password": "example" }'Registers a P-256 key that signs your orders, modifies and cancels. public_key is its uncompressed public key: 0x04, then x and y, 65 bytes in hex. session_key is its name: the last 20 bytes of keccak256 of x followed by y. A name can be registered once only. A key registered with a login lasts at most 30 days. A key registered with an API key lasts at most 180 days with a grant, and 24 hours without one. When your account has a linked wallet, each key needs a grant: the wallet’s EIP-712 SessionKeyGrant signature. Its issued_at_ms and issued_at_token must come from GET /me/session-keys/issued-at less than 10 minutes before, and the key’s lifetime counts from that issued_at_ms. The first grant links its wallet and revokes your keys that have no grant. Only a login can send the first grant. If your account has no linked wallet, send password, your current password, with a login. An API key does not need it. You can have 20 live keys. Then a new key replaces the oldest key of the same login or API key. With an API key, the signature also covers the request body: timestamp + method + path + body. 400: a bad key, expiry or grant, or no password. 403: a wrong password, the linked wallet did not sign a grant, or an API key sent the first grant. 409: the name was registered before, or no key of this login or API key can be replaced. 429: more than 5 registrations for your account in one minute, or too many wrong passwords.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
object
Examplegenerated
{ "session_key": "example", "public_key": "example", "expires_at_ms": 1, "grant": { "wallet": "example", "issued_at_ms": 1, "issued_at_token": "example", "signature": "example" }, "password": "example"}Responses
Section titled “Responses”Successful Response
object
Examplegenerated
{ "session_key": "example", "public_key": "example", "expires_at_ms": 1, "registered_at_ms": 1, "api_key_id": "example", "wallet": "example"}Validation Error
object
object
object
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example", "input": "example", "ctx": {} } ]}