{
  "openapi": "3.1.0",
  "info": {
    "title": "Nexora Enterprise API",
    "version": "1.0.0",
    "description": "Customer organisation accounts, scoped API keys, metered sales reporting and support triage. Starter implementation with manual billing and one administrator service credential."
  },
  "servers": [
    {
      "url": "/",
      "description": "The Worker serving this specification"
    }
  ],
  "components": {
    "securitySchemes": {
      "CustomerBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "nx_live_\u2026"
      },
      "AdminBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Server-configured administrator token. Keep private."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "request_id": {
                "type": "string",
                "format": "uuid"
              },
              "details": {}
            },
            "required": [
              "code",
              "message",
              "request_id"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "SalesTransaction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000.0,
            "multipleOf": 0.01
          },
          "cost": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000000.0,
            "multipleOf": 0.01
          },
          "category": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          }
        },
        "required": [
          "id",
          "date",
          "amount",
          "cost"
        ],
        "additionalProperties": false
      },
      "SalesRequest": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$"
          },
          "transactions": {
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "items": {
              "$ref": "#/components/schemas/SalesTransaction"
            }
          }
        },
        "required": [
          "currency",
          "transactions"
        ],
        "additionalProperties": false
      },
      "TriageRequest": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 8000
          },
          "mode": {
            "type": "string",
            "enum": [
              "rules",
              "ai"
            ],
            "default": "rules"
          }
        },
        "required": [
          "subject",
          "message"
        ],
        "additionalProperties": false
      },
      "CreateTenant": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "owner_email": {
            "type": "string",
            "format": "email",
            "maxLength": 254
          },
          "plan": {
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "enterprise"
            ],
            "default": "starter"
          }
        },
        "required": [
          "name",
          "owner_email"
        ],
        "additionalProperties": false
      },
      "UpdateTenant": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "enterprise"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended"
            ]
          },
          "monthly_limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000000
          },
          "ai_limit": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000
          },
          "rpm": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000
          }
        },
        "required": [],
        "additionalProperties": false,
        "minProperties": 1
      },
      "CreateKey": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "usage:read",
                "sales:analyze",
                "support:triage"
              ]
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "expires_in_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 365,
            "default": 90
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false
      },
      "UsageTotals": {
        "type": "object",
        "properties": {
          "requests": {
            "type": "integer",
            "minimum": 0
          },
          "ai_requests": {
            "type": "integer",
            "minimum": 0
          },
          "input_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "requests",
          "ai_requests",
          "input_tokens",
          "output_tokens"
        ],
        "additionalProperties": false
      },
      "Tenant": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "owner_email": {
            "type": "string"
          },
          "plan": {
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "enterprise"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended"
            ]
          },
          "monthly_limit": {
            "type": "integer",
            "minimum": 0
          },
          "ai_limit": {
            "type": "integer",
            "minimum": 0
          },
          "rpm": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "owner_email",
          "plan",
          "status",
          "monthly_limit",
          "ai_limit",
          "rpm",
          "created_at"
        ],
        "additionalProperties": false
      },
      "KeyMetadata": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "usage:read",
                "sales:analyze",
                "support:triage"
              ]
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "scopes",
          "expires_at",
          "revoked_at",
          "created_at"
        ],
        "additionalProperties": false
      },
      "TriageData": {
        "type": "object",
        "properties": {
          "category": {
            "type": "string",
            "enum": [
              "billing",
              "technical",
              "account",
              "general"
            ]
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "normal",
              "high",
              "urgent"
            ]
          },
          "summary": {
            "type": "string"
          },
          "suggested_response": {
            "type": "string"
          },
          "recommended_team": {
            "type": "string",
            "enum": [
              "finance",
              "account_support",
              "technical_support",
              "customer_support"
            ]
          },
          "engine": {
            "type": "string",
            "enum": [
              "rules",
              "ai"
            ]
          },
          "requires_human_review": {
            "type": "boolean",
            "const": true
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "category",
          "priority",
          "summary",
          "suggested_response",
          "recommended_team",
          "engine",
          "requires_human_review",
          "note"
        ],
        "additionalProperties": false
      },
      "SalesData": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string"
          },
          "transaction_count": {
            "type": "integer",
            "minimum": 0
          },
          "total_revenue": {
            "type": "number"
          },
          "total_cost": {
            "type": "number"
          },
          "gross_profit": {
            "type": "number"
          },
          "gross_margin_percent": {
            "type": [
              "number",
              "null"
            ]
          },
          "average_transaction_value": {
            "type": "number"
          },
          "period": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              }
            },
            "required": [
              "from",
              "to"
            ],
            "additionalProperties": false
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "category": {
                  "type": "string"
                },
                "revenue": {
                  "type": "number"
                },
                "cost": {
                  "type": "number"
                },
                "gross_profit": {
                  "type": "number"
                },
                "transactions": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "required": [
                "category",
                "revenue",
                "cost",
                "gross_profit",
                "transactions"
              ],
              "additionalProperties": false
            }
          },
          "daily_revenue": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "revenue": {
                  "type": "number"
                }
              },
              "required": [
                "date",
                "revenue"
              ],
              "additionalProperties": false
            }
          },
          "method": {
            "type": "string"
          }
        },
        "required": [
          "currency",
          "transaction_count",
          "total_revenue",
          "total_cost",
          "gross_profit",
          "gross_margin_percent",
          "average_transaction_value",
          "period",
          "categories",
          "daily_revenue",
          "method"
        ],
        "additionalProperties": false
      },
      "PlanLimits": {
        "type": "object",
        "properties": {
          "monthly_limit": {
            "type": "integer",
            "minimum": 0
          },
          "ai_limit": {
            "type": "integer",
            "minimum": 0
          },
          "rpm": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "monthly_limit",
          "ai_limit",
          "rpm"
        ],
        "additionalProperties": false
      },
      "Account": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "owner_email": {
            "type": "string"
          },
          "plan": {
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "enterprise"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended"
            ]
          },
          "monthly_limit": {
            "type": "integer",
            "minimum": 0
          },
          "ai_limit": {
            "type": "integer",
            "minimum": 0
          },
          "rpm": {
            "type": "integer",
            "minimum": 0
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "usage:read",
                "sales:analyze",
                "support:triage"
              ]
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "key_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "ai_enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "name",
          "owner_email",
          "plan",
          "status",
          "monthly_limit",
          "ai_limit",
          "rpm",
          "scopes",
          "key_expires_at",
          "ai_enabled"
        ],
        "additionalProperties": false
      },
      "TenantUsage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "owner_email": {
            "type": "string"
          },
          "plan": {
            "type": "string",
            "enum": [
              "starter",
              "growth",
              "enterprise"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended"
            ]
          },
          "monthly_limit": {
            "type": "integer",
            "minimum": 0
          },
          "ai_limit": {
            "type": "integer",
            "minimum": 0
          },
          "rpm": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "requests": {
            "type": "integer",
            "minimum": 0
          },
          "ai_requests": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "id",
          "name",
          "owner_email",
          "plan",
          "status",
          "monthly_limit",
          "ai_limit",
          "rpm",
          "created_at",
          "requests",
          "ai_requests"
        ],
        "additionalProperties": false
      },
      "KeyReveal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "usage:read",
                "sales:analyze",
                "support:triage"
              ]
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "tenant_id": {
            "type": "string"
          },
          "secret": {
            "type": "string",
            "description": "Shown once; do not log."
          },
          "notice": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "scopes",
          "expires_at",
          "created_at",
          "tenant_id",
          "secret",
          "notice"
        ],
        "additionalProperties": false
      },
      "RequestLog": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "duration_ms": {
            "type": "integer",
            "minimum": 0
          },
          "units": {
            "type": "integer",
            "minimum": 0
          },
          "ai_units": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "endpoint",
          "status",
          "duration_ms",
          "units",
          "ai_units",
          "created_at"
        ],
        "additionalProperties": false
      },
      "DailyUsage": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "requests": {
            "type": "integer",
            "minimum": 0
          },
          "ai_requests": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "date",
          "requests",
          "ai_requests"
        ],
        "additionalProperties": false
      },
      "CustomerUsage": {
        "type": "object",
        "properties": {
          "month": {
            "type": "string"
          },
          "totals": {
            "$ref": "#/components/schemas/UsageTotals"
          },
          "limits": {
            "$ref": "#/components/schemas/PlanLimits"
          },
          "recent_requests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RequestLog"
            }
          },
          "daily": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyUsage"
            }
          },
          "log_retention_days": {
            "type": "integer",
            "minimum": 0
          },
          "current_month": {
            "type": "string"
          }
        },
        "required": [
          "month",
          "totals",
          "limits",
          "recent_requests",
          "daily",
          "log_retention_days",
          "current_month"
        ],
        "additionalProperties": false
      },
      "AdminUsage": {
        "type": "object",
        "properties": {
          "tenant_id": {
            "type": "string"
          },
          "month": {
            "type": "string"
          },
          "totals": {
            "$ref": "#/components/schemas/UsageTotals"
          },
          "limits": {
            "type": "object",
            "properties": {
              "monthly_limit": {
                "type": "integer",
                "minimum": 0
              },
              "ai_limit": {
                "type": "integer",
                "minimum": 0
              },
              "rpm": {
                "type": "integer",
                "minimum": 0
              },
              "id": {
                "type": "string"
              }
            },
            "required": [
              "monthly_limit",
              "ai_limit",
              "rpm",
              "id"
            ],
            "additionalProperties": false
          },
          "recent_requests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RequestLog"
            }
          },
          "daily": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyUsage"
            }
          },
          "log_retention_days": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "tenant_id",
          "month",
          "totals",
          "limits",
          "recent_requests",
          "daily",
          "log_retention_days"
        ],
        "additionalProperties": false
      },
      "AuditEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "tenant_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "actor": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "target_id": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "tenant_id",
          "actor",
          "action",
          "target_id",
          "created_at"
        ],
        "additionalProperties": false
      },
      "AdminOverview": {
        "type": "object",
        "properties": {
          "month": {
            "type": "string"
          },
          "customers": {
            "type": "integer",
            "minimum": 0
          },
          "active_customers": {
            "type": "integer",
            "minimum": 0
          },
          "requests": {
            "type": "integer",
            "minimum": 0
          },
          "ai_requests": {
            "type": "integer",
            "minimum": 0
          },
          "input_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "daily": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyUsage"
            }
          },
          "recent_requests": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "endpoint": {
                  "type": "string"
                },
                "status": {
                  "type": "integer"
                },
                "duration_ms": {
                  "type": "integer",
                  "minimum": 0
                },
                "units": {
                  "type": "integer",
                  "minimum": 0
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "tenant_name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "endpoint",
                "status",
                "duration_ms",
                "units",
                "created_at",
                "tenant_name"
              ],
              "additionalProperties": false
            }
          },
          "ai_enabled": {
            "type": "boolean"
          },
          "billing": {
            "type": "string",
            "const": "manual"
          }
        },
        "required": [
          "month",
          "customers",
          "active_customers",
          "requests",
          "ai_requests",
          "input_tokens",
          "output_tokens",
          "daily",
          "recent_requests",
          "ai_enabled",
          "billing"
        ],
        "additionalProperties": false
      }
    }
  },
  "paths": {
    "/health": {
      "get": {
        "operationId": "get_health",
        "summary": "Database-backed health check",
        "tags": [
          "Public"
        ],
        "description": "",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "service": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "service",
                    "version",
                    "status",
                    "request_id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/plans": {
      "get": {
        "operationId": "get_v1_plans",
        "summary": "Technical plan allowances",
        "tags": [
          "Public"
        ],
        "description": "",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "monthly_limit": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "ai_limit": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "rpm": {
                            "type": "integer",
                            "minimum": 0
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "monthly_limit",
                          "ai_limit",
                          "rpm"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "billing": {
                      "type": "string"
                    },
                    "reset": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data",
                    "billing",
                    "reset"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/me": {
      "get": {
        "operationId": "get_v1_me",
        "summary": "Account identity and key scopes",
        "tags": [
          "Customer"
        ],
        "description": "Requires usage:read. Account is derived solely from the customer key.",
        "security": [
          {
            "CustomerBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Account"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "get_v1_usage",
        "summary": "Own monthly usage and recent metadata",
        "tags": [
          "Customer"
        ],
        "description": "Requires usage:read. Logs cover the most recent 30 days. Monthly counters are authoritative.",
        "security": [
          {
            "CustomerBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CustomerUsage"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "month",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^20[0-9]{2}-(0[1-9]|1[0-2])$"
            }
          }
        ]
      }
    },
    "/v1/sales/summary": {
      "post": {
        "operationId": "post_v1_sales_summary",
        "summary": "Summarise sales transactions",
        "tags": [
          "Customer"
        ],
        "description": "Requires sales:analyze. Consumes one unit after validation. No tax calculation, currency conversion, or payload storage.",
        "security": [
          {
            "CustomerBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/SalesData"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SalesRequest"
              }
            }
          }
        }
      }
    },
    "/v1/support/triage": {
      "post": {
        "operationId": "post_v1_support_triage",
        "summary": "Classify a ticket and draft a reply",
        "tags": [
          "Customer"
        ],
        "description": "Requires support:triage. Rules mode needs no provider. AI mode needs server configuration and an AI allowance. Admitted AI attempts remain counted if the provider fails. Human review is always required.",
        "security": [
          {
            "CustomerBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/TriageData"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TriageRequest"
              }
            }
          }
        }
      }
    },
    "/admin/overview": {
      "get": {
        "operationId": "get_admin_overview",
        "summary": "Overall client and usage counters",
        "tags": [
          "Administration"
        ],
        "description": "",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AdminOverview"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/admin/tenants": {
      "get": {
        "operationId": "get_admin_tenants",
        "summary": "List customer organisations",
        "tags": [
          "Administration"
        ],
        "description": "",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TenantUsage"
                      }
                    },
                    "next_offset": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "month": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "request_id",
                    "data",
                    "next_offset",
                    "month"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      },
      "post": {
        "operationId": "post_admin_tenants",
        "summary": "Create a customer and a single-reveal initial key",
        "tags": [
          "Administration"
        ],
        "description": "The initial key has all service scopes and expires in 90 days. No email is sent and no payment is collected.",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "tenant": {
                          "$ref": "#/components/schemas/Tenant"
                        },
                        "key": {
                          "$ref": "#/components/schemas/KeyReveal"
                        }
                      },
                      "required": [
                        "tenant",
                        "key"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTenant"
              }
            }
          }
        }
      }
    },
    "/admin/tenants/{tenant_id}": {
      "patch": {
        "operationId": "patch_admin_tenants_tenant_id",
        "summary": "Update plan, status, or Enterprise limits",
        "tags": [
          "Administration"
        ],
        "description": "Custom limits require Enterprise. AI limit may not exceed processing limit. Existing usage is preserved.",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Tenant"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTenant"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "tenant_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/admin/tenants/{tenant_id}/keys": {
      "get": {
        "operationId": "get_admin_tenants_tenant_id_keys",
        "summary": "List safe key metadata",
        "tags": [
          "Administration"
        ],
        "description": "",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/KeyMetadata"
                      }
                    },
                    "next_offset": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "request_id",
                    "data",
                    "next_offset"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "tenant_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      },
      "post": {
        "operationId": "post_admin_tenants_tenant_id_keys",
        "summary": "Create a scoped, expiring single-reveal key",
        "tags": [
          "Administration"
        ],
        "description": "",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/KeyReveal"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateKey"
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "tenant_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/admin/tenants/{tenant_id}/keys/{key_id}/revoke": {
      "post": {
        "operationId": "post_admin_tenants_tenant_id_keys_key_id_revoke",
        "summary": "Revoke a key belonging to this organisation",
        "tags": [
          "Administration"
        ],
        "description": "Idempotent. In-flight requests already admitted may finish.",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "revoked_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "id",
                        "revoked_at"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "tenant_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "key_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/admin/usage": {
      "get": {
        "operationId": "get_admin_usage",
        "summary": "Read one customer's monthly usage",
        "tags": [
          "Administration"
        ],
        "description": "",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AdminUsage"
                    }
                  },
                  "required": [
                    "request_id",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "tenant_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "month",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^20[0-9]{2}-(0[1-9]|1[0-2])$"
            }
          }
        ]
      }
    },
    "/admin/audit": {
      "get": {
        "operationId": "get_admin_audit",
        "summary": "List administrative events",
        "tags": [
          "Administration"
        ],
        "description": "",
        "security": [
          {
            "AdminBearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-ID": {
                "description": "Correlation ID",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Limit": {
                "description": "Account fixed-minute limit, on authenticated customer routes",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Remaining fixed-minute requests",
                "schema": {
                  "type": "string"
                }
              },
              "X-RateLimit-Reset": {
                "description": "Next UTC minute as Unix seconds",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Limit": {
                "description": "Monthly processing allowance, after service admission",
                "schema": {
                  "type": "string"
                }
              },
              "X-Quota-Remaining": {
                "description": "Remaining monthly processing units, after admission",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AuditEvent"
                      }
                    },
                    "next_offset": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "request_id",
                    "data",
                    "next_offset"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Scope, account status, or browser origin denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body larger than 256 KiB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "AI provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Minute or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "AI provider failed or returned invalid output",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Service or configuration unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "AI provider timed out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1000000,
              "default": 0
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Public"
    },
    {
      "name": "Customer"
    },
    {
      "name": "Administration"
    }
  ]
}
