Deriv API
K

Options Setup

REST API

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.

OpenAPI Specification

View the complete OpenAPI 3.1.0 specification for detailed schema definitions and examples:

Typical Workflow

  1. Create an Options trading account using POST /trading/v1/options/accounts
  2. Get OTP token for WebSocket authentication using POST /trading/v1/options/accounts/{accountId}/otp
  3. Connect to WebSocket using the OTP token at /trading/v1/options/ws/demo or /trading/v1/options/ws/real
  4. Start trading operations through the WebSocket connection

Available Endpoints

Get All Accounts
GET
Get all Options trading accounts
/trading/v1/options/accountsView documentation →
Create Account
POST
Create a new Options trading account
/trading/v1/options/accountsView documentation →
Reset Demo Account Balance
POST
Reset balance for Options trading demo account
/trading/v1/options/accounts/{account_id}/reset-demo-balanceView documentation →
Get OTP for WebSocket Authentication
POST
Get one-time password (OTP) for WebSocket authentication
/trading/v1/options/accounts/{accountId}/otpView documentation →
WebSocket Demo Endpoint
GET
WebSocket endpoint for Options trading demo account
/trading/v1/options/ws/demoView documentation →
WebSocket Real Endpoint
GET
WebSocket endpoint for Options trading real account
/trading/v1/options/ws/realView documentation →
WebSocket Public Endpoint
GET
WebSocket endpoint for Options Trading public data that does not require authentication
/trading/v1/options/ws/publicView documentation →

Authentication

All Options Setup endpoints require the Deriv-App-ID header to identify your application, plus OAuth2 authentication with the appropriate scope.

OAuth2 Scopes

Each endpoint requires a specific OAuth2 scope:

EndpointScope
GET /trading/v1/options/accountstrade
POST /trading/v1/options/accountsadmin
POST /.../{account_id}/reset-demo-balancetrade
POST /.../{accountId}/otptrade

Example Request

curl -X POST https://api.derivws.com/trading/v1/options/accounts \
  -H "Deriv-App-ID: YOUR_APP_ID" \
  -H "Authorization: Bearer YOUR_OAUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -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)
201 Created - New resource created successfully
101 Switching Protocols - WebSocket connection established
4xx/5xx Errors
400 Bad Request - Invalid parameters or request body
401 Unauthorized - Invalid or missing authentication
404 Not Found - Resource not found
500 Internal Server Error - Server-side error

Error Response Format

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

{
  "errors": [
    {
      "status": 400,
      "code": "ValidationError",
      "message": "currency field is required"
    }
  ],
  "meta": {
    "endpoint": "/accounts",
    "method": "POST",
    "timing": 23
  }
}

Error codes include: ValidationError,FieldIsRequired,Unauthorized,NotFound

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