{
  "openapi": "3.1.0",
  "paths": {
    "/admin/v1/workspaces": {
      "post": {
        "operationId": "createWorkspace",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkspaceDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Create a workspace",
        "tags": [
          "Workspaces"
        ]
      },
      "get": {
        "operationId": "listWorkspaces",
        "parameters": [
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspaceDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List workspaces visible to the current management principal",
        "tags": [
          "Workspaces"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}": {
      "get": {
        "operationId": "getWorkspace",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Get a workspace",
        "tags": [
          "Workspaces"
        ]
      },
      "patch": {
        "operationId": "updateWorkspace",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkspaceDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Update a workspace",
        "tags": [
          "Workspaces"
        ]
      },
      "delete": {
        "operationId": "archiveWorkspace",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Archive a workspace",
        "tags": [
          "Workspaces"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/provider-connections": {
      "post": {
        "operationId": "createProviderConnection",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateProviderConnectionDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Connect an upstream provider and encrypted API key",
        "tags": [
          "Workspaces",
          "Provider Connections"
        ]
      },
      "get": {
        "operationId": "listProviderConnections",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProviderConnectionDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List provider connections",
        "tags": [
          "Workspaces",
          "Provider Connections"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/provider-connections/test": {
      "post": {
        "operationId": "testProviderConnection",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestProviderConnectionDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Test provider connectivity and credentials before saving",
        "tags": [
          "Workspaces",
          "Provider Connections"
        ]
      }
    },
    "/admin/v1/provider-connections/{providerConnectionId}": {
      "get": {
        "operationId": "getProviderConnection",
        "parameters": [
          {
            "name": "providerConnectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Get a provider connection without secret plaintext",
        "tags": [
          "Provider Connections"
        ]
      },
      "patch": {
        "operationId": "updateProviderConnection",
        "parameters": [
          {
            "name": "providerConnectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateProviderConnectionDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Update a provider connection",
        "tags": [
          "Provider Connections"
        ]
      },
      "delete": {
        "operationId": "archiveProviderConnection",
        "parameters": [
          {
            "name": "providerConnectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Archive a provider connection",
        "tags": [
          "Provider Connections"
        ]
      }
    },
    "/admin/v1/provider-connections/{providerConnectionId}/verify": {
      "post": {
        "operationId": "verifyProviderConnection",
        "parameters": [
          {
            "name": "providerConnectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Verify provider connectivity and credentials",
        "tags": [
          "Provider Connections"
        ]
      }
    },
    "/admin/v1/provider-connections/{providerConnectionId}/rotate-secret": {
      "post": {
        "operationId": "rotateProviderSecret",
        "parameters": [
          {
            "name": "providerConnectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RotateProviderSecretDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Rotate a provider API key",
        "tags": [
          "Provider Connections"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/plans": {
      "post": {
        "operationId": "createPlan",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkspacePlanDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspacePlanDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Create a workspace plan",
        "tags": [
          "Plans"
        ]
      },
      "get": {
        "operationId": "listPlans",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspacePlanDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List workspace plans",
        "tags": [
          "Plans"
        ]
      }
    },
    "/admin/v1/plans/{planId}": {
      "get": {
        "operationId": "getPlan",
        "parameters": [
          {
            "name": "planId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspacePlanDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Get a workspace plan and active strategy bindings",
        "tags": [
          "Plans"
        ]
      },
      "patch": {
        "operationId": "updatePlan",
        "parameters": [
          {
            "name": "planId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWorkspacePlanDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspacePlanDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Update a draft workspace plan",
        "tags": [
          "Plans"
        ]
      }
    },
    "/admin/v1/plans/{planId}/publish": {
      "post": {
        "operationId": "publishPlan",
        "parameters": [
          {
            "name": "planId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspacePlanDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Publish a plan after strategy validation",
        "tags": [
          "Plans"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/plan-strategies/quota": {
      "post": {
        "operationId": "createQuotaStrategy",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateQuotaStrategyDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuotaStrategyDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Create a versioned quota strategy",
        "tags": [
          "Plans",
          "Plan Strategies"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/plan-strategies": {
      "get": {
        "operationId": "listPlanStrategies",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuotaStrategyDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List plan strategies owned by a workspace",
        "tags": [
          "Plans",
          "Plan Strategies"
        ]
      }
    },
    "/admin/v1/plan-strategies/{strategyId}": {
      "get": {
        "operationId": "getPlanStrategy",
        "parameters": [
          {
            "name": "strategyId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuotaStrategyDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Get a strategy version",
        "tags": [
          "Plans",
          "Plan Strategies"
        ]
      }
    },
    "/admin/v1/plan-strategies/{strategyId}/publish": {
      "post": {
        "operationId": "publishPlanStrategy",
        "parameters": [
          {
            "name": "strategyId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuotaStrategyDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Publish an immutable strategy version",
        "tags": [
          "Plans",
          "Plan Strategies"
        ]
      }
    },
    "/admin/v1/plans/{planId}/strategy-bindings": {
      "post": {
        "operationId": "bindPlanStrategy",
        "parameters": [
          {
            "name": "planId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateStrategyBindingDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StrategyBindingDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Bind a strategy version to a plan from an effective time",
        "tags": [
          "Plans",
          "Plan Strategies"
        ]
      },
      "get": {
        "operationId": "listPlanStrategyBindings",
        "parameters": [
          {
            "name": "planId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StrategyBindingDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List current and historical strategy bindings",
        "tags": [
          "Plans",
          "Plan Strategies"
        ]
      }
    },
    "/admin/v1/plan-strategy-bindings/{bindingId}": {
      "delete": {
        "operationId": "closePlanStrategyBinding",
        "parameters": [
          {
            "name": "bindingId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Close a strategy binding at the requested effective time",
        "tags": [
          "Plans",
          "Plan Strategies"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/users": {
      "post": {
        "operationId": "provisionWorkspaceUser",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProvisionWorkspaceUserDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProvisionedWorkspaceUserDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Idempotently provision a Better Auth user and workspace access",
        "tags": [
          "Workspace Users"
        ]
      },
      "get": {
        "operationId": "listWorkspaceUsers",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WorkspaceAccessDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List users with data-plane access to a workspace",
        "tags": [
          "Workspace Users"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}": {
      "get": {
        "operationId": "getWorkspaceAccess",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAccessDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Get a workspace access",
        "tags": [
          "Workspace Users"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/plan": {
      "patch": {
        "operationId": "changeAccessPlan",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeAccessPlanDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAccessDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Change the plan bound to an access",
        "tags": [
          "Workspace Users"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/renew": {
      "post": {
        "operationId": "renewWorkspaceAccess",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenewAccessDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAccessDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Renew access and create the next quota period from active plan strategies",
        "tags": [
          "Workspace Users"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/suspend": {
      "post": {
        "operationId": "suspendWorkspaceAccess",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAccessDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Suspend new data-plane calls",
        "tags": [
          "Workspace Users"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/activate": {
      "post": {
        "operationId": "activateWorkspaceAccess",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAccessDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Activate a workspace access",
        "tags": [
          "Workspace Users"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/quota": {
      "get": {
        "operationId": "getWorkspaceAccessQuota",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuotaSnapshotDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Get the current quota snapshot",
        "tags": [
          "Workspace Users"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/api-keys": {
      "post": {
        "operationId": "createInferenceKey",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInferenceKeyDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedInferenceKeyDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Issue a Better Auth inference key; plaintext is returned once",
        "tags": [
          "Workspace Users",
          "Inference Keys"
        ]
      },
      "get": {
        "operationId": "listInferenceKeys",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiKeyDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List inference keys without plaintext",
        "tags": [
          "Workspace Users",
          "Inference Keys"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/api-keys/{keyId}": {
      "delete": {
        "operationId": "revokeInferenceKey",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "keyId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Revoke an inference key without changing plan or quota",
        "tags": [
          "Workspace Users",
          "Inference Keys"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/invocations": {
      "get": {
        "operationId": "listInvocations",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          },
          {
            "name": "workspaceAccessId",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "model",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InvocationDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List model invocations",
        "tags": [
          "Observability",
          "Usage"
        ]
      }
    },
    "/admin/v1/invocations/{invocationId}": {
      "get": {
        "operationId": "getInvocation",
        "parameters": [
          {
            "name": "invocationId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvocationDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Get an invocation, provider attempt and quota settlement",
        "tags": [
          "Observability",
          "Usage"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/usage-events": {
      "get": {
        "operationId": "listUsageEvents",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UsageEventDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List immutable usage and adjustment events",
        "tags": [
          "Observability",
          "Usage"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/audit-logs": {
      "get": {
        "operationId": "listAuditLogs",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AuditLogDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List control-plane audit logs",
        "tags": [
          "Observability",
          "Audit"
        ]
      }
    },
    "/admin/v1/workspaces/{workspaceId}/billing-connections": {
      "post": {
        "operationId": "createBillingConnection",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBillingConnectionDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Create a Stripe, Creem or app-sync connection",
        "tags": [
          "Billing Connections"
        ]
      },
      "get": {
        "operationId": "listBillingConnections",
        "parameters": [
          {
            "name": "workspaceId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BillingConnectionDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List billing connections",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-connections/{connectionId}/verify": {
      "post": {
        "operationId": "verifyBillingConnection",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Verify billing provider credentials",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-connections/{connectionId}/provider-credential": {
      "put": {
        "operationId": "configureBillingProviderCredential",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfigureBillingProviderCredentialDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Store or rotate a billing provider credential",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-connections/{connectionId}/webhook-secret": {
      "put": {
        "operationId": "configureBillingWebhookSecret",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfigureBillingWebhookSecretDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingConnectionDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Store or rotate a billing webhook signing secret",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-connections/{connectionId}": {
      "delete": {
        "operationId": "disableBillingConnection",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Disable a billing connection",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-connections/{connectionId}/product-mappings": {
      "post": {
        "operationId": "createBillingProductMapping",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateProductMappingDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Map an external Product/Price to a workspace plan",
        "tags": [
          "Billing Connections"
        ]
      },
      "get": {
        "operationId": "listBillingProductMappings",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List product mappings",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/billing-checkouts": {
      "post": {
        "operationId": "createCheckout",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Access-scoped Checkout retry key.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBillingCheckoutDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingCheckoutDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Create a provider-neutral hosted subscription Checkout",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-product-mappings/{mappingId}": {
      "delete": {
        "operationId": "deleteBillingProductMapping",
        "parameters": [
          {
            "name": "mappingId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Disable a product mapping",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/billing-periods/sync": {
      "post": {
        "operationId": "syncWorkspaceAccessBillingPeriod",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Workspace-scoped retry key.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SyncBillingPeriodDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceAccessDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Idempotently synchronize an external billing period",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/workspace-accesses/{accessId}/external-subscriptions": {
      "get": {
        "operationId": "listExternalSubscriptions",
        "parameters": [
          {
            "name": "accessId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalSubscriptionDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List external subscription projections",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-connections/{connectionId}/webhook-events": {
      "get": {
        "operationId": "listBillingWebhookEvents",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "List webhook inbox events",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/webhook-events/{eventId}/replay": {
      "post": {
        "operationId": "replayBillingWebhookEvent",
        "parameters": [
          {
            "name": "eventId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Replay a failed webhook inbox event",
        "tags": [
          "Billing Connections"
        ]
      }
    },
    "/admin/v1/billing-connections/{connectionId}/reconcile": {
      "post": {
        "operationId": "reconcileBillingConnection",
        "parameters": [
          {
            "name": "connectionId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "managementKey": []
          }
        ],
        "summary": "Start external subscription reconciliation",
        "tags": [
          "Billing Connections"
        ]
      }
    }
  },
  "info": {
    "title": "Nexus Admin API",
    "description": "Public control-plane contract for workspaces, providers, plans, strategies, users, access, usage and billing connectors.",
    "version": "1.0.0",
    "contact": {}
  },
  "tags": [],
  "servers": [
    {
      "url": "http://localhost:3000",
      "description": "Local development"
    },
    {
      "url": "https://nexus.microvoid.io",
      "description": "Production Console and Admin origin"
    }
  ],
  "components": {
    "securitySchemes": {
      "managementKey": {
        "scheme": "bearer",
        "bearerFormat": "Nexus Management Key",
        "type": "http",
        "description": "Better Auth management API key."
      },
      "idempotencyKey": {
        "type": "apiKey",
        "in": "header",
        "name": "Idempotency-Key",
        "description": "Required for retryable write commands."
      }
    },
    "schemas": {
      "CreateWorkspaceDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          }
        },
        "required": [
          "name",
          "slug"
        ]
      },
      "WorkspaceDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "ws_01J..."
          },
          "organizationId": {
            "type": "string",
            "example": "org_01J..."
          },
          "name": {
            "type": "string",
            "example": "Coding Agent Production"
          },
          "slug": {
            "type": "string",
            "example": "coding-agent-prod"
          },
          "status": {
            "enum": [
              "ACTIVE",
              "SUSPENDED",
              "ARCHIVED"
            ],
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "organizationId",
          "name",
          "slug",
          "status",
          "createdAt",
          "updatedAt"
        ]
      },
      "UpdateWorkspaceDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "SUSPENDED",
              "ARCHIVED"
            ]
          }
        }
      },
      "CreateProviderConnectionDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "protocolProfile": {
            "type": "string"
          },
          "baseUrl": {
            "type": "string",
            "format": "uri"
          },
          "apiKey": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "protocolProfile",
          "baseUrl",
          "apiKey"
        ]
      },
      "ProviderConnectionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "workspaceId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "example": "OpenRouter Production"
          },
          "gatewayBaseUrl": {
            "type": "string",
            "example": "https://gateway.nexus.microvoid.io/providers/533c4e1e-2823-4349-86b9-d6f1a869a2ca",
            "description": "Copy-ready SDK Base URL computed from the deployment Gateway origin and ProviderConnection ID.",
            "readOnly": true
          },
          "protocolProfile": {
            "type": "string",
            "example": "openai-compatible"
          },
          "baseUrl": {
            "type": "string",
            "example": "https://openrouter.ai/api/v1"
          },
          "status": {
            "enum": [
              "ACTIVE",
              "SUSPENDED",
              "ARCHIVED"
            ],
            "type": "string"
          },
          "secretPreview": {
            "type": "string",
            "example": "sk-or-...abcd"
          },
          "lastVerifiedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "name",
          "gatewayBaseUrl",
          "protocolProfile",
          "baseUrl",
          "status",
          "secretPreview"
        ]
      },
      "TestProviderConnectionDto": {
        "type": "object",
        "properties": {
          "protocolProfile": {
            "type": "string"
          },
          "baseUrl": {
            "type": "string",
            "format": "uri"
          },
          "apiKey": {
            "type": "string"
          }
        },
        "required": [
          "protocolProfile",
          "baseUrl",
          "apiKey"
        ]
      },
      "OperationResponseDto": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean"
          },
          "operationId": {
            "type": "string"
          }
        },
        "required": [
          "accepted"
        ]
      },
      "UpdateProviderConnectionDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "protocolProfile": {
            "type": "string"
          },
          "baseUrl": {
            "type": "string",
            "format": "uri"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "SUSPENDED",
              "ARCHIVED"
            ]
          }
        }
      },
      "RotateProviderSecretDto": {
        "type": "object",
        "properties": {
          "apiKey": {
            "type": "string"
          }
        },
        "required": [
          "apiKey"
        ]
      },
      "CreateWorkspacePlanDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "name": {
            "type": "string"
          },
          "billingInterval": {
            "type": "string",
            "enum": [
              "MONTH",
              "YEAR"
            ]
          }
        },
        "required": [
          "key",
          "name",
          "billingInterval"
        ]
      },
      "WorkspacePlanDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "plan_01J..."
          },
          "workspaceId": {
            "type": "string",
            "example": "ws_01J..."
          },
          "key": {
            "type": "string",
            "example": "pro"
          },
          "name": {
            "type": "string",
            "example": "Pro"
          },
          "billingInterval": {
            "enum": [
              "MONTH",
              "YEAR"
            ],
            "type": "string"
          },
          "status": {
            "enum": [
              "DRAFT",
              "ACTIVE",
              "ARCHIVED"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "key",
          "name",
          "billingInterval",
          "status"
        ]
      },
      "UpdateWorkspacePlanDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "name": {
            "type": "string"
          },
          "billingInterval": {
            "enum": [
              "MONTH",
              "YEAR"
            ],
            "type": "string"
          }
        }
      },
      "CreateQuotaStrategyDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "resetInterval": {
            "type": "string",
            "enum": [
              "MONTH",
              "YEAR"
            ]
          },
          "quotaUnits": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "inputMultiplierPpm": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "outputMultiplierPpm": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "cachedInputMultiplierPpm": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "maxOutputTokens": {
            "type": "number",
            "minimum": 1
          }
        },
        "required": [
          "key",
          "resetInterval",
          "quotaUnits",
          "inputMultiplierPpm",
          "outputMultiplierPpm",
          "cachedInputMultiplierPpm",
          "maxOutputTokens"
        ]
      },
      "QuotaStrategyDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "strategy_01J..."
          },
          "workspaceId": {
            "type": "string",
            "example": "ws_01J..."
          },
          "key": {
            "type": "string",
            "example": "pro-quota"
          },
          "version": {
            "type": "number",
            "example": 1
          },
          "type": {
            "type": "string",
            "enum": [
              "QUOTA"
            ],
            "example": "QUOTA"
          },
          "resetInterval": {
            "enum": [
              "MONTH",
              "YEAR"
            ],
            "type": "string"
          },
          "quotaUnits": {
            "type": "string",
            "example": "50000000",
            "description": "64-bit integer encoded as a decimal string."
          },
          "inputMultiplierPpm": {
            "type": "string",
            "example": "1000000"
          },
          "outputMultiplierPpm": {
            "type": "string",
            "example": "2000000"
          },
          "cachedInputMultiplierPpm": {
            "type": "string",
            "example": "200000"
          },
          "maxOutputTokens": {
            "type": "number",
            "example": 8192
          },
          "status": {
            "type": "string",
            "example": "PUBLISHED"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "key",
          "version",
          "type",
          "resetInterval",
          "quotaUnits",
          "inputMultiplierPpm",
          "outputMultiplierPpm",
          "cachedInputMultiplierPpm",
          "maxOutputTokens",
          "status"
        ]
      },
      "CreateStrategyBindingDto": {
        "type": "object",
        "properties": {
          "strategyId": {
            "type": "string"
          },
          "effectiveFrom": {
            "type": "string"
          }
        },
        "required": [
          "strategyId",
          "effectiveFrom"
        ]
      },
      "StrategyBindingDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "planId": {
            "type": "string"
          },
          "strategyId": {
            "type": "string"
          },
          "strategyType": {
            "type": "string",
            "enum": [
              "QUOTA"
            ]
          },
          "effectiveFrom": {
            "type": "string",
            "format": "date-time"
          },
          "effectiveTo": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "planId",
          "strategyId",
          "strategyType",
          "effectiveFrom"
        ]
      },
      "ProvisionWorkspaceUserDto": {
        "type": "object",
        "properties": {
          "externalUserId": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "planId": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "issueInferenceKey": {
            "type": "boolean"
          }
        },
        "required": [
          "externalUserId",
          "email",
          "planId"
        ]
      },
      "WorkspaceAccessDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "wsa_01J..."
          },
          "workspaceId": {
            "type": "string"
          },
          "userId": {
            "type": "string"
          },
          "externalUserId": {
            "type": "string",
            "example": "user_123"
          },
          "planId": {
            "type": "string"
          },
          "status": {
            "enum": [
              "PENDING",
              "ACTIVE",
              "SUSPENDED",
              "EXPIRED",
              "REVOKED"
            ],
            "type": "string"
          },
          "accessStartsAt": {
            "type": "string",
            "format": "date-time"
          },
          "accessEndsAt": {
            "type": "string",
            "format": "date-time"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "id",
          "workspaceId",
          "userId",
          "externalUserId",
          "planId",
          "status",
          "accessStartsAt"
        ]
      },
      "ProvisionedWorkspaceUserDto": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "workspaceAccess": {
            "$ref": "#/components/schemas/WorkspaceAccessDto"
          },
          "apiKey": {
            "type": "string",
            "description": "Returned only when a new key is issued. The plaintext is shown once."
          },
          "keyExpiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "quotaPeriodEndsAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "userId",
          "workspaceAccess"
        ]
      },
      "ChangeAccessPlanDto": {
        "type": "object",
        "properties": {
          "planId": {
            "type": "string"
          },
          "effectiveAt": {
            "type": "string"
          }
        },
        "required": [
          "planId"
        ]
      },
      "RenewAccessDto": {
        "type": "object",
        "properties": {
          "planId": {
            "type": "string"
          },
          "periodStart": {
            "type": "string"
          },
          "periodEnd": {
            "type": "string"
          }
        },
        "required": [
          "planId",
          "periodStart",
          "periodEnd"
        ]
      },
      "QuotaSnapshotDto": {
        "type": "object",
        "properties": {
          "workspaceAccessId": {
            "type": "string"
          },
          "planId": {
            "type": "string"
          },
          "quotaStrategyId": {
            "type": "string"
          },
          "quotaPeriodId": {
            "type": "string"
          },
          "grantedUnits": {
            "type": "string"
          },
          "reservedUnits": {
            "type": "string"
          },
          "consumedUnits": {
            "type": "string"
          },
          "availableUnits": {
            "type": "string"
          },
          "periodEnd": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "workspaceAccessId",
          "planId",
          "quotaStrategyId",
          "quotaPeriodId",
          "grantedUnits",
          "reservedUnits",
          "consumedUnits",
          "availableUnits",
          "periodEnd"
        ]
      },
      "CreateInferenceKeyDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "expiresInSeconds": {
            "type": "number",
            "minimum": 60
          }
        },
        "required": [
          "name",
          "expiresInSeconds"
        ]
      },
      "CreatedInferenceKeyDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastRequestAt": {
            "type": "string",
            "format": "date-time"
          },
          "enabled": {
            "type": "boolean"
          },
          "key": {
            "type": "string",
            "description": "Plaintext key, returned once."
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "expiresAt",
          "enabled",
          "key"
        ]
      },
      "ApiKeyDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastRequestAt": {
            "type": "string",
            "format": "date-time"
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "expiresAt",
          "enabled"
        ]
      },
      "InvocationAttemptDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "sequence": {
            "type": "number"
          },
          "providerConnectionId": {
            "type": "string"
          },
          "upstreamModel": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time"
          },
          "firstTokenAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          },
          "durationMs": {
            "type": "number"
          },
          "httpStatus": {
            "type": "number"
          },
          "errorCode": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "sequence",
          "providerConnectionId",
          "upstreamModel",
          "status",
          "startedAt"
        ]
      },
      "UsageEventDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "workspaceAccessId": {
            "type": "string"
          },
          "quotaPeriodId": {
            "type": "string"
          },
          "reservationId": {
            "type": "string"
          },
          "invocationId": {
            "type": "string"
          },
          "eventType": {
            "type": "string"
          },
          "inputTokens": {
            "type": "string"
          },
          "cachedInputTokens": {
            "type": "string"
          },
          "outputTokens": {
            "type": "string"
          },
          "quotaUnitsDelta": {
            "type": "string"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "reason": {
            "type": "string"
          },
          "adjustsEventId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "workspaceAccessId",
          "quotaPeriodId",
          "invocationId",
          "eventType",
          "inputTokens",
          "cachedInputTokens",
          "outputTokens",
          "quotaUnitsDelta",
          "occurredAt"
        ]
      },
      "InvocationDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          },
          "traceId": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "workspaceAccessId": {
            "type": "string"
          },
          "requestedModel": {
            "type": "string"
          },
          "providerConnectionId": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "quotaUnits": {
            "type": "string"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time"
          },
          "firstTokenAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": "string",
            "format": "date-time"
          },
          "totalLatencyMs": {
            "type": "number"
          },
          "nexusLatencyMs": {
            "type": "number",
            "description": "Gateway time outside the Provider attempt."
          },
          "providerLatencyMs": {
            "type": "number"
          },
          "totalTtftMs": {
            "type": "number"
          },
          "nexusTtftMs": {
            "type": "number",
            "description": "Gateway time before the Provider first byte."
          },
          "providerTtftMs": {
            "type": "number"
          },
          "attempt": {
            "$ref": "#/components/schemas/InvocationAttemptDto"
          },
          "usageEvents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UsageEventDto"
            }
          }
        },
        "required": [
          "id",
          "requestId",
          "workspaceId",
          "workspaceAccessId",
          "requestedModel",
          "providerConnectionId",
          "status",
          "quotaUnits",
          "startedAt"
        ]
      },
      "AuditLogDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "actorType": {
            "type": "string"
          },
          "actorId": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "targetType": {
            "type": "string"
          },
          "targetId": {
            "type": "string"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "actorType",
          "actorId",
          "action",
          "targetType",
          "targetId",
          "occurredAt"
        ]
      },
      "CreateBillingConnectionDto": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "STRIPE",
              "CREEM"
            ]
          },
          "mode": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "provider",
          "mode"
        ]
      },
      "BillingConnectionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "workspaceId": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "HOSTED",
              "APP_SYNC"
            ],
            "type": "string"
          },
          "provider": {
            "enum": [
              "STRIPE",
              "CREEM"
            ],
            "type": "string"
          },
          "mode": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "webhookUrl": {
            "type": "string",
            "format": "uri",
            "readOnly": true
          },
          "credentialConfigured": {
            "type": "boolean"
          },
          "webhookSecretConfigured": {
            "type": "boolean"
          },
          "credentialVerificationStatus": {
            "type": "string"
          },
          "credentialPreview": {
            "type": "string"
          },
          "lastVerifiedAt": {
            "type": "string",
            "format": "date-time"
          },
          "externalAccountId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "workspaceId",
          "kind",
          "provider",
          "mode",
          "status",
          "name",
          "webhookUrl",
          "credentialConfigured",
          "webhookSecretConfigured",
          "credentialVerificationStatus"
        ]
      },
      "ConfigureBillingProviderCredentialDto": {
        "type": "object",
        "properties": {
          "credential": {
            "type": "string"
          }
        },
        "required": [
          "credential"
        ]
      },
      "ConfigureBillingWebhookSecretDto": {
        "type": "object",
        "properties": {
          "webhookSecret": {
            "type": "string"
          }
        },
        "required": [
          "webhookSecret"
        ]
      },
      "CreateProductMappingDto": {
        "type": "object",
        "properties": {
          "externalProductId": {
            "type": "string"
          },
          "externalPriceId": {
            "type": "string"
          },
          "planId": {
            "type": "string"
          },
          "checkoutEnabled": {
            "type": "boolean"
          }
        },
        "required": [
          "externalProductId",
          "planId"
        ]
      },
      "IdResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ]
      },
      "CreateBillingCheckoutDto": {
        "type": "object",
        "properties": {
          "billingConnectionId": {
            "type": "string"
          },
          "planKey": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "successUrl": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "billingConnectionId",
          "planKey",
          "successUrl"
        ]
      },
      "BillingCheckoutDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "provider": {
            "enum": [
              "STRIPE",
              "CREEM"
            ],
            "type": "string"
          },
          "checkoutUrl": {
            "type": "string",
            "format": "uri"
          },
          "requestId": {
            "type": "string"
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "provider",
          "checkoutUrl",
          "requestId",
          "replayed"
        ]
      },
      "SyncBillingPeriodDto": {
        "type": "object",
        "properties": {
          "planId": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "STRIPE",
              "CREEM"
            ]
          },
          "externalSubscriptionId": {
            "type": "string"
          },
          "externalCustomerId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "TRIALING",
              "PAST_DUE",
              "PAUSED",
              "CANCELED",
              "UNPAID",
              "INCOMPLETE",
              "UNKNOWN"
            ]
          },
          "periodStart": {
            "type": "string"
          },
          "periodEnd": {
            "type": "string"
          },
          "cancelAtPeriodEnd": {
            "type": "boolean"
          },
          "sourceEventId": {
            "type": "string"
          }
        },
        "required": [
          "planId",
          "provider",
          "externalSubscriptionId",
          "status",
          "periodStart",
          "periodEnd"
        ]
      },
      "ExternalSubscriptionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "billingConnectionId": {
            "type": "string"
          },
          "workspaceAccessId": {
            "type": "string"
          },
          "provider": {
            "enum": [
              "STRIPE",
              "CREEM"
            ],
            "type": "string"
          },
          "externalCustomerId": {
            "type": "string"
          },
          "externalSubscriptionId": {
            "type": "string"
          },
          "status": {
            "enum": [
              "ACTIVE",
              "TRIALING",
              "PAST_DUE",
              "PAUSED",
              "CANCELED",
              "UNPAID",
              "INCOMPLETE",
              "UNKNOWN"
            ],
            "type": "string"
          },
          "periodStart": {
            "type": "string",
            "format": "date-time"
          },
          "periodEnd": {
            "type": "string",
            "format": "date-time"
          },
          "cancelAtPeriodEnd": {
            "type": "boolean"
          },
          "sourceEventId": {
            "type": "string"
          },
          "sourceEventOccurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "billingConnectionId",
          "workspaceAccessId",
          "provider",
          "externalSubscriptionId",
          "status",
          "periodStart",
          "periodEnd",
          "cancelAtPeriodEnd",
          "updatedAt"
        ]
      }
    }
  }
}
