{
  "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"
    ]
  }
}
