{
  "openapi": "3.1.0",
  "info": {
    "title": "ParlayMarket Agent API",
    "version": "1.0.0",
    "description": "US market discovery, paper basket planning, owner approval, and durable workflows. Live trading is unavailable."
  },
  "servers": [
    {
      "url": "https://parlaymarket.io"
    }
  ],
  "paths": {
    "/api/v1/tools/get_capabilities": {
      "post": {
        "operationId": "get_capabilities",
        "summary": "Discover implemented capabilities, prerequisites, and operating limits.",
        "security": [],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {},
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/search_markets": {
      "post": {
        "operationId": "search_markets",
        "summary": "Browse one page of a native US venue catalog; query filters that page. Follow next_cursor to continue.",
        "security": [],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "venue": {
                    "enum": [
                      "polymarket-us",
                      "kalshi"
                    ]
                  },
                  "query": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "cursor": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "$ref": "#/components/schemas/MarketPage"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/get_market": {
      "post": {
        "operationId": "get_market",
        "summary": "Read native instrument identity, outcome labels, resolution terms and source.",
        "security": [],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "venue": {
                    "enum": [
                      "polymarket-us",
                      "kalshi"
                    ]
                  },
                  "instrument_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "outcome_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  }
                },
                "required": [
                  "venue",
                  "instrument_id",
                  "outcome_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "$ref": "#/components/schemas/MarketRecord"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/get_orderbook": {
      "post": {
        "operationId": "get_orderbook",
        "summary": "Read observed outcome ask depth. Missing data is never synthesized.",
        "security": [],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "venue": {
                    "enum": [
                      "polymarket-us",
                      "kalshi"
                    ]
                  },
                  "instrument_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "outcome_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  }
                },
                "required": [
                  "venue",
                  "instrument_id",
                  "outcome_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "$ref": "#/components/schemas/OrderBook"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/create_plan": {
      "post": {
        "operationId": "create_plan",
        "summary": "Persist an immutable basket proposal. This does not grant authority or submit orders.",
        "security": [
          {
            "OAuth": [
              "plans:write"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "orders": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "market": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "venue": {
                              "enum": [
                                "polymarket-us",
                                "kalshi"
                              ]
                            },
                            "instrument_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                            },
                            "outcome_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                            }
                          },
                          "required": [
                            "venue",
                            "instrument_id",
                            "outcome_id"
                          ]
                        },
                        "account_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                        },
                        "quantity_micro": {
                          "type": "string",
                          "pattern": "^(0|[1-9][0-9]{0,14})$"
                        },
                        "limit_price_micro": {
                          "type": "string",
                          "pattern": "^(0|[1-9][0-9]{0,14})$"
                        },
                        "currency": {
                          "enum": [
                            "USD",
                            "USDC"
                          ]
                        },
                        "expires_at": {
                          "type": "string",
                          "minLength": 20,
                          "maxLength": 30
                        },
                        "time_in_force": {
                          "enum": [
                            "IOC",
                            "GTC"
                          ]
                        }
                      },
                      "required": [
                        "market",
                        "account_id",
                        "quantity_micro",
                        "limit_price_micro",
                        "currency",
                        "expires_at",
                        "time_in_force"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 20
                  },
                  "mode": {
                    "enum": [
                      "paper",
                      "live"
                    ]
                  },
                  "expires_at": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 30
                  },
                  "max_fee_micro": {
                    "type": "string",
                    "pattern": "^(0|[1-9][0-9]{0,14})$"
                  },
                  "max_total_cost_micro": {
                    "type": "string",
                    "pattern": "^(0|[1-9][0-9]{0,14})$"
                  },
                  "max_quote_age_ms": {
                    "type": "integer",
                    "minimum": 1000,
                    "maximum": 60000
                  }
                },
                "required": [
                  "orders",
                  "mode",
                  "expires_at",
                  "max_fee_micro"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/simulate_plan": {
      "post": {
        "operationId": "simulate_plan",
        "summary": "Estimate immediate fills and costs from current displayed depth. Paper results are not venue fills.",
        "security": [],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "plan_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "plan": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "orders": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "properties": {
                            "market": {
                              "type": "object",
                              "additionalProperties": false,
                              "properties": {
                                "venue": {
                                  "enum": [
                                    "polymarket-us",
                                    "kalshi"
                                  ]
                                },
                                "instrument_id": {
                                  "type": "string",
                                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                                },
                                "outcome_id": {
                                  "type": "string",
                                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                                }
                              },
                              "required": [
                                "venue",
                                "instrument_id",
                                "outcome_id"
                              ]
                            },
                            "account_id": {
                              "type": "string",
                              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                            },
                            "quantity_micro": {
                              "type": "string",
                              "pattern": "^(0|[1-9][0-9]{0,14})$"
                            },
                            "limit_price_micro": {
                              "type": "string",
                              "pattern": "^(0|[1-9][0-9]{0,14})$"
                            },
                            "currency": {
                              "enum": [
                                "USD",
                                "USDC"
                              ]
                            },
                            "expires_at": {
                              "type": "string",
                              "minLength": 20,
                              "maxLength": 30
                            },
                            "time_in_force": {
                              "enum": [
                                "IOC",
                                "GTC"
                              ]
                            }
                          },
                          "required": [
                            "market",
                            "account_id",
                            "quantity_micro",
                            "limit_price_micro",
                            "currency",
                            "expires_at",
                            "time_in_force"
                          ]
                        },
                        "minItems": 1,
                        "maxItems": 20
                      },
                      "mode": {
                        "enum": [
                          "paper",
                          "live"
                        ]
                      },
                      "expires_at": {
                        "type": "string",
                        "minLength": 20,
                        "maxLength": 30
                      },
                      "max_fee_micro": {
                        "type": "string",
                        "pattern": "^(0|[1-9][0-9]{0,14})$"
                      },
                      "max_total_cost_micro": {
                        "type": "string",
                        "pattern": "^(0|[1-9][0-9]{0,14})$"
                      },
                      "max_quote_age_ms": {
                        "type": "integer",
                        "minimum": 1000,
                        "maximum": 60000
                      }
                    },
                    "required": [
                      "orders",
                      "mode",
                      "expires_at",
                      "max_fee_micro"
                    ]
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "$ref": "#/components/schemas/PaperSimulation"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/compare_routes": {
      "post": {
        "operationId": "compare_routes",
        "summary": "Compare supplied market records and books; unverified mappings cannot authorize routing.",
        "security": [],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "markets": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "venue": {
                          "enum": [
                            "polymarket-us",
                            "kalshi"
                          ]
                        },
                        "instrument_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                        },
                        "outcome_id": {
                          "type": "string",
                          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                        }
                      },
                      "required": [
                        "venue",
                        "instrument_id",
                        "outcome_id"
                      ]
                    },
                    "minItems": 2,
                    "maxItems": 5
                  }
                },
                "required": [
                  "markets"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/request_approval": {
      "post": {
        "operationId": "request_approval",
        "summary": "Request owner review of an exact plan and return a trusted approval URL. Cannot approve itself.",
        "security": [
          {
            "OAuth": [
              "plans:write"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "plan_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  }
                },
                "required": [
                  "plan_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/get_authorization_status": {
      "post": {
        "operationId": "get_authorization_status",
        "summary": "Read whether an approval is pending, approved, expired, or rejected.",
        "security": [
          {
            "OAuth": [
              "history:read"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "approval_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  }
                },
                "required": [
                  "approval_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/create_workflow": {
      "post": {
        "operationId": "create_workflow",
        "summary": "Create a bounded workflow linked to a plan and one owner approval or mandate.",
        "security": [
          {
            "OAuth": [
              "workflows:write"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "plan_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "approval_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "grant_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "trigger": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "enum": [
                          "immediate",
                          "time",
                          "price_below",
                          "market_resolved"
                        ]
                      },
                      "at": {
                        "type": "string",
                        "minLength": 20,
                        "maxLength": 30
                      },
                      "market": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "venue": {
                            "enum": [
                              "polymarket-us",
                              "kalshi"
                            ]
                          },
                          "instrument_id": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                          },
                          "outcome_id": {
                            "type": "string",
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                          }
                        },
                        "required": [
                          "venue",
                          "instrument_id",
                          "outcome_id"
                        ]
                      },
                      "price_micro": {
                        "type": "string",
                        "pattern": "^(0|[1-9][0-9]{0,14})$"
                      },
                      "outcome_id": {
                        "type": "string",
                        "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                      }
                    },
                    "required": [
                      "type"
                    ]
                  }
                },
                "required": [
                  "plan_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/start_workflow": {
      "post": {
        "operationId": "start_workflow",
        "summary": "Reserve owner budget and start an authorized workflow. Live execution requires an approved integration.",
        "security": [
          {
            "OAuth": [
              "workflows:write"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "workflow_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "workflow_id",
                  "version"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/pause_workflow": {
      "post": {
        "operationId": "pause_workflow",
        "summary": "Stop future workflow steps. Existing fills remain positions.",
        "security": [
          {
            "OAuth": [
              "workflows:write"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "workflow_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "workflow_id",
                  "version"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/cancel_workflow": {
      "post": {
        "operationId": "cancel_workflow",
        "summary": "Cancel future workflow activity. Already filled positions are not liquidated.",
        "security": [
          {
            "OAuth": [
              "workflows:write"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "workflow_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "workflow_id",
                  "version"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/get_workflow": {
      "post": {
        "operationId": "get_workflow",
        "summary": "Read authoritative workflow state and clearly labeled paper results.",
        "security": [
          {
            "OAuth": [
              "history:read"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "workflow_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  }
                },
                "required": [
                  "workflow_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/get_positions": {
      "post": {
        "operationId": "get_positions",
        "summary": "Read simulated positions. Live account positions remain unavailable until account integration.",
        "security": [
          {
            "OAuth": [
              "history:read"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {},
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/list_events": {
      "post": {
        "operationId": "list_events",
        "summary": "Read durable owner events after a sequence cursor; events may be replayed.",
        "security": [
          {
            "OAuth": [
              "history:read"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "cursor": {
                    "type": "string",
                    "maxLength": 1000
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tools/subscribe_events": {
      "post": {
        "operationId": "subscribe_events",
        "summary": "Register signed event delivery to an approved HTTPS destination. Secret is returned once.",
        "security": [
          {
            "OAuth": [
              "events:write"
            ]
          },
          {
            "WalletSession": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "url": {
                    "type": "string",
                    "maxLength": 2048
                  },
                  "types": {
                    "type": "array",
                    "items": {
                      "enum": [
                        "plan.created",
                        "approval.required",
                        "approval.decided",
                        "workflow.started",
                        "workflow.paused",
                        "workflow.paper_result",
                        "workflow.cancel_requested",
                        "order.updated",
                        "market.resolved",
                        "quote.changed",
                        "subscription.failed"
                      ]
                    },
                    "minItems": 1,
                    "maxItems": 20,
                    "uniqueItems": true
                  }
                },
                "required": [
                  "url",
                  "types"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured result; paper outcomes never establish live fills.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "request_id",
                    "result"
                  ],
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "result": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, budget, native constraints, or stale plan",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Structured error",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Dependency unavailable; preserve intent and honor retry timing",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "description": "Seconds to wait before a new attempt. No automatic mutation retries.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "MarketRef": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "venue": {
            "enum": [
              "polymarket-us",
              "kalshi"
            ]
          },
          "instrument_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          },
          "outcome_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          }
        },
        "required": [
          "venue",
          "instrument_id",
          "outcome_id"
        ]
      },
      "OrderSpec": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "market": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "venue": {
                "enum": [
                  "polymarket-us",
                  "kalshi"
                ]
              },
              "instrument_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              },
              "outcome_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              }
            },
            "required": [
              "venue",
              "instrument_id",
              "outcome_id"
            ]
          },
          "account_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          },
          "quantity_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,14})$"
          },
          "limit_price_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,14})$"
          },
          "currency": {
            "enum": [
              "USD",
              "USDC"
            ]
          },
          "expires_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "time_in_force": {
            "enum": [
              "IOC",
              "GTC"
            ]
          }
        },
        "required": [
          "market",
          "account_id",
          "quantity_micro",
          "limit_price_micro",
          "currency",
          "expires_at",
          "time_in_force"
        ]
      },
      "PlanInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "orders": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "market": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "venue": {
                      "enum": [
                        "polymarket-us",
                        "kalshi"
                      ]
                    },
                    "instrument_id": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                    },
                    "outcome_id": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                    }
                  },
                  "required": [
                    "venue",
                    "instrument_id",
                    "outcome_id"
                  ]
                },
                "account_id": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                },
                "quantity_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]{0,14})$"
                },
                "limit_price_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]{0,14})$"
                },
                "currency": {
                  "enum": [
                    "USD",
                    "USDC"
                  ]
                },
                "expires_at": {
                  "type": "string",
                  "minLength": 20,
                  "maxLength": 30
                },
                "time_in_force": {
                  "enum": [
                    "IOC",
                    "GTC"
                  ]
                }
              },
              "required": [
                "market",
                "account_id",
                "quantity_micro",
                "limit_price_micro",
                "currency",
                "expires_at",
                "time_in_force"
              ]
            },
            "minItems": 1,
            "maxItems": 20
          },
          "mode": {
            "enum": [
              "paper",
              "live"
            ]
          },
          "expires_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "max_fee_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,14})$"
          },
          "max_total_cost_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,14})$"
          },
          "max_quote_age_ms": {
            "type": "integer",
            "minimum": 1000,
            "maximum": 60000
          }
        },
        "required": [
          "orders",
          "mode",
          "expires_at",
          "max_fee_micro"
        ]
      },
      "ExecutionIntent": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "version": {
            "const": "parlaymarket-execution-intent-v1"
          },
          "plan_hash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          },
          "owner": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "authority": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "kind": {
                "enum": [
                  "approval",
                  "grant"
                ]
              },
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              }
            },
            "required": [
              "kind",
              "id"
            ]
          },
          "expires_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "nonce": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          },
          "intent_hash": {
            "type": "string",
            "pattern": "^0x[0-9a-f]{64}$"
          }
        },
        "required": [
          "version",
          "plan_hash",
          "owner",
          "authority",
          "expires_at",
          "nonce",
          "intent_hash"
        ]
      },
      "WorkflowInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "plan_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          },
          "approval_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          },
          "grant_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          },
          "trigger": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "type": {
                "enum": [
                  "immediate",
                  "time",
                  "price_below",
                  "market_resolved"
                ]
              },
              "at": {
                "type": "string",
                "minLength": 20,
                "maxLength": 30
              },
              "market": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "venue": {
                    "enum": [
                      "polymarket-us",
                      "kalshi"
                    ]
                  },
                  "instrument_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  },
                  "outcome_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                  }
                },
                "required": [
                  "venue",
                  "instrument_id",
                  "outcome_id"
                ]
              },
              "price_micro": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,14})$"
              },
              "outcome_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              }
            },
            "required": [
              "type"
            ]
          }
        },
        "required": [
          "plan_id"
        ]
      },
      "WorkflowEvent": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "event_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          },
          "sequence": {
            "type": "integer",
            "minimum": 1
          },
          "type": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "owner": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "occurred_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "event_id",
          "sequence",
          "type",
          "owner",
          "occurred_at",
          "data"
        ]
      },
      "GrantInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "client_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "mode": {
            "enum": [
              "paper",
              "live"
            ]
          },
          "account_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
            },
            "minItems": 1,
            "maxItems": 20,
            "uniqueItems": true
          },
          "instruments": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "venue": {
                  "enum": [
                    "polymarket-us",
                    "kalshi"
                  ]
                },
                "instrument_id": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                },
                "outcome_id": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
                }
              },
              "required": [
                "venue",
                "instrument_id",
                "outcome_id"
              ]
            },
            "minItems": 1,
            "maxItems": 100
          },
          "max_total_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,14})$"
          },
          "max_order_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,14})$"
          },
          "currency": {
            "enum": [
              "USD",
              "USDC"
            ]
          },
          "expires_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          }
        },
        "required": [
          "client_id",
          "mode",
          "account_ids",
          "instruments",
          "max_total_micro",
          "max_order_micro",
          "currency",
          "expires_at"
        ]
      },
      "Trigger": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "type": {
            "enum": [
              "immediate",
              "time",
              "price_below",
              "market_resolved"
            ]
          },
          "at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "market": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "venue": {
                "enum": [
                  "polymarket-us",
                  "kalshi"
                ]
              },
              "instrument_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              },
              "outcome_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              }
            },
            "required": [
              "venue",
              "instrument_id",
              "outcome_id"
            ]
          },
          "price_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]{0,14})$"
          },
          "outcome_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
          }
        },
        "required": [
          "type"
        ]
      },
      "Provenance": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "url": {
            "type": "string"
          },
          "observed_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "source_kind": {
            "const": "venue_public_api"
          }
        },
        "required": [
          "url",
          "observed_at",
          "source_kind"
        ]
      },
      "NativeConstraints": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "status": {
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "minimum_quantity_micro": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]*)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "quantity_increment_micro": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]*)$"
              },
              {
                "type": "null"
              }
            ]
          },
          "price_ranges": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "start_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]*)$"
                },
                "end_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]*)$"
                },
                "tick_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]*)$"
                }
              },
              "required": [
                "start_micro",
                "end_micro",
                "tick_micro"
              ]
            }
          },
          "quantity_source": {
            "type": "string"
          },
          "price_source": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "minimum_quantity_micro",
          "quantity_increment_micro",
          "price_ranges",
          "quantity_source",
          "price_source"
        ]
      },
      "MarketRecord": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "venue": {
            "enum": [
              "polymarket-us",
              "kalshi"
            ]
          },
          "instrument_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "outcomes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "outcome_id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                }
              },
              "required": [
                "outcome_id",
                "label"
              ]
            }
          },
          "status": {
            "enum": [
              "open",
              "closed"
            ]
          },
          "currency": {
            "const": "USD"
          },
          "resolution_terms": {
            "type": "string"
          },
          "resolution_terms_hash": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "constraints": {
            "$ref": "#/components/schemas/NativeConstraints"
          },
          "provenance": {
            "$ref": "#/components/schemas/Provenance"
          },
          "instrument_kind": {
            "enum": [
              "single",
              "venue_combo"
            ]
          },
          "link": {
            "type": "string"
          }
        },
        "required": [
          "venue",
          "instrument_id",
          "title",
          "outcomes",
          "status",
          "currency",
          "resolution_terms",
          "resolution_terms_hash",
          "expires_at",
          "constraints",
          "provenance",
          "instrument_kind",
          "link"
        ]
      },
      "MarketPage": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "markets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketRecord"
            }
          },
          "cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "scanned_count": {
            "type": "integer"
          },
          "search_scope": {
            "const": "current_venue_page"
          },
          "observed_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "synthetic": {
            "const": false
          }
        },
        "required": [
          "markets",
          "cursor",
          "next_cursor",
          "scanned_count",
          "search_scope",
          "observed_at",
          "synthetic"
        ]
      },
      "DepthLevel": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "price_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "quantity_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          }
        },
        "required": [
          "price_micro",
          "quantity_micro"
        ]
      },
      "OrderBook": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "market": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "venue": {
                "enum": [
                  "polymarket-us",
                  "kalshi"
                ]
              },
              "instrument_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              },
              "outcome_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              }
            },
            "required": [
              "venue",
              "instrument_id",
              "outcome_id"
            ]
          },
          "asks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DepthLevel"
            }
          },
          "observed_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "snapshot_id": {
            "type": "string"
          },
          "currency": {
            "const": "USD"
          },
          "status": {
            "enum": [
              "open",
              "closed",
              "snapshot",
              "unknown"
            ]
          },
          "provenance": {
            "$ref": "#/components/schemas/Provenance"
          },
          "fee_model": {
            "const": "unknown"
          },
          "fee_estimate_micro": {
            "type": "null"
          },
          "synthetic": {
            "const": false
          }
        },
        "required": [
          "market",
          "asks",
          "observed_at",
          "snapshot_id",
          "currency",
          "status",
          "provenance",
          "fee_model",
          "fee_estimate_micro",
          "synthetic"
        ]
      },
      "SimulationLeg": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "step_index": {
            "type": "integer"
          },
          "market": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "venue": {
                "enum": [
                  "polymarket-us",
                  "kalshi"
                ]
              },
              "instrument_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              },
              "outcome_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              }
            },
            "required": [
              "venue",
              "instrument_id",
              "outcome_id"
            ]
          },
          "requested_quantity_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "limit_price_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "filled_quantity_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "remaining_quantity_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "cost_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "status": {
            "enum": [
              "filled",
              "partially_filled",
              "unfilled"
            ]
          },
          "snapshot_id": {
            "type": "string"
          },
          "quote_age_ms": {
            "type": "number"
          },
          "fills": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true,
              "properties": {
                "price_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]*)$"
                },
                "quantity_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]*)$"
                },
                "cost_micro": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]*)$"
                }
              },
              "required": [
                "price_micro",
                "quantity_micro",
                "cost_micro"
              ]
            }
          }
        },
        "required": [
          "step_index",
          "market",
          "requested_quantity_micro",
          "limit_price_micro",
          "filled_quantity_micro",
          "remaining_quantity_micro",
          "cost_micro",
          "status",
          "snapshot_id",
          "quote_age_ms",
          "fills"
        ]
      },
      "SimulationObservation": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "snapshot_id": {
            "type": "string"
          },
          "market": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "venue": {
                "enum": [
                  "polymarket-us",
                  "kalshi"
                ]
              },
              "instrument_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              },
              "outcome_id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,159}$"
              }
            },
            "required": [
              "venue",
              "instrument_id",
              "outcome_id"
            ]
          },
          "provenance": {
            "$ref": "#/components/schemas/Provenance"
          },
          "observed_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "quote_age_ms": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "asks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DepthLevel"
            }
          },
          "market_detail": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MarketRecord"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "snapshot_id",
          "market",
          "provenance",
          "observed_at",
          "quote_age_ms",
          "currency",
          "status",
          "asks",
          "market_detail"
        ]
      },
      "PaperSimulation": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "mode": {
            "const": "paper"
          },
          "plan_hash": {
            "type": "string"
          },
          "observed_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "expires_at": {
            "type": "string",
            "minLength": 20,
            "maxLength": 30
          },
          "currency": {
            "type": "string"
          },
          "preparation_status": {
            "enum": [
              "ready_for_review",
              "incomplete",
              "needs_review"
            ]
          },
          "all_legs_filled": {
            "type": "boolean"
          },
          "native_constraints_verified": {
            "type": "boolean"
          },
          "planned_purchase_cost_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "planned_maximum_cost_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "cost_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "fee_allowance_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "fee_estimate_micro": {
            "type": "null"
          },
          "maximum_cost_with_fee_allowance_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "maximum_loss_micro": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)$"
          },
          "executable": {
            "const": false
          },
          "model": {
            "type": "string"
          },
          "joint_probability": {
            "type": "null"
          },
          "legs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SimulationLeg"
            }
          },
          "snapshots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SimulationObservation"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "mode",
          "plan_hash",
          "observed_at",
          "expires_at",
          "currency",
          "preparation_status",
          "all_legs_filled",
          "native_constraints_verified",
          "planned_purchase_cost_micro",
          "planned_maximum_cost_micro",
          "cost_micro",
          "fee_allowance_micro",
          "fee_estimate_micro",
          "maximum_cost_with_fee_allowance_micro",
          "maximum_loss_micro",
          "executable",
          "model",
          "joint_probability",
          "legs",
          "snapshots",
          "assumptions",
          "warnings"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "ok": {
            "const": false
          },
          "request_id": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "status": {
                "type": "integer"
              },
              "retryable": {
                "type": "boolean"
              },
              "retry_after_seconds": {
                "type": "integer",
                "minimum": 1
              },
              "details": {}
            },
            "required": [
              "code",
              "message",
              "status",
              "retryable"
            ]
          }
        },
        "required": [
          "ok",
          "request_id",
          "error"
        ]
      },
      "Response": {
        "type": "object",
        "required": [
          "ok",
          "request_id"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "request_id": {
            "type": "string"
          },
          "result": {
            "type": "object"
          },
          "error": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "status": {
                "type": "integer"
              },
              "retryable": {
                "type": "boolean"
              },
              "retry_after_seconds": {
                "type": "integer",
                "minimum": 1
              },
              "details": {}
            },
            "required": [
              "code",
              "message",
              "status",
              "retryable"
            ]
          }
        }
      }
    },
    "securitySchemes": {
      "WalletSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "pm_session"
      },
      "OAuth": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://parlaymarket.io/api/oauth/authorize",
            "tokenUrl": "https://parlaymarket.io/api/oauth/token",
            "scopes": {
              "markets:read": "markets:read",
              "plans:write": "plans:write",
              "workflows:write": "workflows:write",
              "history:read": "history:read",
              "events:write": "events:write"
            }
          }
        }
      }
    }
  }
}
