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 with your Bearer token.
  2. Request a WebSocket URL via POST /trading/v1/options/accounts/{accountId}/otp — the response contains a ready-to-use WebSocket URL with the OTP already embedded.
  3. Connect directly to the WebSocket URL returned in the previous step. No additional headers are needed.
  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 →
WebSockets
POST
Get a WebSocket URL via OTP and connect for real-time Options trading
/trading/v1/options/accounts/{accountId}/otpView 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 authenticated endpoints require both the Deriv-App-ID header to identify your application and an Authorization: Bearer YOUR_AUTH_TOKEN header with the appropriate OAuth2 scope.

OAuth2 Scopes

Each endpoint requires a specific OAuth2 scope:

EndpointScope
GET /trading/v1/options/accountstrade
POST /trading/v1/options/accountsaccount_manage
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 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
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.