{
  "openapi": "3.1.0",
  "info": {
    "title": "Lambda API",
    "description": "Every endpoint is authenticated with an API key: send api-access-key, api-timestamp, and api-signature on each request.",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.pax.markets",
      "description": "Production API"
    }
  ],
  "paths": {
    "/v1/lambda/submit": {
      "post": {
        "tags": [
          "lambda"
        ],
        "summary": "Submit a lambda program",
        "description": "Arm a lambda program. Requires a LAMBDA account.",
        "operationId": "LambdaService_SubmitLambda",
        "requestBody": {
          "description": "Submit a lambda program.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitLambda"
              }
            }
          },
          "required": true
        },
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubmitLambdaResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiAccessKey": [
              "trade"
            ],
            "ApiTimestamp": [],
            "ApiSignature": []
          }
        ]
      }
    },
    "/v1/lambda/cancel": {
      "post": {
        "tags": [
          "lambda"
        ],
        "summary": "Cancel a lambda program",
        "description": "Cancel a lambda program, named by its exchange-assigned id or its client-assigned id, releasing its untriggered quantity.",
        "operationId": "LambdaService_CancelLambda",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelLambda"
              }
            }
          },
          "required": true
        },
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelLambdaResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiAccessKey": [
              "trade"
            ],
            "ApiTimestamp": [],
            "ApiSignature": []
          }
        ]
      }
    },
    "/v1/lambda/list": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "List lambda programs",
        "description": "List the account's lambda programs, newest first, optionally narrowed to one market and one status.",
        "operationId": "LambdaService_GetLambdas",
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "description": "Return only lambda programs in this status.",
            "schema": {
              "description": "Return only lambda programs in this status.",
              "$ref": "#/components/schemas/LambdaStatus"
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "market_id",
            "description": "Return only lambda programs on this market. Omit for every market.",
            "schema": {
              "description": "Return only lambda programs on this market. Omit for every market.",
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "limit",
            "description": "Maximum lambda programs to return, from 1 to 1000. Defaults to 1000.",
            "schema": {
              "description": "Maximum lambda programs to return, from 1 to 1000. Defaults to 1000.",
              "type": "integer",
              "format": "uint32",
              "minimum": 0
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "cursor",
            "description": "Cursor from the previous response's next_cursor. Omit for the first page.",
            "schema": {
              "description": "Cursor from the previous response's next_cursor. Omit for the first page.",
              "type": "string"
            },
            "style": "form"
          }
        ],
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LambdaPage"
                }
              }
            }
          }
        }
      }
    },
    "/v1/lambda/{lambda_id}": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "Get a lambda program",
        "description": "Fetch one lambda program by lambda_id.",
        "operationId": "LambdaService_GetLambda",
        "parameters": [
          {
            "in": "path",
            "name": "lambda_id",
            "description": "Exchange-assigned id of the lambda program to fetch.",
            "required": true,
            "schema": {
              "description": "Exchange-assigned id of the lambda program to fetch.",
              "type": "string",
              "format": "uuid"
            },
            "style": "simple"
          }
        ],
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lambda"
                }
              }
            }
          }
        }
      }
    },
    "/v1/lambda/active": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "List active lambda programs",
        "description": "List the account's lambda programs currently in force. The user-data WebSocket's snapshot carries the same list.",
        "operationId": "LambdaService_GetActiveLambdas",
        "parameters": [
          {
            "in": "query",
            "name": "market_id",
            "description": "Return only lambda programs on this market. Omit for every market.",
            "schema": {
              "description": "Return only lambda programs on this market. Omit for every market.",
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            },
            "style": "form"
          }
        ],
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActiveLambdas"
                }
              }
            }
          }
        }
      }
    },
    "/v1/lambda/pending-cancels": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "List pending lambda cancels",
        "description": "List the account's lambda cancels that are not yet confirmed.",
        "operationId": "LambdaService_GetPendingLambdaCancels",
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingLambdaCancels"
                }
              }
            }
          }
        }
      }
    },
    "/v1/lambda/status-updates": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "Get a lambda program's status updates",
        "description": "Read the full status update history of one lambda program. Updates can take up to 15 minutes to appear here.",
        "operationId": "LambdaService_GetLambdaStatusUpdates",
        "parameters": [
          {
            "in": "query",
            "name": "lambda_id",
            "description": "Exchange-assigned id of the lambda program whose history to read.",
            "required": true,
            "schema": {
              "description": "Exchange-assigned id of the lambda program whose history to read.",
              "type": "string",
              "format": "uuid"
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "limit",
            "description": "Maximum updates to return, from 1 to 1000. Defaults to 1000.",
            "schema": {
              "description": "Maximum updates to return, from 1 to 1000. Defaults to 1000.",
              "type": "integer",
              "format": "uint32",
              "minimum": 0
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "cursor",
            "description": "Cursor from the previous response's next_cursor. Omit for the first page.",
            "schema": {
              "description": "Cursor from the previous response's next_cursor. Omit for the first page.",
              "type": "string"
            },
            "style": "form"
          }
        ],
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LambdaStatusUpdatePage"
                }
              }
            }
          }
        }
      }
    },
    "/v1/lambda/status-updates/recent": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "Get recent lambda status updates",
        "description": "Read the account's most recent lambda status updates, newest first. Covers the last 10,000 updates per account.",
        "operationId": "LambdaService_GetRecentLambdaStatusUpdates",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "description": "Maximum updates to return, from 1 to 1000. Defaults to 1000.",
            "schema": {
              "description": "Maximum updates to return, from 1 to 1000. Defaults to 1000.",
              "type": "integer",
              "format": "uint32",
              "minimum": 0
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "cursor",
            "description": "Cursor from the previous response's next_cursor. Omit to start at the newest update.",
            "schema": {
              "description": "Cursor from the previous response's next_cursor. Omit to start at the newest update.",
              "type": "string"
            },
            "style": "form"
          }
        ],
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LambdaStatusUpdatePage"
                }
              }
            }
          }
        }
      }
    },
    "/v1/lambda/status-updates/since": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "Get lambda status updates since a time",
        "description": "Read the account's lambda status updates from a point in time onward, oldest first. Covers the last 10,000 updates per account.",
        "operationId": "LambdaService_GetLambdaStatusUpdatesSince",
        "parameters": [
          {
            "in": "query",
            "name": "since_time_ms",
            "description": "Return updates at or after this time, in Unix milliseconds.",
            "required": true,
            "schema": {
              "description": "Return updates at or after this time, in Unix milliseconds.",
              "type": "integer",
              "format": "int64"
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "limit",
            "description": "Maximum updates to return, from 1 to 1000. Defaults to 1000.",
            "schema": {
              "description": "Maximum updates to return, from 1 to 1000. Defaults to 1000.",
              "type": "integer",
              "format": "uint32",
              "minimum": 0
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "cursor",
            "description": "Cursor from the previous response's next_cursor. Omit to start at since_time_ms.",
            "schema": {
              "description": "Cursor from the previous response's next_cursor. Omit to start at since_time_ms.",
              "type": "string"
            },
            "style": "form"
          }
        ],
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LambdaStatusUpdatePage"
                }
              }
            }
          }
        }
      }
    },
    "/v1/lambda/status-updates/by-time": {
      "get": {
        "tags": [
          "lambda"
        ],
        "summary": "Get lambda status updates by time",
        "description": "Fetch lambda status updates in a time range of up to 7 days, oldest first. Updates appear up to 30 minutes after they happen.",
        "operationId": "LambdaService_GetLambdaStatusUpdatesByTime",
        "parameters": [
          {
            "in": "query",
            "name": "start_time_ms",
            "description": "Return updates at or after this time, in Unix milliseconds.",
            "required": true,
            "schema": {
              "description": "Return updates at or after this time, in Unix milliseconds.",
              "type": "integer",
              "format": "int64"
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "end_time_ms",
            "description": "Return updates before this time, in Unix milliseconds. At most 7 days after start_time_ms.",
            "required": true,
            "schema": {
              "description": "Return updates before this time, in Unix milliseconds. At most 7 days after start_time_ms.",
              "type": "integer",
              "format": "int64"
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "limit",
            "description": "Maximum updates to return, from 1 to 10000. Defaults to 10000.",
            "schema": {
              "description": "Maximum updates to return, from 1 to 10000. Defaults to 10000.",
              "type": "integer",
              "format": "uint32",
              "minimum": 0
            },
            "style": "form"
          },
          {
            "in": "query",
            "name": "cursor",
            "description": "Cursor from the previous response's next_cursor, with the same time range.",
            "schema": {
              "description": "Cursor from the previous response's next_cursor, with the same time range.",
              "type": "string"
            },
            "style": "form"
          }
        ],
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LambdaStatusUpdatePage"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiAccessKey": {
        "type": "apiKey",
        "in": "header",
        "name": "api-access-key",
        "description": "The key id of the API key making the request. Endpoints that need more than read access list `trade` or `withdraw` as a role."
      },
      "ApiTimestamp": {
        "type": "apiKey",
        "in": "header",
        "name": "api-timestamp",
        "description": "Request timestamp in milliseconds since the Unix epoch. Requests outside recvWindow are rejected."
      },
      "ApiSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "api-signature",
        "description": "Signature over the request, produced with the API key's secret."
      }
    },
    "schemas": {
      "SubmitLambda": {
        "description": "Submit a lambda program.",
        "type": "object",
        "properties": {
          "program": {
            "$ref": "#/components/schemas/LambdaProgram"
          },
          "client_lambda_id": {
            "description": "Client-assigned id, at most 36 bytes. Omit or leave empty for none. Rejected if it matches another of the account's live lambda programs.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "program"
        ]
      },
      "LambdaProgram": {
        "description": "A lambda program.",
        "oneOf": [
          {
            "description": "Watches a local order book on PAX.",
            "type": "object",
            "properties": {
              "predicate": {
                "$ref": "#/components/schemas/LocalPredicate"
              },
              "order": {
                "$ref": "#/components/schemas/LocalOrder"
              },
              "lifetime": {
                "$ref": "#/components/schemas/Lifetime"
              },
              "kind": {
                "type": "string",
                "const": "local"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "predicate",
              "order",
              "lifetime"
            ]
          }
        ],
        "examples": [
          {
            "kind": "local",
            "predicate": {
              "market_id": 1,
              "side": "ask",
              "event": "crossed",
              "px": {
                "kind": "tob_depth",
                "max": 2
              },
              "qty": {
                "kind": "event_qty",
                "min": 5000000
              }
            },
            "order": {
              "kind": "limit",
              "market_id": 1,
              "side": "ask",
              "tif": "gtc",
              "px": {
                "kind": "fixed",
                "ticks": 10105
              },
              "qty": {
                "kind": "fixed",
                "qty": 50000000
              }
            },
            "lifetime": {
              "kind": "once"
            }
          }
        ]
      },
      "LocalPredicate": {
        "description": "Which order book events trigger a local lambda program.",
        "type": "object",
        "properties": {
          "market_id": {
            "description": "Market whose order book is watched.",
            "type": [
              "integer",
              "string"
            ],
            "format": "uint64",
            "examples": [
              1
            ]
          },
          "side": {
            "description": "Side of the book the event happens on.",
            "allOf": [
              {
                "$ref": "#/components/schemas/Side"
              }
            ]
          },
          "event": {
            "$ref": "#/components/schemas/LocalEvent"
          },
          "px": {
            "$ref": "#/components/schemas/PxPredicate"
          },
          "qty": {
            "$ref": "#/components/schemas/QtyPredicate"
          }
        },
        "additionalProperties": false,
        "required": [
          "market_id",
          "side",
          "event",
          "px",
          "qty"
        ]
      },
      "Side": {
        "description": "Side of an order or of the book.",
        "oneOf": [
          {
            "description": "Buy the base asset.",
            "type": "string",
            "const": "bid"
          },
          {
            "description": "Sell the base asset.",
            "type": "string",
            "const": "ask"
          }
        ]
      },
      "LocalEvent": {
        "description": "The kind of book event that qualifies.",
        "oneOf": [
          {
            "description": "Liquidity was added to the book from a GTC/ALO order.",
            "type": "string",
            "const": "rested"
          },
          {
            "description": "Liquidity was removed from the book for any reason.",
            "type": "string",
            "const": "removed"
          },
          {
            "description": "Liquidity was removed from the book by a cancel.",
            "type": "string",
            "const": "canceled"
          },
          {
            "description": "Liquidity was removed from the book by a trade.",
            "type": "string",
            "const": "crossed"
          }
        ]
      },
      "PxPredicate": {
        "description": "Which event prices qualify.",
        "oneOf": [
          {
            "description": "Any price.",
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "any"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind"
            ]
          },
          {
            "description": "The event's price is in [min, max] ticks.",
            "type": "object",
            "properties": {
              "min": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Ticks"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "max": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Ticks"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "kind": {
                "type": "string",
                "const": "event_px"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind"
            ]
          },
          {
            "description": "The event’s price is in [min, max] ticks within the top-of-book as it was before the event.\nAn event at or inside the best price, or on an empty side, is within 0 ticks.",
            "type": "object",
            "properties": {
              "min": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Ticks"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "max": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Ticks"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "kind": {
                "type": "string",
                "const": "tob_depth"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind"
            ]
          }
        ]
      },
      "Ticks": {
        "description": "A price, in units of the market's tick size.",
        "type": [
          "integer",
          "string"
        ],
        "format": "int64",
        "examples": [
          10105
        ]
      },
      "QtyPredicate": {
        "description": "Which event quantities qualify.",
        "oneOf": [
          {
            "description": "Any quantity.",
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "any"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind"
            ]
          },
          {
            "description": "The quantity the event added or removed is in [min, max].",
            "type": "object",
            "properties": {
              "min": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Qty"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "max": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Qty"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "kind": {
                "type": "string",
                "const": "event_qty"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind"
            ]
          },
          {
            "description": "The quantity resting at the event's price after the event is in [min, max].",
            "type": "object",
            "properties": {
              "min": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Qty"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "max": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/Qty"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "kind": {
                "type": "string",
                "const": "final_level_qty"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind"
            ]
          }
        ]
      },
      "Qty": {
        "description": "A base-asset quantity in native units, a multiple of the market's qty step size.",
        "type": [
          "integer",
          "string"
        ],
        "format": "uint64",
        "examples": [
          5000000
        ]
      },
      "LocalOrder": {
        "description": "The underlying order placed on every fire.",
        "oneOf": [
          {
            "description": "A limit order.",
            "type": "object",
            "properties": {
              "market_id": {
                "description": "Market the order is placed on.",
                "type": [
                  "integer",
                  "string"
                ],
                "format": "uint64",
                "examples": [
                  1
                ]
              },
              "side": {
                "description": "Side of the order.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Side"
                  }
                ]
              },
              "tif": {
                "$ref": "#/components/schemas/Tif"
              },
              "px": {
                "description": "Limit price.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/LocalPx"
                  }
                ]
              },
              "qty": {
                "description": "Quantity.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/LocalQty"
                  }
                ]
              },
              "kind": {
                "type": "string",
                "const": "limit"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "market_id",
              "side",
              "tif",
              "px",
              "qty"
            ]
          },
          {
            "description": "Cancel up to qty of the account's own resting liquidity at one price.",
            "type": "object",
            "properties": {
              "market_id": {
                "description": "Market the order is placed on.",
                "type": [
                  "integer",
                  "string"
                ],
                "format": "uint64",
                "examples": [
                  1
                ]
              },
              "side": {
                "description": "Side of the order.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Side"
                  }
                ]
              },
              "px": {
                "description": "Price of the resting liquidity.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/LocalPx"
                  }
                ]
              },
              "qty": {
                "description": "Quantity to cancel.",
                "allOf": [
                  {
                    "$ref": "#/components/schemas/LocalQty"
                  }
                ]
              },
              "kind": {
                "type": "string",
                "const": "cancel"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "market_id",
              "side",
              "px",
              "qty"
            ]
          }
        ]
      },
      "Tif": {
        "description": "Time in force.",
        "oneOf": [
          {
            "description": "Good until canceled: the unfilled quantity rests on the book.",
            "type": "string",
            "const": "gtc"
          },
          {
            "description": "Immediate or cancel: the unfilled quantity is canceled.",
            "type": "string",
            "const": "ioc"
          },
          {
            "description": "Add liquidity only: rests like gtc, but the whole order is canceled if it would cross.",
            "type": "string",
            "const": "alo"
          }
        ]
      },
      "LocalPx": {
        "description": "The price template each fire of a local lambda program places its order at.",
        "oneOf": [
          {
            "description": "A fixed price, in ticks.",
            "type": "object",
            "properties": {
              "ticks": {
                "$ref": "#/components/schemas/Ticks"
              },
              "kind": {
                "type": "string",
                "const": "fixed"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "ticks"
            ]
          }
        ]
      },
      "LocalQty": {
        "description": "The quantity template for the order placed on each fire of a local lambda program.",
        "oneOf": [
          {
            "description": "A fixed quantity, in the base asset's native units.",
            "type": "object",
            "properties": {
              "qty": {
                "$ref": "#/components/schemas/Qty"
              },
              "kind": {
                "type": "string",
                "const": "fixed"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "qty"
            ]
          }
        ]
      },
      "Lifetime": {
        "description": "When a lambda program stops firing.",
        "oneOf": [
          {
            "description": "Fire once.",
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "once"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind"
            ]
          }
        ]
      },
      "SubmitLambdaResponse": {
        "type": "object",
        "properties": {
          "lambda_id": {
            "description": "Exchange-assigned lambda id.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "lambda_id"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        },
        "required": [
          "error"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "message": {
            "description": "Human-readable description of the error.",
            "type": "string"
          },
          "field": {
            "description": "Dotted path of the request field at fault, such as `program.order.qty`. Omitted if no single field is at fault.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "ErrorCode": {
        "description": "Error category.",
        "oneOf": [
          {
            "description": "The request is malformed or has an invalid value.",
            "type": "string",
            "const": "invalid_request"
          },
          {
            "description": "The request is valid, but the combination is not supported.",
            "type": "string",
            "const": "unsupported"
          },
          {
            "description": "The requested feature is not available yet.",
            "type": "string",
            "const": "not_available"
          },
          {
            "description": "The referenced order or lambda program does not exist.",
            "type": "string",
            "const": "not_found"
          },
          {
            "description": "The request is not authenticated.",
            "type": "string",
            "const": "unauthenticated"
          },
          {
            "description": "The caller lacks permission for this request.",
            "type": "string",
            "const": "forbidden"
          },
          {
            "description": "The referenced order or lambda program is not in a state that allows the request.",
            "type": "string",
            "const": "failed_precondition"
          },
          {
            "description": "The request conflicts with an earlier one.",
            "type": "string",
            "const": "conflict"
          },
          {
            "description": "Insufficient balance.",
            "type": "string",
            "const": "insufficient_balance"
          },
          {
            "description": "The client-assigned id is already in use.",
            "type": "string",
            "const": "duplicate_client_id"
          },
          {
            "description": "The exchange is at capacity.",
            "type": "string",
            "const": "capacity_reached"
          },
          {
            "description": "Rate limit exceeded.",
            "type": "string",
            "const": "rate_limited"
          },
          {
            "description": "The exchange is temporarily unavailable.",
            "type": "string",
            "const": "exchange_unavailable"
          },
          {
            "description": "Internal exchange error.",
            "type": "string",
            "const": "exchange_error"
          }
        ]
      },
      "CancelLambda": {
        "type": "object",
        "properties": {
          "key": {
            "description": "The lambda program to cancel.",
            "allOf": [
              {
                "$ref": "#/components/schemas/Key"
              }
            ]
          }
        },
        "additionalProperties": false,
        "required": [
          "key"
        ]
      },
      "Key": {
        "description": "Identifies a lambda program by its exchange-assigned or client-assigned id.",
        "oneOf": [
          {
            "description": "The exchange-assigned id.",
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "kind": {
                "type": "string",
                "const": "exchange"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "id"
            ]
          },
          {
            "description": "The client-assigned id, at most 36 bytes. Only matches a live lambda program.",
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "kind": {
                "type": "string",
                "const": "client"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "id"
            ]
          }
        ]
      },
      "CancelLambdaResponse": {
        "type": "object",
        "properties": {
          "lambda_id": {
            "description": "Exchange-assigned id of the lambda program being canceled.",
            "type": "string",
            "format": "uuid"
          },
          "cancel_id": {
            "description": "Exchange-assigned id of this cancel.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "lambda_id",
          "cancel_id"
        ]
      },
      "LambdaStatus": {
        "description": "Status of a lambda program.",
        "oneOf": [
          {
            "description": "Submitted, not yet accepted.",
            "type": "string",
            "const": "pending"
          },
          {
            "description": "In force: evaluated on every matching event.",
            "type": "string",
            "const": "in_force"
          },
          {
            "description": "No longer in force: exhausted, canceled, or reset by a system restart.",
            "type": "string",
            "const": "out_of_force"
          },
          {
            "description": "Rejected.",
            "type": "string",
            "const": "rejected"
          }
        ]
      },
      "LambdaPage": {
        "type": "object",
        "properties": {
          "lambdas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Lambda"
            }
          },
          "next_cursor": {
            "description": "Pass as cursor to fetch the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "lambdas"
        ]
      },
      "Lambda": {
        "type": "object",
        "properties": {
          "lambda_id": {
            "description": "Exchange-assigned lambda id.",
            "type": "string",
            "format": "uuid"
          },
          "client_lambda_id": {
            "description": "Client-assigned id from the submit request.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/LambdaStatus"
          },
          "program": {
            "description": "The program as it was submitted.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/LambdaProgram"
              },
              {
                "type": "null"
              }
            ],
            "examples": [
              {
                "kind": "local",
                "predicate": {
                  "market_id": "1",
                  "side": "ask",
                  "event": "crossed",
                  "px": {
                    "kind": "tob_depth",
                    "max": "2"
                  },
                  "qty": {
                    "kind": "event_qty",
                    "min": "5000000"
                  }
                },
                "order": {
                  "kind": "limit",
                  "market_id": "1",
                  "side": "ask",
                  "tif": "gtc",
                  "px": {
                    "kind": "fixed",
                    "ticks": "10105"
                  },
                  "qty": {
                    "kind": "fixed",
                    "qty": "50000000"
                  }
                },
                "lifetime": {
                  "kind": "once"
                }
              }
            ]
          },
          "qty_triggered": {
            "description": "Quantity the lambda program has placed so far.",
            "type": "string",
            "format": "uint64"
          },
          "created_time_ms": {
            "description": "When the lambda program was submitted, in Unix milliseconds.",
            "type": "string",
            "format": "int64"
          },
          "updated_time_ms": {
            "description": "When the lambda program last changed, in Unix milliseconds.",
            "type": "string",
            "format": "int64"
          }
        },
        "required": [
          "lambda_id",
          "status",
          "qty_triggered",
          "created_time_ms",
          "updated_time_ms"
        ]
      },
      "ActiveLambdas": {
        "type": "object",
        "properties": {
          "lambdas": {
            "description": "The account's lambda programs in force.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Lambda"
            }
          }
        },
        "required": [
          "lambdas"
        ]
      },
      "PendingLambdaCancels": {
        "type": "object",
        "properties": {
          "pending_cancels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PendingLambdaCancel"
            }
          }
        },
        "required": [
          "pending_cancels"
        ]
      },
      "PendingLambdaCancel": {
        "description": "A lambda program cancel awaiting confirmation.",
        "type": "object",
        "properties": {
          "lambda_id": {
            "description": "Lambda program being canceled.",
            "type": "string",
            "format": "uuid"
          },
          "client_lambda_id": {
            "description": "Client-assigned lambda id, if one was sent.",
            "type": [
              "string",
              "null"
            ]
          },
          "cancel_id": {
            "description": "Exchange-assigned id of this lambda cancel request.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "lambda_id",
          "cancel_id"
        ]
      },
      "LambdaStatusUpdatePage": {
        "type": "object",
        "properties": {
          "lambda_status_updates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LambdaStatusUpdate"
            }
          },
          "next_cursor": {
            "description": "Pass as cursor to fetch the next page. Null on the last page.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "lambda_status_updates"
        ]
      },
      "LambdaStatusUpdate": {
        "description": "A lambda program status update. Also sent on the user-data WebSocket.",
        "type": "object",
        "properties": {
          "lsu_id": {
            "description": "Id of this status update.",
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "lambda_id": {
            "description": "Exchange-assigned id of the lambda program this update belongs to. Null for older updates that did not record it.",
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "client_lambda_id": {
            "description": "Client-assigned lambda id, if one was sent.",
            "type": [
              "string",
              "null"
            ]
          },
          "delta_qty": {
            "description": "Change in the lambda program's untriggered quantity: the full quantity when programmed, minus what was left when canceled or reset by a system restart, and 0 otherwise.",
            "type": "string",
            "format": "int64"
          },
          "status": {
            "description": "New status of the lambda program.",
            "allOf": [
              {
                "$ref": "#/components/schemas/LambdaStatus"
              }
            ]
          },
          "reason": {
            "$ref": "#/components/schemas/LambdaStatusUpdateReason"
          },
          "created_time_ms": {
            "description": "When this update happened, in Unix milliseconds.",
            "type": "string",
            "format": "int64"
          },
          "cancel_id": {
            "description": "Exchange-assigned id of the lambda cancel request. Null unless reason is canceled or cancel_missed.",
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        },
        "required": [
          "delta_qty",
          "status",
          "reason",
          "created_time_ms"
        ]
      },
      "LambdaStatusUpdateReason": {
        "description": "Why a lambda program changed status.",
        "oneOf": [
          {
            "description": "Accepted and now in force.",
            "type": "string",
            "const": "programmed"
          },
          {
            "description": "The lambda program was successfully canceled and its untriggered quantity released.",
            "type": "string",
            "const": "canceled"
          },
          {
            "description": "The lambda program's quantity changed.",
            "type": "string",
            "const": "modified"
          },
          {
            "description": "All quantity has triggered.",
            "type": "string",
            "const": "exhausted"
          },
          {
            "description": "State reset by a system restart.",
            "type": "string",
            "const": "system_restart"
          },
          {
            "description": "Refused because the account cannot fund the lambda program.",
            "type": "string",
            "const": "insufficient_balance"
          },
          {
            "description": "Refused because client_lambda_id is already in use by a live lambda program.",
            "type": "string",
            "const": "duplicate_client_id"
          },
          {
            "description": "Refused because the lambda program failed validation.",
            "type": "string",
            "const": "invalid_lambda"
          },
          {
            "description": "Refused because of an internal exchange error. The lambda program was not placed.",
            "type": "string",
            "const": "exchange_error"
          },
          {
            "description": "Refused because the exchange is not accepting lambda programs right now.",
            "type": "string",
            "const": "exchange_unavailable"
          },
          {
            "description": "Refused because the exchange has no capacity for the lambda program right now.",
            "type": "string",
            "const": "capacity_reached"
          },
          {
            "description": "The cancel had nothing to cancel: the lambda program had already fully triggered or ended.",
            "type": "string",
            "const": "cancel_missed"
          }
        ]
      }
    }
  },
  "security": [
    {
      "ApiAccessKey": [],
      "ApiTimestamp": [],
      "ApiSignature": []
    }
  ]
}
