Options Setup
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.
REST API
Deriv-App-ID: YOUR_APP_ID header and an Authorization: Bearer YOUR_OAUTH_TOKEN token for authenticated endpoints.OpenAPI Specification
View the complete OpenAPI 3.1.0 specification for detailed schema definitions and examples:
Typical Workflow
- Create an Options trading account using
POST /trading/v1/options/accountswith your Bearer token. - 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. - Connect directly to the WebSocket URL returned in the previous step. No additional headers are needed.
- Start trading operations through the WebSocket connection.
Available Endpoints
/trading/v1/options/accountsView documentation →/trading/v1/options/accountsView documentation →/trading/v1/options/accounts/{account_id}/reset-demo-balanceView documentation →/trading/v1/options/accounts/{accountId}/otpView documentation →/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:
| Endpoint | Scope |
|---|---|
GET /trading/v1/options/accounts | trade |
POST /trading/v1/options/accounts | account_manage |
POST /.../{account_id}/reset-demo-balance | trade |
POST /.../{accountId}/otp | trade |
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:
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