---
title: "private/set_session_key"
method: POST
path: "/private/set_session_key"
tags: ["Session Keys"]
---

# private/set_session_key

`POST /private/set_session_key`

## Request

- Base URL: `https://api.derive.xyz/v3`
- URL: `https://api.derive.xyz/v3/private/set_session_key`
- Auth: API key in header `X-DeriveWallet` and API key in header `X-DeriveTimestamp` and API key in header `X-DeriveSignature`

Authorizes a new session key for a wallet from a signed action, granting it a set of on-chain (protocol) scopes and off-chain scopes with an expiry, an optional label, an optional IP allowlist, and an optional list of subaccounts it may act on (defaults to all of the wallet's subaccounts). Send the signed action fields (nonce, signer, signature, signature expiry, and module) alongside the requested scopes; the endpoint returns the registered key's public address and its granted scopes, expiry, allowlist, label, and subaccounts.

## Request body

- SetSessionKeyRequest: Request parameters for registering a scoped session key. Address fields are 0x-prefixed hex strings.
  - `expiry_sec` integer, required
  - `ip_whitelist` string[], nullable
  - `label` string, nullable
  - `nonce` string, required
  - `offchain_scopes` string[], required: Off-chain scopes which are validated in backend only
  - `protocol_scopes` string[], required: Scopes granted to the session key, validated by the protocol. Each is a string like `"trade:orderbook:all"`.
  - `public_session_key` string, required: Session key address being authorized.
  - `signature` string, required: 0x-prefixed hex, 65-byte r||s||v.
  - `signature_expiry_sec` integer, required
  - `signer` string, required
  - `subaccount_ids` integer[], nullable
  - `wallet` string, required: Wallet the session key is being registered for.

## Response `200`

Success

- PrivateSetSessionKeyResponse
  - `expiry_sec` integer, required
  - `ip_whitelist` string[], required
  - `label` string, nullable
  - `offchain_scopes` string[], required
  - `protocol_scopes` string[], required
  - `public_session_key` string, required
  - `subaccount_ids` integer[], required: Subaccounts the key may act on. Empty/omitted request (all subaccounts) is expanded to the wallet's current subaccount list.

## Other responses

- `default`: JSON-RPC error (see Error Codes)

## Changes

- **2026-10-20** `0c500202be49`: 2 info
  - the endpoint scheme security `DeriveWallet AND DeriveTimestamp AND DeriveSignature` was added to the API
  - added the media type `application/json` for the response with the status `default`

[Operation history](https://skmtc.dev/lyra/apis/derive-v3-api/changes/private/set_session_key/post.md)

---

[API](https://skmtc.dev/lyra/apis/derive-v3-api.md) - [All operations](https://skmtc.dev/lyra/apis/derive-v3-api/llms.txt) - [OpenAPI document](https://skmtc.dev/lyra/apis/derive-v3-api/revisions/415f8a73b10c?raw)
