{
  "openapi": "3.1.0",
  "info": {
    "title": "Compatibility API",
    "description": "Endpoints are authenticated with an API key: send api-access-key, api-timestamp, and api-signature on each request. Public endpoints (security: []) take no key.",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.pax.markets",
      "description": "Production API"
    }
  ],
  "paths": {
    "/v1/compatibility/order/cancel": {
      "post": {
        "tags": [
          "CompatibilityOrderService"
        ],
        "summary": "Cancel order",
        "description": "Cancel the named order's unfilled quantity at its side and price level. This is a liquidity cancel, so the quantity may come off any of the account's orders at that level.",
        "operationId": "CompatibilityOrderService_CancelOrder",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/paxcompatibility_apiCancelOrderRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "A successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/paxcompatibility_apiCancelOrderResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiAccessKey": [
              "trade"
            ],
            "ApiTimestamp": [],
            "ApiSignature": []
          }
        ]
      }
    },
    "/v1/compatibility/order/submit-batch": {
      "post": {
        "tags": [
          "CompatibilityOrderService"
        ],
        "summary": "Batch submit orders",
        "description": "Place several orders in one request.",
        "operationId": "CompatibilityOrderService_BatchSubmitOrders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/paxcompatibility_apiBatchSubmitOrdersRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "A successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/paxcompatibility_apiBatchSubmitOrdersResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiAccessKey": [
              "trade"
            ],
            "ApiTimestamp": [],
            "ApiSignature": []
          }
        ]
      }
    },
    "/v1/compatibility/order/cancel-batch": {
      "post": {
        "tags": [
          "CompatibilityOrderService"
        ],
        "summary": "Batch cancel orders",
        "description": "Run several CancelOrder liquidity cancels in one request.",
        "operationId": "CompatibilityOrderService_BatchCancelOrders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/paxcompatibility_apiBatchCancelOrdersRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "default": {
            "description": "An error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyErrorResponse"
                }
              }
            }
          },
          "200": {
            "description": "A successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/paxcompatibility_apiBatchCancelOrdersResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiAccessKey": [
              "trade"
            ],
            "ApiTimestamp": [],
            "ApiSignature": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "LegacyErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "description": "Why the request failed. Requests stopped before reaching the endpoint, for example by authentication, send an object with a code and a message; errors from the endpoint itself send a string.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "message"
                ]
              }
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "paxcompatibility_apiCancelOrderRequest": {
        "type": "object",
        "properties": {
          "order_id": {
            "description": "Order whose unfilled quantity, side and price level set the cancel.",
            "type": "string"
          },
          "client_order_id": {
            "description": "Client-assigned id for the cancel, at most 36 bytes. Omit or leave empty for none.",
            "type": "string"
          }
        },
        "required": [
          "order_id"
        ]
      },
      "paxcompatibility_apiCancelOrderResponse": {
        "type": "object",
        "properties": {
          "order_id": {
            "description": "Exchange-assigned id of the cancel order, not of the order named in the request.",
            "type": "string"
          }
        },
        "required": [
          "order_id"
        ]
      },
      "paxcommonSide": {
        "description": "Side of an order.\n\n- `ASK`: Sell the base asset.\n- `BID`: Buy the base asset.",
        "x-enum-numbers": [
          1,
          2
        ],
        "x-enum-descriptions": {
          "ASK": "Sell the base asset.",
          "BID": "Buy the base asset."
        },
        "type": "string",
        "enum": [
          "ASK",
          "BID"
        ]
      },
      "paxcommonTimeInForce": {
        "description": "Time in force.\n\n- `IOC`: Immediate or cancel.\n- `GTC`: Good until canceled.\n- `ALO`: Add liquidity only: rests if it would not cross, else canceled.",
        "x-enum-numbers": [
          1,
          2,
          3
        ],
        "x-enum-descriptions": {
          "ALO": "Add liquidity only: rests if it would not cross, else canceled.",
          "GTC": "Good until canceled.",
          "IOC": "Immediate or cancel."
        },
        "type": "string",
        "enum": [
          "IOC",
          "GTC",
          "ALO"
        ]
      },
      "paxclientOrder": {
        "type": "object",
        "properties": {
          "side": {
            "description": "Side to place on.",
            "allOf": [
              {
                "$ref": "#/components/schemas/paxcommonSide"
              }
            ]
          },
          "market_id": {
            "description": "Market to place on.",
            "type": "string",
            "format": "uint64"
          },
          "qty": {
            "description": "Quantity to place, a multiple of the market's step size. Must be positive except on a cancel lambda.",
            "type": "string",
            "format": "int64"
          },
          "ticks": {
            "description": "Limit price in ticks, from 1 to the market's max_ticks.",
            "type": "integer",
            "format": "int32"
          },
          "tif": {
            "description": "How long the order stays live.",
            "allOf": [
              {
                "$ref": "#/components/schemas/paxcommonTimeInForce"
              }
            ]
          },
          "is_leverage": {
            "description": "Trade on margin. Currently disabled.",
            "type": "boolean"
          }
        },
        "required": [
          "side",
          "market_id",
          "qty",
          "ticks",
          "tif",
          "is_leverage"
        ]
      },
      "paxorder_apiSubmitOrderRequest": {
        "type": "object",
        "properties": {
          "order": {
            "description": "The order to place.",
            "allOf": [
              {
                "$ref": "#/components/schemas/paxclientOrder"
              }
            ]
          },
          "client_order_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 orders.",
            "type": "string"
          }
        },
        "required": [
          "order"
        ]
      },
      "paxcompatibility_apiBatchSubmitOrdersRequest": {
        "type": "object",
        "properties": {
          "orders": {
            "description": "List of orders to place, in the order given. At most 10 per request.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/paxorder_apiSubmitOrderRequest"
            },
            "maxItems": 10
          }
        }
      },
      "paxcommonOrderStatusUpdateReason": {
        "description": "Why the system rejected or canceled an order.\n\n- `OSU_REASON_UNSPECIFIED`: None.\n- `OSU_REASON_ADMIN_CANCELED`: Canceled by the system, such as ahead of maintenance or shutdown.\n- `OSU_REASON_INSUFFICIENT_BALANCE`: Refused because the account cannot fund the order.\n- `OSU_REASON_DUPLICATE_CLIENT_ID`: Refused because `client_order_id` is already in use by a live order.\n- `OSU_REASON_EXCHANGE_ERROR`: Refused because of an internal exchange error. The order was not placed.\n- `OSU_REASON_ALO_WOULD_CROSS`: Canceled because the ALO order would have crossed the book.\n- `OSU_REASON_EXCHANGE_UNAVAILABLE`: Refused because the exchange is not accepting orders right now.\n- `OSU_REASON_CAPACITY_REACHED`: Refused because the exchange has no capacity for another active lambda account right now.\n- `OSU_REASON_INVALID_ORDER`: Refused because the order failed validation.",
        "default": "OSU_REASON_UNSPECIFIED",
        "x-enum-numbers": [
          0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8
        ],
        "x-enum-descriptions": {
          "OSU_REASON_ADMIN_CANCELED": "Canceled by the system, such as ahead of maintenance or shutdown.",
          "OSU_REASON_ALO_WOULD_CROSS": "Canceled because the ALO order would have crossed the book.",
          "OSU_REASON_CAPACITY_REACHED": "Refused because the exchange has no capacity for another active lambda account right now.",
          "OSU_REASON_DUPLICATE_CLIENT_ID": "Refused because `client_order_id` is already in use by a live order.",
          "OSU_REASON_EXCHANGE_ERROR": "Refused because of an internal exchange error. The order was not placed.",
          "OSU_REASON_EXCHANGE_UNAVAILABLE": "Refused because the exchange is not accepting orders right now.",
          "OSU_REASON_INSUFFICIENT_BALANCE": "Refused because the account cannot fund the order.",
          "OSU_REASON_INVALID_ORDER": "Refused because the order failed validation.",
          "OSU_REASON_UNSPECIFIED": "None."
        },
        "type": "string",
        "enum": [
          "OSU_REASON_UNSPECIFIED",
          "OSU_REASON_ADMIN_CANCELED",
          "OSU_REASON_INSUFFICIENT_BALANCE",
          "OSU_REASON_DUPLICATE_CLIENT_ID",
          "OSU_REASON_EXCHANGE_ERROR",
          "OSU_REASON_ALO_WOULD_CROSS",
          "OSU_REASON_EXCHANGE_UNAVAILABLE",
          "OSU_REASON_CAPACITY_REACHED",
          "OSU_REASON_INVALID_ORDER"
        ]
      },
      "paxcompatibility_apiOrderResult": {
        "type": "object",
        "properties": {
          "order_id": {
            "description": "Exchange-assigned order id. Empty if refused.",
            "type": "string"
          },
          "client_order_id": {
            "description": "The entry's client_order_id. Empty if none was sent.",
            "type": "string"
          },
          "accepted": {
            "description": "True if the exchange took the order.",
            "type": "boolean"
          },
          "reason": {
            "description": "Why the entry was refused. OSU_REASON_UNSPECIFIED if accepted.",
            "allOf": [
              {
                "$ref": "#/components/schemas/paxcommonOrderStatusUpdateReason"
              }
            ]
          },
          "message": {
            "description": "Error message for a refused entry.",
            "type": "string"
          }
        },
        "required": [
          "order_id",
          "client_order_id",
          "accepted",
          "reason",
          "message"
        ]
      },
      "paxcompatibility_apiBatchSubmitOrdersResponse": {
        "type": "object",
        "properties": {
          "results": {
            "description": "One result per entry, in request order.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/paxcompatibility_apiOrderResult"
            }
          }
        }
      },
      "paxcompatibility_apiBatchCancelOrdersRequest": {
        "type": "object",
        "properties": {
          "orders": {
            "description": "List of cancels to apply, in the order given. At most 10 per request.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/paxcompatibility_apiCancelOrderRequest"
            },
            "maxItems": 10
          }
        }
      },
      "paxcompatibility_apiBatchCancelOrdersResponse": {
        "type": "object",
        "properties": {
          "results": {
            "description": "One result per entry, in request order. order_id is the cancel order's id.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/paxcompatibility_apiOrderResult"
            }
          }
        }
      }
    },
    "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."
      }
    }
  },
  "security": [
    {
      "ApiAccessKey": [],
      "ApiTimestamp": [],
      "ApiSignature": []
    }
  ],
  "tags": [
    {
      "name": "CompatibilityOrderService"
    }
  ]
}