{
  "openapi": "3.1.0",
  "info": {
    "title": "Quanteex RESELLER management API",
    "version": "1.3.0"
  },
  "servers": [
    {
      "url": "https://api.quanteex.com/v1/reseller"
    }
  ],
  "security": [
    {
      "ManagementToken": []
    }
  ],
  "paths": {
    "/workspace": {
      "get": {
        "operationId": "getWorkspace",
        "summary": "Read workspace and RESELLER expiration",
        "x-required-permission": "any",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Workspace"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects": {
      "get": {
        "operationId": "listProjects",
        "summary": "List projects and balances",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "description": ""
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "description": "Pass next_cursor from the preceding page."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createProject",
        "summary": "Create a project",
        "x-required-permission": "projects",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": "Save a different UUID for each logical operation. Reuse it only with the same operation and body."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Named"
              }
            }
          }
        }
      }
    },
    "/projects/{project}": {
      "get": {
        "operationId": "getProject",
        "summary": "Read a project balance and budget",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "modifyProject",
        "summary": "Update, archive or restore a project",
        "x-required-permission": "projects",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": "Save a different UUID for each logical operation. Reuse it only with the same operation and body."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectPatch"
              }
            }
          }
        }
      }
    },
    "/projects/{project}/limits": {
      "get": {
        "operationId": "getProjectModelLimits",
        "summary": "Read live model limits for a project",
        "description": "Up to 24 models. Returns the serving gateway snapshot for the active project. The optional RPM is shared by the workspace; video jobs are excluded. Archived projects return 409 project_archived.",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            },
            "description": "Pass next_cursor from the preceding page. Retain the current cursor on reconnect."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectModelLimits"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/limits/events": {
      "get": {
        "operationId": "streamProjectModelLimits",
        "summary": "Watch live model limits for a project",
        "description": "Server-sent events. limits contains a full ProjectModelLimits snapshot, first on connect and then if the sampled values change. unavailable contains {} and ends the stream when access is lost. Connections end after 45 seconds; reconnect with the same cursor for a fresh snapshot. No event replay. Eight streams per workspace, subject to service capacity; HTTP 429 provides Retry-After.",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 256
            },
            "description": "Pass next_cursor from the preceding page. Retain the current cursor on reconnect."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "x-limits-event-data-schema": {
                  "$ref": "#/components/schemas/ProjectModelLimits"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/keys": {
      "get": {
        "operationId": "listKeys",
        "summary": "List keys and their budgets",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "description": ""
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "description": "Pass next_cursor from the preceding page."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "issueKey",
        "summary": "Issue an inference key",
        "x-required-permission": "keys",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": "Save a different UUID for each logical operation. Reuse it only with the same operation and body."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyReceipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Named"
              }
            }
          }
        }
      }
    },
    "/projects/{project}/keys/{key}": {
      "patch": {
        "operationId": "modifyKey",
        "summary": "Update the key name and budget or revoke the key",
        "x-required-permission": "keys",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "key",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": "Save a different UUID for each logical operation. Reuse it only with the same operation and body."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KeyPatch"
              }
            }
          }
        }
      }
    },
    "/projects/{project}/requests": {
      "get": {
        "operationId": "listRequests",
        "summary": "List recorded usage and charges",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false,
            "description": ""
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "description": "Pass next_cursor from the preceding page."
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31,
              "default": 7
            },
            "required": false,
            "description": "Rolling UTC days."
          },
          {
            "name": "key",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "description": "Filter by this project's key ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/requests/{request}": {
      "get": {
        "operationId": "getRequest",
        "summary": "Read one request and its recorded charge",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "request",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Request"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Summarize exact settled charges",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": ""
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31,
              "default": 7
            },
            "required": false,
            "description": "Rolling UTC days."
          },
          {
            "name": "key",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false,
            "description": "Filter by this project's key ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/transfers": {
      "post": {
        "operationId": "transferFunds",
        "summary": "Transfer funds between projects in this workspace",
        "x-required-permission": "transfers",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true,
            "description": "Save a different UUID for each logical operation. Reuse it only with the same operation and body."
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferReceipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Transfer"
              }
            }
          }
        }
      }
    },
    "/models": {
      "get": {
        "operationId": "listEffectiveModels",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EffectiveModelPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/payment-methods": {
      "get": {
        "operationId": "listPaymentMethods",
        "x-required-permission": "billing",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentMethods"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/topups": {
      "get": {
        "operationId": "listTopups",
        "x-required-permission": "billing",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopupPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/topups/{intent}": {
      "get": {
        "operationId": "getTopup",
        "x-required-permission": "billing",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "intent",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Topup"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/report": {
      "get": {
        "operationId": "getDailyUsageReport",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31,
              "default": 7
            },
            "required": false
          },
          {
            "name": "key",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DailyUsage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/reconciliation": {
      "get": {
        "operationId": "readReconciliation",
        "summary": "Reconcile settled model spending",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          },
          {
            "name": "key",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reconciliation"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Groups all settled requests by UTC creation day, model and key. Supports a half-open interval of up to 31 days, defaults to seven complete UTC days. Both timestamps are required when overriding the range. Output is complete or returns HTTP 422; narrow oversized intervals or filter by model/key."
      }
    },
    "/projects/{project}/reconciliation.csv": {
      "get": {
        "operationId": "exportReconciliation",
        "summary": "Export daily, model and key spending",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          },
          {
            "name": "key",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "X-Report-From": {
                "schema": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "X-Report-To": {
                "schema": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "X-Report-Sampled-At": {
                "schema": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "X-Report-Charge-USD": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+(\\.[0-9]+)?$"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Groups all settled requests by UTC creation day, model and key. Supports a half-open interval of up to 31 days, defaults to seven complete UTC days. Both timestamps are required when overriding the range. Output is complete or returns HTTP 422; narrow oversized intervals or filter by model/key."
      }
    },
    "/projects/{project}/requests.csv": {
      "get": {
        "operationId": "exportRequestPage",
        "x-required-permission": "read",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false
          },
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 31,
              "default": 7
            },
            "required": false
          },
          {
            "name": "key",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "One page of CSV data",
            "headers": {
              "X-Next-Cursor": {
                "description": "Pass as before on the next request.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{project}/balance-alert": {
      "get": {
        "operationId": "getBalanceAlert",
        "x-required-permission": "alerts",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Alert"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateBalanceAlert",
        "x-required-permission": "alerts",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AlertChange"
              }
            }
          }
        }
      }
    },
    "/projects/{project}/webhooks": {
      "get": {
        "operationId": "listProjectWebhooks",
        "summary": "List project webhooks",
        "x-required-permission": "webhooks",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 25
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookList"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createProjectWebhook",
        "summary": "Create and verify a webhook",
        "x-required-permission": "webhooks",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookReceipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Install a receiver before creating the subscription. Save signing_secret once. An authenticated webhook.verify acknowledgment is required before delivering project events.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewWebhook"
              }
            }
          }
        }
      }
    },
    "/projects/{project}/webhooks/{webhook}": {
      "patch": {
        "operationId": "revokeProjectWebhook",
        "summary": "Revoke a webhook",
        "x-required-permission": "webhooks",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "webhook",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookReceipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "const": "revoke"
                  }
                },
                "required": [
                  "action"
                ],
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/projects/{project}/webhooks/{webhook}/deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "summary": "Read webhook delivery history",
        "x-required-permission": "webhooks",
        "parameters": [
          {
            "name": "project",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "webhook",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 25
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryList"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/team/members": {
      "get": {
        "operationId": "listMembers",
        "x-required-permission": "team",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamMemberPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/team/members/{user}": {
      "patch": {
        "operationId": "updateMember",
        "x-required-permission": "team",
        "parameters": [
          {
            "name": "user",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemberChange"
              }
            }
          }
        }
      }
    },
    "/team/invitations": {
      "get": {
        "operationId": "listInvitations",
        "x-required-permission": "team",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvitationPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "changeInvitation",
        "x-required-permission": "team",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvitationChange"
              }
            }
          }
        }
      }
    },
    "/support/tickets": {
      "get": {
        "operationId": "listTickets",
        "x-required-permission": "support",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            },
            "required": false
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicketPage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTicket",
        "x-required-permission": "support",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTicket"
              }
            }
          }
        }
      }
    },
    "/support/tickets/{ticket}": {
      "get": {
        "operationId": "getTicket",
        "x-required-permission": "support",
        "parameters": [
          {
            "name": "ticket",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportTicket"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "resolveTicket",
        "x-required-permission": "support",
        "parameters": [
          {
            "name": "ticket",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResolveTicket"
              }
            }
          }
        }
      }
    },
    "/support/tickets/{ticket}/messages": {
      "get": {
        "operationId": "listMessages",
        "x-required-permission": "support",
        "parameters": [
          {
            "name": "ticket",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 25
            },
            "required": false
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessagePage"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "replyToTicket",
        "x-required-permission": "support",
        "parameters": [
          {
            "name": "ticket",
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TicketMessage"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ManagementToken": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Workspace": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tier": {
            "const": "reseller"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "scopes": {
            "type": "array",
            "items": {
              "enum": [
                "read",
                "projects",
                "keys",
                "transfers",
                "billing",
                "alerts",
                "team",
                "support",
                "webhooks"
              ]
            }
          }
        },
        "required": [
          "id",
          "tier",
          "expires_at",
          "scopes"
        ],
        "additionalProperties": false
      },
      "Project": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "archived": {
            "type": "boolean"
          },
          "currency": {
            "const": "USD"
          },
          "monthly_budget_usd": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
              },
              {
                "type": "null"
              }
            ]
          },
          "posted_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "held_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "available_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          }
        },
        "required": [
          "id",
          "name",
          "archived",
          "currency",
          "monthly_budget_usd",
          "posted_usd",
          "held_usd",
          "available_usd"
        ],
        "additionalProperties": false
      },
      "Key": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "prefix": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "monthly_budget_usd": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "name",
          "active",
          "prefix",
          "monthly_budget_usd"
        ],
        "additionalProperties": false
      },
      "Request": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "key_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "model": {
            "type": "string"
          },
          "protocol": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "state": {
            "type": "string"
          },
          "charge_usd": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
              },
              {
                "type": "null"
              }
            ]
          },
          "outcome": {
            "enum": [
              "succeeded",
              "failed",
              "unknown",
              "pending"
            ]
          },
          "tokens": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "input": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "output": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cache_read": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cache_write_5m": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cache_write_1h": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "images": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "audio_duration_seconds": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "project_id",
          "model",
          "protocol",
          "created_at",
          "state",
          "charge_usd",
          "outcome"
        ],
        "additionalProperties": false
      },
      "Usage": {
        "type": "object",
        "properties": {
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "key_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "days": {
            "type": "integer"
          },
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "to": {
            "type": "string",
            "format": "date-time"
          },
          "currency": {
            "const": "USD"
          },
          "settled_requests": {
            "type": "integer"
          },
          "charge_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          }
        },
        "required": [
          "project_id",
          "key_id",
          "days",
          "from",
          "to",
          "currency",
          "settled_requests",
          "charge_usd"
        ],
        "additionalProperties": false
      },
      "ProjectPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Project"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "KeyPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Key"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "RequestPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Request"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "Named": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "monthly_budget_usd": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false
      },
      "ProjectPatch": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "update"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "monthly_budget_usd": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "action",
              "name"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "archive"
              }
            },
            "required": [
              "action"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "restore"
              }
            },
            "required": [
              "action"
            ],
            "additionalProperties": false
          }
        ]
      },
      "KeyPatch": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "update"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "monthly_budget_usd": {
                "anyOf": [
                  {
                    "type": "string",
                    "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "action",
              "name"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "revoke"
              }
            },
            "required": [
              "action"
            ],
            "additionalProperties": false
          }
        ]
      },
      "Transfer": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "format": "uuid"
          },
          "destination": {
            "type": "string",
            "format": "uuid"
          },
          "amount_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          }
        },
        "required": [
          "source",
          "destination",
          "amount_usd"
        ],
        "additionalProperties": false
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "replayed"
        ],
        "additionalProperties": false
      },
      "KeyReceipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "replayed": {
            "type": "boolean"
          },
          "key": {
            "type": "string",
            "description": "Only returned on the original successful response."
          }
        },
        "required": [
          "id",
          "replayed"
        ],
        "additionalProperties": false
      },
      "TransferReceipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "amount_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "amount_usd",
          "replayed"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "EffectiveModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "currency": {
            "const": "USD"
          },
          "pricing_tier": {
            "type": "string"
          },
          "input_modalities": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "output_modalities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "protocols": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "pricing": {
            "type": "object",
            "description": "Effective customer rates; unit and applicable options vary by modality."
          },
          "limits": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ]
          },
          "context_length": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "max_output_tokens": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "min_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "max_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "pricing",
          "protocols"
        ],
        "additionalProperties": false
      },
      "PaymentMethods": {
        "type": "object",
        "properties": {
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "methods": {
            "type": "array",
            "items": {
              "enum": [
                "card_rub",
                "sbp",
                "crypto",
                "card_eur",
                "card_usd",
                "apple_pay_eur",
                "apple_pay_usd",
                "paypal_eur",
                "paypal_usd"
              ]
            }
          }
        },
        "required": [
          "project_id",
          "methods"
        ],
        "additionalProperties": false
      },
      "Topup": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "enum": [
              "credited",
              "expired",
              "cancelled",
              "failed",
              "cancelling",
              "awaiting_payment",
              "pending_review",
              "processing"
            ]
          },
          "gross_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "fee_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "credit_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "currency": {
            "const": "USD"
          }
        },
        "required": [
          "id",
          "project_id",
          "status",
          "gross_usd",
          "fee_usd",
          "credit_usd"
        ],
        "additionalProperties": false
      },
      "DailyUsage": {
        "type": "object",
        "properties": {
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "key_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "days": {
            "type": "integer"
          },
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "to": {
            "type": "string",
            "format": "date-time"
          },
          "currency": {
            "const": "USD"
          },
          "settled_requests": {
            "type": "integer"
          },
          "charge_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "daily": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "charge_usd": {
                  "type": "string",
                  "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
                },
                "settled_requests": {
                  "type": "integer"
                }
              },
              "required": [
                "date",
                "charge_usd",
                "settled_requests"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "project_id",
          "key_id",
          "days",
          "from",
          "to",
          "currency",
          "settled_requests",
          "charge_usd",
          "daily"
        ],
        "additionalProperties": false
      },
      "AlertChange": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "threshold_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
          },
          "email": {
            "type": "boolean"
          },
          "telegram": {
            "type": "boolean"
          }
        },
        "required": [
          "enabled",
          "threshold_usd",
          "email",
          "telegram"
        ],
        "additionalProperties": false
      },
      "Alert": {
        "type": "object",
        "properties": {
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "channels": {
            "type": "object",
            "properties": {
              "email": {
                "type": "boolean"
              },
              "telegram": {
                "type": "boolean"
              }
            },
            "required": [
              "email",
              "telegram"
            ],
            "additionalProperties": false
          },
          "preference": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "threshold_usd": {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]{1,6})?$"
              },
              "email": {
                "type": "boolean"
              },
              "telegram": {
                "type": "boolean"
              },
              "last_notification_at": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "enabled",
              "threshold_usd",
              "email",
              "telegram",
              "last_notification_at"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "project_id",
          "channels",
          "preference"
        ],
        "additionalProperties": false
      },
      "TeamMember": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email",
                "maxLength": 254
              },
              {
                "type": "null"
              }
            ]
          },
          "role": {
            "enum": [
              "owner",
              "admin",
              "developer",
              "billing",
              "viewer"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "role"
        ],
        "additionalProperties": false
      },
      "Invitation": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "role": {
            "enum": [
              "admin",
              "developer",
              "billing",
              "viewer"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "email",
          "role",
          "expires_at"
        ],
        "additionalProperties": false
      },
      "InvitationChange": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "invite"
              },
              "email": {
                "type": "string",
                "format": "email",
                "maxLength": 254
              },
              "role": {
                "enum": [
                  "admin",
                  "developer",
                  "billing",
                  "viewer"
                ]
              }
            },
            "required": [
              "action",
              "email",
              "role"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "cancel"
              },
              "email": {
                "type": "string",
                "format": "email",
                "maxLength": 254
              }
            },
            "required": [
              "action",
              "email"
            ],
            "additionalProperties": false
          }
        ]
      },
      "MemberChange": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "role"
              },
              "role": {
                "enum": [
                  "admin",
                  "developer",
                  "billing",
                  "viewer"
                ]
              }
            },
            "required": [
              "action",
              "role"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "action": {
                "const": "remove"
              }
            },
            "required": [
              "action"
            ],
            "additionalProperties": false
          }
        ]
      },
      "SupportTicket": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "subject": {
            "type": "string"
          },
          "status": {
            "enum": [
              "open",
              "awaiting_customer",
              "resolved"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "subject",
          "status"
        ],
        "additionalProperties": false
      },
      "SupportMessage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "staff": {
            "type": "boolean"
          },
          "body": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "staff",
          "body",
          "created_at"
        ],
        "additionalProperties": false
      },
      "CreateTicket": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 180
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 10000
          }
        },
        "required": [
          "subject",
          "body"
        ],
        "additionalProperties": false
      },
      "TicketMessage": {
        "type": "object",
        "properties": {
          "body": {
            "type": "string",
            "minLength": 1,
            "maxLength": 10000
          }
        },
        "required": [
          "body"
        ],
        "additionalProperties": false
      },
      "ResolveTicket": {
        "type": "object",
        "properties": {
          "action": {
            "const": "resolve"
          }
        },
        "required": [
          "action"
        ],
        "additionalProperties": false
      },
      "EffectiveModelPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EffectiveModel"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "TopupPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Topup"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "TeamMemberPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamMember"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "InvitationPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Invitation"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "SupportTicketPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportTicket"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "SupportMessagePage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportMessage"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "LiveModelLimit": {
        "type": "object",
        "required": [
          "model",
          "concurrent",
          "in_use"
        ],
        "properties": {
          "model": {
            "type": "string"
          },
          "concurrent": {
            "type": "integer",
            "minimum": 1
          },
          "in_use": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "LiveWorkspaceLimit": {
        "type": "object",
        "required": [
          "concurrent",
          "in_use",
          "requests_per_minute",
          "starts_last_minute",
          "expires_unix"
        ],
        "properties": {
          "concurrent": {
            "type": "integer",
            "minimum": 1
          },
          "in_use": {
            "type": "integer",
            "minimum": 0
          },
          "requests_per_minute": {
            "type": "integer",
            "minimum": 1
          },
          "starts_last_minute": {
            "type": "integer",
            "minimum": 0
          },
          "expires_unix": {
            "type": "integer",
            "minimum": 1
          }
        },
        "additionalProperties": false
      },
      "ProjectModelLimits": {
        "type": "object",
        "required": [
          "sampled_at_unix",
          "default_model_concurrent",
          "project_in_use",
          "workspace",
          "models",
          "next_cursor"
        ],
        "properties": {
          "sampled_at_unix": {
            "type": "integer",
            "minimum": 1
          },
          "default_model_concurrent": {
            "type": "integer",
            "minimum": 1
          },
          "project_in_use": {
            "type": "integer",
            "minimum": 0
          },
          "workspace": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LiveWorkspaceLimit"
              },
              {
                "type": "null"
              }
            ]
          },
          "models": {
            "type": "array",
            "maxItems": 24,
            "items": {
              "$ref": "#/components/schemas/LiveModelLimit"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "ReconciliationRow": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "model": {
            "type": "string"
          },
          "key_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "settled_requests": {
            "type": "integer",
            "minimum": 0
          },
          "charge_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]+)?$"
          },
          "input_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "cache_read_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "cache_write_5m_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "cache_write_1h_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "images": {
            "type": "integer",
            "minimum": 0
          },
          "audio_seconds": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]+)?$"
          }
        },
        "required": [
          "date",
          "model",
          "key_id",
          "settled_requests",
          "charge_usd",
          "input_tokens",
          "output_tokens",
          "cache_read_tokens",
          "cache_write_5m_tokens",
          "cache_write_1h_tokens",
          "images",
          "audio_seconds"
        ],
        "additionalProperties": false
      },
      "Reconciliation": {
        "type": "object",
        "properties": {
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "to": {
            "type": "string",
            "format": "date-time"
          },
          "sampled_at": {
            "type": "string",
            "format": "date-time"
          },
          "currency": {
            "const": "USD"
          },
          "key_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          },
          "model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "settled_requests": {
            "type": "integer",
            "minimum": 0
          },
          "charge_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]+)?$"
          },
          "rows": {
            "type": "array",
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/ReconciliationRow"
            }
          }
        },
        "required": [
          "project_id",
          "from",
          "to",
          "sampled_at",
          "currency",
          "key_id",
          "model",
          "settled_requests",
          "charge_usd",
          "rows"
        ],
        "additionalProperties": false
      },
      "NewWebhook": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "balance.low",
                "capacity.high",
                "topup.credited"
              ]
            }
          },
          "balance_below_usd": {
            "type": "string",
            "pattern": "^[0-9]+(\\.[0-9]+)?$"
          },
          "capacity": {
            "type": "object",
            "properties": {
              "percent": {
                "type": "integer",
                "minimum": 1,
                "maximum": 100
              },
              "models": {
                "type": "array",
                "minItems": 1,
                "maxItems": 16,
                "uniqueItems": true,
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "percent",
              "models"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "url",
          "events"
        ],
        "additionalProperties": false
      },
      "WebhookReceipt": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "replayed": {
            "type": "boolean"
          },
          "signing_secret": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "replayed"
        ],
        "additionalProperties": false
      },
      "ProjectWebhook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "project_id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "balance.low",
                "capacity.high",
                "topup.credited"
              ]
            }
          },
          "balance_below_usd": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[0-9]+(\\.[0-9]+)?$"
              },
              {
                "type": "null"
              }
            ]
          },
          "capacity": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "percent": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  },
                  "models": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 16,
                    "uniqueItems": true,
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "percent",
                  "models"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "inactive",
              "revoked"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "verified_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "project_id",
          "url",
          "events",
          "balance_below_usd",
          "capacity",
          "state",
          "created_at",
          "verified_at"
        ],
        "additionalProperties": false
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "webhook.verify",
              "balance.low",
              "capacity.high",
              "topup.credited"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "queued",
              "delivered",
              "failed",
              "skipped"
            ]
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "last_http_status": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "type",
          "state",
          "attempts",
          "last_http_status",
          "created_at",
          "completed_at"
        ],
        "additionalProperties": false
      },
      "WebhookList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 25,
            "items": {
              "$ref": "#/components/schemas/ProjectWebhook"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "WebhookDeliveryList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 25,
            "items": {
              "$ref": "#/components/schemas/WebhookDelivery"
            }
          },
          "next_cursor": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "WebhookEnvelope": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "webhook.verify",
              "balance.low",
              "capacity.high",
              "topup.credited"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object"
          }
        },
        "required": [
          "id",
          "type",
          "created_at",
          "data"
        ],
        "additionalProperties": false
      }
    }
  },
  "webhooks": {
    "projectEvent": {
      "post": {
        "summary": "Project event sent to the verified receiver",
        "security": [],
        "parameters": [
          {
            "name": "X-Quanteex-Event-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "X-Quanteex-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEnvelope"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Processed, or already processed. For verification return the proof header.",
            "headers": {
              "X-Quanteex-Webhook-Proof": {
                "schema": {
                  "type": "string"
                },
                "description": "Required for webhook.verify: lowercase HMAC-SHA256 hex of verify.<id> using the secret string."
              }
            }
          }
        }
      }
    }
  }
}
