Deriv API
Documentation
Options Setup

Options Setup REST

Manage Options trading accounts and establish WebSocket connections for real-time trading.

Overview

The Options Setup APIs allow you to create and manage Options trading accounts using REST endpoints. These endpoints handle account creation, balance management, and WebSocket authentication setup.

Typical Workflow

  1. Create an Options trading account using POST /trading/v1/options/accounts.
  2. Request a WebSocket URL via POST /trading/v1/options/accounts/{accountId}/otp.
  3. Connect directly to the WebSocket URL returned.
  4. Start trading operations through the WebSocket connection.

Available Endpoints

Get All AccountsGet
Get all Options trading accounts/trading/v1/options/accounts
Create AccountPost
Create a new Options trading account/trading/v1/options/accounts
Reset Demo Account BalancePost
Reset balance for Options trading demo account/trading/v1/options/accounts/{account_id}/reset-demo-balance
WebSocketsPost
Issues a short-lived one-time password (OTP) that authenticates a subsequent WebSocket connection for the specified account. The response includes the OTP and a ready-to-use WebSocket URL with the OTP attached as a query parameter. The OTP is valid for 120 seconds and can be used only once, so open the WebSocket connection promptly after calling this endpoint./trading/v1/options/accounts/{accountId}/otp
WebSocket Demo EndpointGet
Upgrades the connection to a WebSocket scoped to a demo Options Trading account. Requires a valid one-time password (OTP) from the OTP endpoint, passed as the otp query parameter. Use this channel to subscribe to market data, send trading instructions, and receive order and position updates for the demo account./trading/v1/options/ws/demo
WebSocket Real EndpointGet
Upgrades the connection to a WebSocket scoped to a real-money Options Trading account. Requires a valid one-time password (OTP) from the OTP endpoint, passed as the otp query parameter. Trades placed over this channel settle against the account's real balance./trading/v1/options/ws/real
WebSocket Public EndpointGet
Streams real-time public market data — quotes, ticks, and contract metadata — with no authentication or OTP required. Account-scoped actions such as placing trades or reading balances aren't available on this channel./trading/v1/options/ws/public

Authentication

All authenticated endpoints require the Deriv-App-ID header and an Authorization: Bearer YOUR_AUTH_TOKEN header.

OAuth2 Scopes

EndpointScope
GET /trading/v1/options/accountstrade
POST /trading/v1/options/accountsaccount_manage
POST /.../reset-demo-balancetrade
POST .../{accountId}/otptrade
1curl -X POST https://api.derivws.com/trading/v1/options/accounts \
2  -H "Deriv-App-ID: YOUR_APP_ID" \
3  -H "Authorization: Bearer YOUR_OAUTH_TOKEN" \
4  -H "Content-Type: application/json" \
5  -d '{"currency": "USD", "group": "row", "account_type": "demo"}'

Response Status Codes

The API uses standard HTTP status codes to indicate success or failure:

2xx Success
200 OK — Request successful (existing account or OTP generated)
201 Created — New resource created successfully
4xx/5xx Errors
400 Bad Request — Invalid parameters or request body
401 Unauthorized — Invalid or missing authentication
403 Forbidden — Access denied
404 Not Found — Resource not found
500 Internal Server Error — Server-side error
504 Gateway Timeout — Upstream service timeout

Error Response Format

All error responses follow a consistent structure with an errors array and metadata:

1{
2  "errors": [
3    {
4      "status": 400,
5      "code": "ValidationError",
6      "message": "currency field is required"
7    }
8  ],
9  "meta": {
10  }
11}

Error codes include: ValidationError, FieldIsRequired, Unauthorized, UnauthorizedAccess, AccessDenied, AccountNotFound, BadInputRequest, RateLimit, InternalServerError

Any other questions? Get in touch

Click to open live chat support. Get instant help from our support team.