Skip to content

Register a session key

POST
/api/user/me/session-keys
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.

Media typeapplication/json
SessionKeyRegistration
object
session_key
required
Session Key
string
public_key
required
Public Key
string
expires_at_ms
required
Expires At Ms
integer
grant
Any of:
WalletGrant
object
wallet
required
Wallet
string
issued_at_ms
required
Issued At Ms
integer
issued_at_token
required
Issued At Token
string
<= 64 characters
signature
required
Signature
string
password
Any of:
string
<= 128 characters
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"
}

Successful Response

Media typeapplication/json
SessionKey
object
session_key
required
Session Key
string
public_key
required
Public Key
string
expires_at_ms
required
Expires At Ms
integer
registered_at_ms
required
Registered At Ms
integer
api_key_id
required
Any of:
string
wallet
required
Any of:
string
Examplegenerated
{
"session_key": "example",
"public_key": "example",
"expires_at_ms": 1,
"registered_at_ms": 1,
"api_key_id": "example",
"wallet": "example"
}

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}