{
  "openapi": "3.1.0",
  "info": {
    "title": "OX212 API",
    "version": "1.2.0",
    "summary": "A trader's behavioural risk, from OX212's engine: before an order, during the session and after it, with evidence anyone can verify.",
    "description": "OX212 reads a trader's behaviour, never the market. Readings are the trader's own risk state against the limits they declared; they are not financial advice. The API, the MCP server and the app give the same reading of each account.",
    "contact": {
      "name": "OX212",
      "email": "access@ox212.com"
    }
  },
  "servers": [
    {
      "url": "https://app.ox212.com"
    }
  ],
  "tags": [
    {
      "name": "Risk",
      "description": "The decision before an order and the active guardrails."
    },
    {
      "name": "Accounts",
      "description": "Read-only agent reads (also as MCP tools)."
    },
    {
      "name": "Evidence",
      "description": "The sealed case (signed with OX212's Ed25519 key), every decision's proof, the public key and the public seal registry."
    },
    {
      "name": "MCP",
      "description": "Model Context Protocol server for AI agents."
    },
    {
      "name": "Pay per call (x402)",
      "description": "No account: the agent sends the trades and pays each call in USDC on Base."
    }
  ],
  "paths": {
    "/api/v1/risk-check": {
      "post": {
        "operationId": "risk_check",
        "tags": [
          "Risk"
        ],
        "summary": "A decision before opening or scaling risk.",
        "security": [
          {
            "ox212Key": []
          },
          {
            "ox212Session": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 200
            },
            "description": "A repeated call with the same key and body gets the first answer (60 minutes)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RiskCheckRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The decision, with its attestation: fingerprint, OX212's signature and its record, sealed within the hour.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RiskCheckResponse"
                }
              }
            }
          },
          "400": {
            "description": "BODY_INVALID, ACCOUNT_ID_INVALID, IDEMPOTENCY_KEY_INVALID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The key's plan does not include the API (API_PLAN_REQUIRED: a personal key needs Elite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "IDEMPOTENCY_CONFLICT / IDEMPOTENCY_IN_PROGRESS.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED: 60 calls per minute and key (see Retry-After).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "risk_check_preflight",
        "tags": [
          "Risk"
        ],
        "summary": "CORS preflight.",
        "responses": {
          "204": {
            "description": "Allowed."
          }
        }
      }
    },
    "/api/v1/guardrails/current": {
      "get": {
        "operationId": "guardrails_current",
        "tags": [
          "Risk"
        ],
        "summary": "The account's active guardrails (the MCP tool «guardrails»).",
        "security": [
          {
            "ox212Key": []
          },
          {
            "ox212Session": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "An account the caller can read (GET /api/v1/agent/accounts)."
          }
        ],
        "responses": {
          "200": {
            "description": "The active guardrails, with their attestation (sealed within the hour).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Guardrails"
                }
              }
            }
          },
          "400": {
            "description": "ACCOUNT_ID_INVALID.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The key's plan does not include the API (API_PLAN_REQUIRED: a personal key needs Elite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED: 60 calls per minute and key (see Retry-After).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/guardrails/execute": {
      "post": {
        "operationId": "guardrails_execute",
        "tags": [
          "Risk"
        ],
        "summary": "Apply a guardrail (a pause through the OX212 Guard), with the trader's permission.",
        "description": "The trader, signed in (their session), on platform accounts where they allowed the Guard to pause; or a firm key (ox212_fk_), only on an account whose trader allowed that firm to pause it, always with a reason (1-200 characters, it is what the trader is told) and a lock of 1-1440 minutes (lock_minutes) or lock: \"end_of_day\"; at most 30 pauses an hour per firm, one every 2 minutes per account, and only when the trader's plan includes the pause. The trader cannot lift a firm's pause before its end; the firm can, with action UNLOCK and its firm key (200, only while its own pause runs and never over another lock still running there). A personal key is read only and gets 403 API_KEY_READ_ONLY. Idempotency-Key is required: repeating it never pauses twice.",
        "security": [
          {
            "ox212Session": []
          },
          {
            "ox212Key": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 200
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecuteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A firm key's UNLOCK: its own pause lifted on at least one platform account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteResponse"
                }
              }
            }
          },
          "201": {
            "description": "Applied on at least one platform account; the answer carries its attestation (sealed within the hour).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteResponse"
                }
              }
            }
          },
          "400": {
            "description": "ACTION_INVALID, LOCK_MINUTES_INVALID, IDEMPOTENCY_KEY_REQUIRED; REASON_REQUIRED and LOCK_INVALID (a firm key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "API_PLAN_REQUIRED (a personal key's plan), or TRADER_PLAN_WITHOUT_PAUSE (a firm key: the trader's plan does not include the pause).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "API_KEY_READ_ONLY (a personal key), FIRM_PAUSE_NOT_ALLOWED (a firm key without the trader's permission), FORBIDDEN (another origin).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not); FIRM_PAUSE_NOT_AVAILABLE: firm pauses are switched off on this service.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Nothing could be paused or lifted (no Guard, no consent, offline, FIRM_PAUSE_NOT_RUNNING…), or an idempotency conflict.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteResponse"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED (60 calls a minute and key), or FIRM_PAUSE_RATE_LIMITED (30 pauses an hour per firm, one every 2 minutes per account).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/evidence-package": {
      "get": {
        "operationId": "evidence_package",
        "tags": [
          "Evidence"
        ],
        "summary": "The sealed case, each record with its proof in Bitcoin, signed by OX212 (Ed25519).",
        "security": [
          {
            "ox212Key": []
          },
          {
            "ox212Session": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "An account the caller can read (GET /api/v1/agent/accounts)."
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 365,
              "default": 30
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "download",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Records with content, salt (owner only), leaf, Merkle path, seal and OpenTimestamps proofs, plus an open verifier (a firm's key gets the firm's package instead: only what the trader shared and only while shared, each download recorded); the whole package with its SHA-256 and OX212's Ed25519 signature (signed: false and signature: null when no signing key is configured).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EvidencePackage"
                }
              }
            }
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The key's plan does not include the API (API_PLAN_REQUIRED: a personal key needs Elite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED: 60 calls per minute and key (see Retry-After).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PROOF_INCONSISTENT: never handed out.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/accounts": {
      "get": {
        "operationId": "list_accounts",
        "tags": [
          "Accounts"
        ],
        "summary": "The accounts this key can read.",
        "security": [
          {
            "ox212Key": []
          }
        ],
        "responses": {
          "200": {
            "description": "scope (personal | firm) and accounts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The key's plan does not include the API (API_PLAN_REQUIRED: a personal key needs Elite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED: 60 calls per minute and key (see Retry-After).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/accounts/{accountId}/now": {
      "get": {
        "operationId": "get_account_now",
        "tags": [
          "Accounts"
        ],
        "summary": "The account's risk state now: call it before a trade.",
        "security": [
          {
            "ox212Key": []
          }
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "light, state, can_open, pressure, reasons, cooldown_until, paused_until, paused_by, today, rules. While a pause holds the account (the trader's own, their firm's, an OX212 Guard pause, or their losses-in-a-row rule), can_open is false, state is blocked and reasons start with paused.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The key's plan does not include the API (API_PLAN_REQUIRED: a personal key needs Elite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED: 60 calls per minute and key (see Retry-After).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agent/accounts/{accountId}/summary": {
      "get": {
        "operationId": "get_account_summary",
        "tags": [
          "Accounts"
        ],
        "summary": "Behaviour over the last 1-90 days.",
        "security": [
          {
            "ox212Key": []
          }
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sessions, plan share, behaviours, pauses, brakes and pressure per session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The key's plan does not include the API (API_PLAN_REQUIRED: a personal key needs Elite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED: 60 calls per minute and key (see Retry-After).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/mcp": {
      "post": {
        "operationId": "mcp",
        "tags": [
          "MCP"
        ],
        "summary": "OX212's MCP server (Streamable HTTP, JSON answers, no sessions). Read only.",
        "description": "One JSON-RPC 2.0 message per POST (or a batch of up to 10): initialize, ping, tools/list, tools/call. Tools: list_accounts, get_account_now, get_account_summary, behavioral_risk, guardrails, session_brief, evidence_summary. The decisions (behavioral_risk, guardrails) carry an Attestation in their structuredContent, sealed within the hour. Add it with: claude mcp add --transport http ox212 https://app.ox212.com/api/mcp --header \"Authorization: Bearer ox212_sk_…\"",
        "security": [
          {
            "ox212Key": []
          }
        ],
        "x-mcp-tools": [
          {
            "name": "list_accounts",
            "title": "Accounts you can read",
            "description": "The trading accounts this connection can read, with their ids for the other tools. A person: their own accounts. A firm: the accounts its traders share with it (with who shares each one).",
            "inputSchema": {
              "type": "object",
              "properties": {},
              "additionalProperties": false
            }
          },
          {
            "name": "get_account_now",
            "title": "Risk state now",
            "description": "The account's risk state right now: light (green, amber, red), whether the trader's own plan allows opening a trade (can_open), pressure (pressure_ox212 is the figure the OX212 app shows, 0-212, where 212 means a limit was reached; pressure is the engine's 0-100 score), the reasons, today's trades and P&L, what is left before the trader's daily limits, any pause after a loss, and any pause holding the account (paused_until and paused_by: the trader's own, their firm's, an OX212 Guard pause for a broken rule, or their losses-in-a-row rule). While a pause runs, can_open is false and reasons start with paused. Call it before a trade.",
            "inputSchema": {
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string",
                  "description": "The account id, as list_accounts returns it.",
                  "format": "uuid"
                }
              },
              "required": [
                "account_id"
              ],
              "additionalProperties": false
            }
          },
          {
            "name": "get_account_summary",
            "title": "Behaviour over recent days",
            "description": "How the trader behaved over the last 1-90 days (30 by default): sessions, trades and P&L, the share of trades inside their own plan, the behaviours that repeat most, Guard pauses, what happened after OX's brakes, and pressure per session (pressure_ox212 as the app shows it, 0-212).",
            "inputSchema": {
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string",
                  "description": "The account id, as list_accounts returns it.",
                  "format": "uuid"
                },
                "days": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 90,
                  "default": 30
                }
              },
              "required": [
                "account_id"
              ],
              "additionalProperties": false
            }
          },
          {
            "name": "behavioral_risk",
            "title": "Behavioural risk",
            "description": "The account's behavioural risk from OX212's engine: the light and state now, whether the trader's plan allows opening, pressure (pressure_ox212 as the OX212 app shows it, 0-212; pressure, the engine's 0-100 score) and confidence, the reasons, and the last 1-90 days (7 by default): average and highest pressure per session, the behaviours that repeat most and the trades outside the plan.",
            "inputSchema": {
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string",
                  "description": "The account id, as list_accounts returns it.",
                  "format": "uuid"
                },
                "days": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 90,
                  "default": 7
                }
              },
              "required": [
                "account_id"
              ],
              "additionalProperties": false
            }
          },
          {
            "name": "guardrails",
            "title": "Active guardrails",
            "description": "The account's active guardrails: the limits the trader declared (daily loss, trades per day, pause after a loss, maximum size), what is left today, any pause or entry lock running now, and the OX212 Guard protection on each platform account (what the trader allows it to do). Read only: it never changes them.",
            "inputSchema": {
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string",
                  "description": "The account id, as list_accounts returns it.",
                  "format": "uuid"
                }
              },
              "required": [
                "account_id"
              ],
              "additionalProperties": false
            }
          },
          {
            "name": "session_brief",
            "title": "Session summary",
            "description": "One trading session as OX212's engine read it (the latest, or the one on date, YYYY-MM-DD within 90 days): trades, result and result within the plan, trades outside the plan, pressure, the behaviours detected and the verdict; and the state the next session starts in.",
            "inputSchema": {
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string",
                  "description": "The account id, as list_accounts returns it.",
                  "format": "uuid"
                },
                "date": {
                  "type": "string",
                  "format": "date"
                }
              },
              "required": [
                "account_id"
              ],
              "additionalProperties": false
            }
          },
          {
            "name": "evidence_summary",
            "title": "Evidence summary",
            "description": "What of the account's record is sealed (Guard receipts, engine sessions, forecasts, interventions and their outcomes) over the last 1-365 days (30 by default), the latest seal holding it and whether it is anchored in Bitcoin, the pauses and brakes OX212 applied, and how to download and verify the sealed case.",
            "inputSchema": {
              "type": "object",
              "properties": {
                "account_id": {
                  "type": "string",
                  "description": "The account id, as list_accounts returns it.",
                  "format": "uuid"
                },
                "days": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 365,
                  "default": 30
                }
              },
              "required": [
                "account_id"
              ],
              "additionalProperties": false
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The JSON-RPC answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "202": {
            "description": "A notification: no answer."
          },
          "401": {
            "description": "No valid key or session (API_KEY_INVALID, UNAUTHORIZED).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The key's plan does not include the API (API_PLAN_REQUIRED: a personal key needs Elite).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "ACCOUNT_NOT_FOUND: not readable by this caller (the same answer whether it exists or not).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "API_RATE_LIMITED: 60 calls per minute and key (see Retry-After).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; nothing was done.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/agentic/x402/risk-check": {
      "post": {
        "operationId": "x402_risk_check",
        "tags": [
          "Pay per call (x402)"
        ],
        "summary": "OX212 risk check: the engine's behavioural risk reading of the trades you send (no AI). Price: 0.01 USDC.",
        "description": "x402 «exact» on Base (USDC). Call without payment to get 402 with the requirements: the v1 body (`accepts`) and the v2 `PAYMENT-REQUIRED` header. Pay with `X-PAYMENT` (v1) or `PAYMENT-SIGNATURE` (v2) and call again with the same body. The payment is verified, the reading computed, and only then settled; the answer carries `X-PAYMENT-RESPONSE` / `PAYMENT-RESPONSE`. A retry of the same paid call returns the same answer without charging again. Nothing of the request is stored. 2000 trades at most; 60 calls per minute per IP.",
        "security": [
          {},
          {
            "x402Payment": []
          }
        ],
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v1 payment payload (base64 JSON)."
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v2 payment payload (base64 JSON)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/X402Request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The reading, paid and settled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Answer"
                }
              }
            },
            "headers": {
              "X-PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              },
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The trades or rules are not valid (TRADES_REQUIRED, TRADE_INVALID with its index, RULES_INVALID, TIMEZONE_INVALID…). Nothing is asked or charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Payment required: 0.01 USDC (10000 atomic units). Also when a payment does not match or is rejected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            },
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "x402 v2 requirements (base64 JSON)."
              }
            }
          },
          "409": {
            "description": "The payment pays for another call, was already used, is being processed or awaits reconciliation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "X402_RATE_LIMITED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "X402_SETTLEMENT_UNKNOWN: the facilitator did not confirm the settlement. Do not pay again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Pay-per-call is off or not configured (X402_DISABLED, X402_PAY_TO_MISSING…), or OX cannot write now. Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "x402_risk_check_preflight",
        "tags": [
          "Pay per call (x402)"
        ],
        "summary": "CORS preflight.",
        "responses": {
          "204": {
            "description": "Allowed."
          }
        }
      }
    },
    "/api/v1/agentic/x402/risk-explain": {
      "post": {
        "operationId": "x402_risk_explain",
        "tags": [
          "Pay per call (x402)"
        ],
        "summary": "OX212 risk check with a short explanation written by OX. Price: 0.05 USDC.",
        "description": "x402 «exact» on Base (USDC). Call without payment to get 402 with the requirements: the v1 body (`accepts`) and the v2 `PAYMENT-REQUIRED` header. Pay with `X-PAYMENT` (v1) or `PAYMENT-SIGNATURE` (v2) and call again with the same body. The payment is verified, the reading computed and written by OX, and only then settled; the answer carries `X-PAYMENT-RESPONSE` / `PAYMENT-RESPONSE`. A retry of the same paid call returns the same answer without charging again. Nothing of the request is stored. 2000 trades at most; 60 calls per minute per IP.",
        "security": [
          {},
          {
            "x402Payment": []
          }
        ],
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v1 payment payload (base64 JSON)."
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v2 payment payload (base64 JSON)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/X402Request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The reading, paid and settled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Answer"
                }
              }
            },
            "headers": {
              "X-PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              },
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The trades or rules are not valid (TRADES_REQUIRED, TRADE_INVALID with its index, RULES_INVALID, TIMEZONE_INVALID…). Nothing is asked or charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Payment required: 0.05 USDC (50000 atomic units). Also when a payment does not match or is rejected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            },
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "x402 v2 requirements (base64 JSON)."
              }
            }
          },
          "409": {
            "description": "The payment pays for another call, was already used, is being processed or awaits reconciliation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "X402_RATE_LIMITED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "X402_SETTLEMENT_UNKNOWN: the facilitator did not confirm the settlement. Do not pay again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Pay-per-call is off or not configured (X402_DISABLED, X402_PAY_TO_MISSING…), or OX cannot write now. Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "x402_risk_explain_preflight",
        "tags": [
          "Pay per call (x402)"
        ],
        "summary": "CORS preflight.",
        "responses": {
          "204": {
            "description": "Allowed."
          }
        }
      }
    },
    "/api/v1/agentic/x402/risk-analysis": {
      "post": {
        "operationId": "x402_risk_analysis",
        "tags": [
          "Pay per call (x402)"
        ],
        "summary": "OX212 risk check with an in-depth analysis written by OX. Price: 0.25 USDC.",
        "description": "x402 «exact» on Base (USDC). Call without payment to get 402 with the requirements: the v1 body (`accepts`) and the v2 `PAYMENT-REQUIRED` header. Pay with `X-PAYMENT` (v1) or `PAYMENT-SIGNATURE` (v2) and call again with the same body. The payment is verified, the reading computed and written by OX, and only then settled; the answer carries `X-PAYMENT-RESPONSE` / `PAYMENT-RESPONSE`. A retry of the same paid call returns the same answer without charging again. Nothing of the request is stored. 2000 trades at most; 60 calls per minute per IP.",
        "security": [
          {},
          {
            "x402Payment": []
          }
        ],
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v1 payment payload (base64 JSON)."
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v2 payment payload (base64 JSON)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/X402AnalysisRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The reading, paid and settled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/X402Answer"
                }
              }
            },
            "headers": {
              "X-PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              },
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The trades or rules are not valid (TRADES_REQUIRED, TRADE_INVALID with its index, RULES_INVALID, TIMEZONE_INVALID…). Nothing is asked or charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Payment required: 0.25 USDC (250000 atomic units). Also when a payment does not match or is rejected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            },
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                },
                "description": "x402 v2 requirements (base64 JSON)."
              }
            }
          },
          "409": {
            "description": "The payment pays for another call, was already used, is being processed or awaits reconciliation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "X402_RATE_LIMITED.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "X402_SETTLEMENT_UNKNOWN: the facilitator did not confirm the settlement. Do not pay again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Pay-per-call is off or not configured (X402_DISABLED, X402_PAY_TO_MISSING…), or OX cannot write now. Nothing was charged.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "x402_risk_analysis_preflight",
        "tags": [
          "Pay per call (x402)"
        ],
        "summary": "CORS preflight.",
        "responses": {
          "204": {
            "description": "Allowed."
          }
        }
      }
    },
    "/api/v1/agentic/x402/readiness": {
      "get": {
        "operationId": "x402_readiness",
        "tags": [
          "Pay per call (x402)"
        ],
        "summary": "Whether pay-per-call is on and what is configured (never a secret).",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "ready, network, asset, prices.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/decision/{id}/proof": {
      "get": {
        "operationId": "decision_proof",
        "tags": [
          "Evidence"
        ],
        "summary": "The proof of one decision: its sealed record, Merkle path, hourly seal and Bitcoin proofs. Public.",
        "description": "The id is attestation.record.id of a decision answer. Status recorded (it joins the next hourly seal), waiting_next_seal, then sealed. answer_sha256 = sha256(canonical JSON of the answer as received, without «attestation»; on x402 calls also without «payment»; on MCP, the tool's structuredContent without «attestation»). It equals attestation.hash; attestation.signature is OX212's Ed25519 signature over that same canonical text. 60 calls per 10 minutes per IP.",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The proof, checked before it is handed out.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DecisionProof"
                }
              }
            }
          },
          "404": {
            "description": "NOT_FOUND: no such decision (or a test account's, never recorded).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "TOO_MANY_REQUESTS.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "PROOF_INCONSISTENT: never handed out.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "PROOF_UNAVAILABLE.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/evidence-key": {
      "get": {
        "operationId": "evidence_key",
        "tags": [
          "Evidence"
        ],
        "summary": "OX212's public Ed25519 key that signs evidence packages and decision answers (JWK, PEM, key id). Public.",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "The key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EvidenceKey"
                }
              }
            }
          },
          "404": {
            "description": "EVIDENCE_KEY_NOT_CONFIGURED: nothing is signed (signed: false).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/seal": {
      "get": {
        "operationId": "seal_registry",
        "tags": [
          "Evidence"
        ],
        "summary": "Every hourly seal: root, chain, manifest and OpenTimestamps proofs. Public.",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "The registry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/seal/{id}": {
      "get": {
        "operationId": "seal_manifest",
        "tags": [
          "Evidence"
        ],
        "summary": "A seal's manifest (the document anchored in Bitcoin).",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The manifest, byte for byte.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/seal/{id}/ots": {
      "get": {
        "operationId": "seal_ots",
        "tags": [
          "Evidence"
        ],
        "summary": "A seal's OpenTimestamps proof (.ots).",
        "security": [
          {}
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "n",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 9
            }
          }
        ],
        "responses": {
          "200": {
            "description": "application/octet-stream"
          }
        }
      }
    },
    "/api/v1/openapi": {
      "get": {
        "operationId": "openapi",
        "tags": [
          "Evidence"
        ],
        "summary": "This document.",
        "security": [
          {}
        ],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ox212Key": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ox212_sk_… (a person, Elite) or ox212_fk_… (a firm)",
        "description": "Read-only keys from Settings › API or the firm's panel. 60 calls per minute per key."
      },
      "ox212Session": {
        "type": "apiKey",
        "in": "cookie",
        "name": "ox212_access_token",
        "description": "The trader's own signed-in session (the app)."
      },
      "x402Payment": {
        "type": "apiKey",
        "in": "header",
        "name": "X-PAYMENT",
        "description": "x402 payment (v1 X-PAYMENT or v2 PAYMENT-SIGNATURE), scheme «exact», USDC on Base, valid for at most 60 s of processing."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "IntendedAction": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "OPEN_TRADE",
              "SCALE_IN",
              "CLOSE_TRADE",
              "HOLD"
            ]
          },
          "size_multiplier": {
            "type": "number",
            "minimum": 0
          },
          "instrument": {
            "type": "string"
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          }
        }
      },
      "RiskCheckRequest": {
        "type": "object",
        "required": [
          "account_id"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "format": "uuid"
          },
          "context_window": {
            "type": "string",
            "enum": [
              "session",
              "day",
              "week"
            ],
            "default": "session"
          },
          "intended_action": {
            "$ref": "#/components/schemas/IntendedAction"
          }
        }
      },
      "Decision": {
        "type": "object",
        "description": "The engine state now, said as what to do. HARD: the trader's own plan forbids opening now, or a pause holds the account (reason PAUSED, guardrails.paused_until); SOFT: OX212's advice.",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "ok",
              "warning",
              "critical",
              "blocked"
            ]
          },
          "light": {
            "type": "string",
            "enum": [
              "green",
              "amber",
              "red"
            ]
          },
          "can_open": {
            "type": "boolean"
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ]
          },
          "pressure": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "reason_codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "decision": {
            "type": "object",
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "ALLOW",
                  "REDUCE_SIZE",
                  "COOLDOWN",
                  "STOP_TRADING"
                ]
              },
              "enforcement": {
                "type": "string",
                "enum": [
                  "NONE",
                  "SOFT",
                  "HARD"
                ]
              },
              "ttl_minutes": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "guardrails": {
            "type": "object",
            "properties": {
              "max_size_multiplier": {
                "type": "number"
              },
              "max_trades_remaining": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "max_loss_remaining": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "cooldown_after_loss_min": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "cooldown_until": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "paused_until": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Signature": {
        "type": "object",
        "required": [
          "alg",
          "kid",
          "value"
        ],
        "description": "OX212's Ed25519 signature (GET /api/public/evidence-key).",
        "properties": {
          "alg": {
            "const": "Ed25519"
          },
          "kid": {
            "type": "string",
            "description": "RFC 7638 thumbprint of the signing key."
          },
          "value": {
            "type": "string",
            "description": "base64url (no padding) of the 64-byte signature."
          }
        }
      },
      "Attestation": {
        "type": "object",
        "required": [
          "attestable",
          "hash",
          "record",
          "signed",
          "signature"
        ],
        "description": "Every decision answer's attestation. answer_sha256 = sha256(canonical JSON of the answer as received, without «attestation»; on x402 calls also without «payment»; on MCP, the tool's structuredContent without «attestation»). It equals attestation.hash; attestation.signature is OX212's Ed25519 signature over that same canonical text. canonical JSON = RFC 8785 (JCS): members sorted by key in UTF-16 code units, no whitespace, strings and numbers as JavaScript JSON.stringify writes them.",
        "properties": {
          "attestable": {
            "type": "boolean"
          },
          "hash": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "sha256 of the answer's canonical JSON (the answer without attestation; on x402 also without payment)."
          },
          "record": {
            "type": "object",
            "description": "The decision's record: recorded answers are sealed within the hour (the next hourly seal, anchored in Bitcoin). test_account: test accounts are never sealed. not_recorded: the record could not be written in time (the answer still stands).",
            "properties": {
              "id": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "status": {
                "type": "string",
                "enum": [
                  "recorded",
                  "test_account",
                  "not_recorded"
                ]
              },
              "sealed": {
                "oneOf": [
                  {
                    "const": "within the hour"
                  },
                  {
                    "const": false
                  }
                ]
              },
              "proof": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri",
                "description": "GET /api/public/decision/{id}/proof."
              }
            }
          },
          "signed": {
            "type": "boolean"
          },
          "signature": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Signature"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "RiskCheckResponse": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Decision"
          },
          {
            "type": "object",
            "properties": {
              "request_id": {
                "type": "string"
              },
              "account_id": {
                "type": "string",
                "format": "uuid"
              },
              "as_of": {
                "type": "string",
                "format": "date-time"
              },
              "engine": {
                "type": "string"
              },
              "today": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "evidence": {
                "type": "object",
                "properties": {
                  "records": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "source": {
                          "type": "string"
                        },
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "package_url": {
                    "type": "string"
                  }
                }
              },
              "attestation": {
                "$ref": "#/components/schemas/Attestation"
              }
            }
          }
        ]
      },
      "Guardrails": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "limits": {
            "type": "object"
          },
          "today": {
            "type": "object"
          },
          "now": {
            "type": "object"
          },
          "decision": {
            "$ref": "#/components/schemas/Decision"
          },
          "protection": {
            "type": "object",
            "properties": {
              "guard_connected": {
                "type": "boolean"
              },
              "platform_accounts": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          },
          "attestation": {
            "$ref": "#/components/schemas/Attestation"
          }
        }
      },
      "ExecuteRequest": {
        "type": "object",
        "required": [
          "account_id",
          "action"
        ],
        "properties": {
          "account_id": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string",
            "enum": [
              "STOP_TRADING",
              "COOLDOWN",
              "UNLOCK"
            ],
            "description": "Both cancel orders and close positions; COOLDOWN also blocks entries for the trader's pause after a loss (or lock_minutes). UNLOCK: a firm key only, lifts that firm's own pause before its end."
          },
          "lock_minutes": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1440
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "A firm key only, required: why the firm pauses the account. The trader is told it."
          },
          "lock": {
            "type": "string",
            "enum": [
              "end_of_day"
            ],
            "description": "A firm key only: block entries until the end of the trader's day (at most 24 h)."
          }
        }
      },
      "ExecuteResponse": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "lock_minutes": {
            "type": "integer"
          },
          "applied": {
            "type": "boolean"
          },
          "paused": {
            "type": "integer"
          },
          "lifted": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "platform": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "account": {
                  "type": "string"
                },
                "outcome": {
                  "type": "string",
                  "enum": [
                    "paused",
                    "plan",
                    "no_consent",
                    "offline",
                    "live_not_allowed",
                    "already_open",
                    "firm_rules",
                    "failed",
                    "lifted",
                    "other_lock",
                    "not_running"
                  ]
                }
              }
            }
          },
          "attestation": {
            "$ref": "#/components/schemas/Attestation"
          }
        }
      },
      "EvidencePackage": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "package": {
            "type": "object",
            "description": "signature = Ed25519 over the UTF-8 bytes of the canonical JSON of the package without package_sha256, signed and signature (whose SHA-256 is package_sha256); value in base64url; public key at /api/public/evidence-key (kid = RFC 7638 thumbprint)",
            "properties": {
              "format": {
                "enum": [
                  "ox212-evidence-package/1",
                  "ox212-firm-evidence/1"
                ],
                "description": "ox212-firm-evidence/1 for a firm's key: only what the trader shared, while it was shared (each download recorded)."
              },
              "records": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "seals": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "rules": {
                "type": "object"
              },
              "signing_key": {
                "type": "string",
                "format": "uri"
              },
              "how_to_verify": {
                "type": "string"
              },
              "verifier": {
                "type": "object",
                "description": "Open JavaScript: verify(record, seal) and verifyPackage(pkg, jwk)."
              },
              "package_sha256": {
                "type": "string",
                "description": "sha256 of the canonical JSON of the package without package_sha256, signed and signature."
              },
              "signed": {
                "type": "boolean"
              },
              "signature": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/Signature"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        }
      },
      "DecisionProof": {
        "type": "object",
        "properties": {
          "format": {
            "const": "ox212-decision-proof/1"
          },
          "record_id": {
            "type": "string",
            "format": "uuid"
          },
          "route": {
            "type": "string"
          },
          "decided_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string",
            "enum": [
              "recorded",
              "waiting_next_seal",
              "sealed"
            ]
          },
          "note": {
            "type": "string"
          },
          "record": {
            "type": [
              "object",
              "null"
            ],
            "description": "The sealed text (format ox212-agentic-decision/1: id, route, decided_at, answer_sha256, refs, principal_sha256), its salt and leaf.",
            "properties": {
              "source": {
                "const": "agentic_decision"
              },
              "content": {
                "type": "string"
              },
              "salt": {
                "type": "string"
              },
              "leaf": {
                "type": "string"
              }
            }
          },
          "path": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object",
              "properties": {
                "side": {
                  "type": "string",
                  "enum": [
                    "left",
                    "right"
                  ]
                },
                "hash": {
                  "type": "string"
                }
              }
            }
          },
          "seal": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "id": {
                "type": "integer"
              },
              "sealed_at": {
                "type": "string"
              },
              "root": {
                "type": "string"
              },
              "prev_chain": {
                "type": "string"
              },
              "chain": {
                "type": "string"
              },
              "manifest": {
                "type": "string"
              },
              "proofs": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          },
          "rules": {
            "type": "object"
          },
          "signing_key": {
            "type": "string",
            "format": "uri"
          },
          "how_to_verify": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "EvidenceKey": {
        "type": "object",
        "properties": {
          "format": {
            "const": "ox212-evidence-key/1"
          },
          "alg": {
            "const": "Ed25519"
          },
          "kid": {
            "type": "string"
          },
          "pem": {
            "type": "string"
          },
          "jwk": {
            "type": "object",
            "properties": {
              "kty": {
                "const": "OKP"
              },
              "crv": {
                "const": "Ed25519"
              },
              "x": {
                "type": "string"
              },
              "kid": {
                "type": "string"
              },
              "alg": {
                "const": "EdDSA"
              },
              "use": {
                "const": "sig"
              }
            }
          },
          "keys": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "The same JWK, as a JWKS."
          },
          "signs": {
            "type": "object"
          },
          "canonical_json": {
            "type": "string"
          },
          "encoding": {
            "type": "string"
          }
        }
      },
      "Trade": {
        "type": "object",
        "required": [
          "pnl"
        ],
        "additionalProperties": false,
        "properties": {
          "pnl": {
            "type": "number",
            "description": "Net result of the closed trade, in the account currency."
          },
          "closed_at": {
            "type": "string",
            "format": "date-time",
            "description": "Close time (or opened_at when there is none)."
          },
          "opened_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lots": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "description": "Size (contracts or lots)."
          },
          "symbol": {
            "type": [
              "string",
              "null"
            ]
          },
          "side": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "buy",
              "sell",
              null
            ]
          }
        }
      },
      "X402Request": {
        "type": "object",
        "required": [
          "trades"
        ],
        "properties": {
          "trades": {
            "type": "array",
            "minItems": 1,
            "maxItems": 2000,
            "items": {
              "$ref": "#/components/schemas/Trade"
            }
          },
          "rules": {
            "type": "object",
            "properties": {
              "max_daily_loss": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "max_trades_per_day": {
                "type": "integer",
                "minimum": 1
              },
              "cooldown_after_loss_min": {
                "type": "integer",
                "minimum": 0
              },
              "max_lots": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "base_size": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Normal size, contracts or lots: after a losing trade, the next one above it is out of plan."
              },
              "max_consecutive_losses": {
                "type": "integer",
                "minimum": 2,
                "maximum": 10,
                "description": "Losses in a row allowed: a trade opened, the same day, inside the pause after that many losses in a row is out of plan."
              },
              "consecutive_loss_pause_min": {
                "type": "integer",
                "minimum": 5,
                "maximum": 240,
                "default": 30,
                "description": "Minutes of that pause."
              },
              "timezone": {
                "type": "string",
                "default": "UTC",
                "description": "IANA zone of the trading day."
              }
            }
          },
          "intended_action": {
            "$ref": "#/components/schemas/IntendedAction"
          },
          "as_of": {
            "type": "string",
            "format": "date-time"
          },
          "locale": {
            "type": "string",
            "enum": [
              "en",
              "es"
            ],
            "default": "en"
          }
        }
      },
      "X402AnalysisRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/X402Request"
          },
          {
            "type": "object",
            "properties": {
              "question": {
                "type": "string",
                "maxLength": 300,
                "description": "Optional focus for the analysis."
              }
            }
          }
        ]
      },
      "X402Answer": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Decision"
          },
          {
            "type": "object",
            "properties": {
              "request_id": {
                "type": "string"
              },
              "call": {
                "type": "string"
              },
              "engine": {
                "type": "string"
              },
              "sessions": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "explanation": {
                "type": "object",
                "properties": {
                  "by": {
                    "const": "OX"
                  },
                  "model": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "points": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "actions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "attestation": {
                "$ref": "#/components/schemas/Attestation"
              },
              "payment": {
                "type": "object",
                "properties": {
                  "network": {
                    "type": "string"
                  },
                  "asset": {
                    "const": "USDC"
                  },
                  "amount_usdc": {
                    "type": "string"
                  },
                  "transaction": {
                    "type": "string"
                  },
                  "payer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        ]
      },
      "PaymentRequired": {
        "type": "object",
        "description": "x402 v1 (the v2 version is in the PAYMENT-REQUIRED header).",
        "properties": {
          "x402Version": {
            "const": 1
          },
          "error": {
            "type": "string"
          },
          "accepts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "scheme": {
                  "const": "exact"
                },
                "network": {
                  "type": "string",
                  "enum": [
                    "base-sepolia",
                    "base"
                  ]
                },
                "maxAmountRequired": {
                  "type": "string"
                },
                "resource": {
                  "type": "string"
                },
                "payTo": {
                  "type": "string"
                },
                "asset": {
                  "type": "string"
                },
                "maxTimeoutSeconds": {
                  "type": "integer"
                },
                "extra": {
                  "type": "object"
                }
              }
            }
          },
          "ox212": {
            "type": "object"
          }
        }
      }
    }
  }
}