{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Platform Transfer Request",
  "description": "Transfer between a wallet and a trading platform account owned by the authenticated client. The body is a strict whitelist - fields not listed here are rejected with 400.",
  "type": "object",
  "properties": {
    "headers": {
      "type": "object",
      "properties": {
        "Deriv-App-ID": {
          "type": "string",
          "description": "Application identifier"
        },
        "Authorization": {
          "type": "string",
          "description": "Bearer token for authentication",
          "example": "Bearer YOUR_AUTH_TOKEN"
        },
        "Content-Type": {
          "type": "string",
          "enum": ["application/json"],
          "description": "Content type"
        }
      },
      "required": ["Deriv-App-ID", "Authorization", "Content-Type"]
    },
    "body": {
      "type": "object",
      "additionalProperties": false,
      "description": "Send wallet_currency, exchange_rate and rate_token together, or none of them. Supplying one without the other two is rejected with 400.",
      "properties": {
        "wallet_id": {
          "type": "string",
          "format": "uuid",
          "description": "Wallet on the wallet side of the transfer. Must belong to the authenticated client.",
          "example": "942a2f2d-1f33-4559-994e-42b403033bc6"
        },
        "amount": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "Transfer amount as a decimal string, in currency. Any applicable fee is deducted from this amount.",
          "example": "100.00"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z0-9_]{1,18}$",
          "description": "Currency of the platform account. Must match the account's actual currency.",
          "example": "USD"
        },
        "direction": {
          "type": "string",
          "enum": ["to_wallet", "from_wallet"],
          "description": "from_wallet debits the wallet to fund the platform account; to_wallet debits the platform account to fund the wallet."
        },
        "platform_name": {
          "type": "string",
          "enum": ["mt5", "ctrader", "options", "crypto-exchange", "tradingview"],
          "description": "Trading platform of the account."
        },
        "platform_account_id": {
          "type": "string",
          "description": "Login or account identifier on the platform. Must belong to the authenticated client and be a real account, not a demo one.",
          "example": "MTR9000001"
        },
        "request_id": {
          "type": "string",
          "format": "uuid",
          "description": "Idempotency key. Reusing a request_id you have already submitted is rejected with DuplicateRequestID.",
          "example": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
        },
        "description": {
          "type": "string",
          "description": "Optional free-text note attached to the transfer.",
          "example": "Fund MT5 account"
        },
        "wallet_currency": {
          "type": "string",
          "pattern": "^[A-Z0-9_]{1,18}$",
          "description": "The wallet's currency. Send only for cross-currency platform transfers, when it differs from currency; exchange_rate and rate_token are then required too.",
          "example": "EUR"
        },
        "exchange_rate": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "Quoted exchange rate as a positive decimal string. Required together with rate_token when wallet_currency differs from currency.",
          "example": "0.92"
        },
        "rate_token": {
          "type": "string",
          "description": "Token attesting to the quoted exchange rate. Required together with exchange_rate when wallet_currency differs from currency.",
          "example": "eyJhbGciOi..."
        }
      },
      "required": [
        "wallet_id",
        "amount",
        "currency",
        "direction",
        "platform_name",
        "platform_account_id",
        "request_id"
      ]
    }
  },
  "required": ["headers", "body"]
}
