{
  "openapi": "3.1.0",
  "info": {
    "title": "Tidegate",
    "version": "0.0.0"
  },
  "paths": {
    "/account": {
      "get": {
        "tags": [
          "account"
        ],
        "summary": "The signed-in person and the organizations they are in",
        "operationId": "account.account",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Forbidden"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/account/authorizations": {
      "post": {
        "tags": [
          "account"
        ],
        "summary": "The person's decision on an agent's authorization request, as where to send the agent",
        "operationId": "account.decideAuthorization",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthorizationDecision"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorizationOutcome"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Forbidden"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/account/authorizations/check": {
      "post": {
        "tags": [
          "account"
        ],
        "summary": "Whether an agent's authorization request is valid, and for which agent",
        "operationId": "account.checkAuthorization",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthorizationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorizationCheck"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Forbidden"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/account/links/{provider}": {
      "post": {
        "tags": [
          "account"
        ],
        "summary": "Start linking a provider's account to the signed-in person, as where to send them",
        "operationId": "account.link",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SignInProvider"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LinkStart"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Forbidden"
                }
              }
            }
          },
          "404": {
            "description": "ProviderOff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderOff"
                }
              }
            }
          },
          "409": {
            "description": "SignInAgain",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignInAgain"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/account/sign-out": {
      "post": {
        "tags": [
          "account"
        ],
        "summary": "End the session the request carries",
        "operationId": "account.signOut",
        "parameters": [],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Forbidden"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/auth/providers": {
      "get": {
        "tags": [
          "system"
        ],
        "summary": "The providers this Tidegate signs people in with",
        "operationId": "system.signInProviders",
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignInProviders"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": [
          "system"
        ],
        "summary": "Whether the process is up",
        "operationId": "system.health",
        "parameters": [],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          }
        }
      }
    },
    "/tenants/{tenant}/access": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "What the caller may do in the organization",
        "operationId": "tenant.access",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Access"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/apps": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "The organization's apps",
        "operationId": "tenant.apps",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AppDefinition"
                  }
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Define an app",
        "operationId": "tenant.defineApp",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppDefinition"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppDefinition"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/apps/{id}": {
      "delete": {
        "tags": [
          "tenant"
        ],
        "summary": "Remove an app",
        "operationId": "tenant.removeApp",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/AppId"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "AppNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppNotFound"
                }
              }
            }
          },
          "409": {
            "description": "AppHasSpend or AppHasKeys",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AppHasSpend"
                    },
                    {
                      "$ref": "#/components/schemas/AppHasKeys"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "The organization's budgets, with what each has spent",
        "operationId": "tenant.budgets",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BudgetState"
                  }
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Define a budget",
        "operationId": "tenant.defineBudget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordedBudget"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetState"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "BudgetConflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetConflict"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "422": {
            "description": "UnknownMeter or UnknownApp or UnpricedMeter",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/UnknownMeter"
                    },
                    {
                      "$ref": "#/components/schemas/UnknownApp"
                    },
                    {
                      "$ref": "#/components/schemas/UnpricedMeter"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/{id}": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "A budget, with what it has spent",
        "operationId": "tenant.budget",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/BudgetId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetState"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "BudgetNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetNotFound"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/{id}/limit": {
      "put": {
        "tags": [
          "tenant"
        ],
        "summary": "Change a budget's limit",
        "operationId": "tenant.setBudgetLimit",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/BudgetId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetLimit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetState"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "BudgetNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetNotFound"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/budgets/{id}/status": {
      "put": {
        "tags": [
          "tenant"
        ],
        "summary": "Freeze, archive, or reactivate a budget",
        "operationId": "tenant.setBudgetStatus",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/BudgetId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetStatus"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetState"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "BudgetNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BudgetNotFound"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/environments": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "The environments the organization's keys and spend name",
        "operationId": "tenant.environments",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EnvironmentId"
                  }
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/history": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "The organization's changes, newest first, a page at a time",
        "operationId": "tenant.history",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "before",
            "in": "query",
            "description": "Entries before this sequence number; the newest when absent",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SafeInt"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HistoryPage"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/keys": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "The organization's API keys",
        "operationId": "tenant.keys",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiKey"
                  }
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Create an API key, whose secret is shown only in this answer",
        "operationId": "tenant.createKey",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KeyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedKey"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "422": {
            "description": "UnknownApp",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnknownApp"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/keys/{id}": {
      "delete": {
        "tags": [
          "tenant"
        ],
        "summary": "Revoke an API key",
        "operationId": "tenant.revokeKey",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/KeyId"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "KeyNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyNotFound"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/members": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "The organization's members",
        "operationId": "tenant.members",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Member"
                  }
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Add a member, by email",
        "operationId": "tenant.addMember",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemberRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Member"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "MemberConflict or MembershipNeedsAcceptance",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/MemberConflict"
                    },
                    {
                      "$ref": "#/components/schemas/MembershipNeedsAcceptance"
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/members/{person}": {
      "delete": {
        "tags": [
          "tenant"
        ],
        "summary": "Remove a member",
        "operationId": "tenant.removeMember",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "person",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/PersonId"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "MemberNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MemberNotFound"
                }
              }
            }
          },
          "409": {
            "description": "LastAdmin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LastAdmin"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/members/{person}/role": {
      "put": {
        "tags": [
          "tenant"
        ],
        "summary": "Change a member's role",
        "operationId": "tenant.setMemberRole",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "person",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/PersonId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetRole"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Member"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "MemberNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MemberNotFound"
                }
              }
            }
          },
          "409": {
            "description": "LastAdmin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LastAdmin"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/meters": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "The organization's meters",
        "operationId": "tenant.meters",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MeterDefinition"
                  }
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Define a meter",
        "operationId": "tenant.defineMeter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MeterDefinition"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterDefinition"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "MeterConflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterConflict"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/meters/{id}": {
      "delete": {
        "tags": [
          "tenant"
        ],
        "summary": "Remove a meter, with its prices and budgets",
        "operationId": "tenant.removeMeter",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MeterId"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "MeterNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterNotFound"
                }
              }
            }
          },
          "409": {
            "description": "MeterHasSpend",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeterHasSpend"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/prices": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "Every meter's prices",
        "operationId": "tenant.prices",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Price"
                  }
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Set a meter's price from a moment on",
        "operationId": "tenant.setPrice",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Price"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Price"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "PriceConflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceConflict"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "422": {
            "description": "UnknownMeter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnknownMeter"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/prices/{meter}/{startsAt}": {
      "delete": {
        "tags": [
          "tenant"
        ],
        "summary": "Remove a price",
        "operationId": "tenant.removePrice",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          },
          {
            "name": "meter",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/MeterId"
            }
          },
          {
            "name": "startsAt",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Timestamp"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "PriceNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceNotFound"
                }
              }
            }
          },
          "409": {
            "description": "PriceInUse",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceInUse"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/reservations": {
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Reserve a call's cost against the budgets it falls under",
        "operationId": "tenant.reserve",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReserveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reservation"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "ReservationConflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReservationConflict"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "422": {
            "description": "UnknownMeter or UnpricedMeter",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/UnknownMeter"
                    },
                    {
                      "$ref": "#/components/schemas/UnpricedMeter"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests or Denied",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/TooManyRequests"
                    },
                    {
                      "$ref": "#/components/schemas/Denied"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/retention": {
      "get": {
        "tags": [
          "tenant"
        ],
        "summary": "Where the organization's kept spend starts",
        "operationId": "tenant.retention",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Retention"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/settlements": {
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "Settle a reservation with what the call used",
        "operationId": "tenant.settle",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SettleRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Settlement"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "ReservationNotFound",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReservationNotFound"
                }
              }
            }
          },
          "409": {
            "description": "AlreadySettled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlreadySettled"
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "422": {
            "description": "MetersMismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetersMismatch"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/tenants/{tenant}/spend": {
      "post": {
        "tags": [
          "tenant"
        ],
        "summary": "A report of the organization's spend, by period and group",
        "operationId": "tenant.spend",
        "parameters": [
          {
            "name": "tenant",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TenantId"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SpendQuery"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SpendReport"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden or NotAdmitted",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Forbidden"
                    },
                    {
                      "$ref": "#/components/schemas/NotAdmitted"
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "PayloadTooLarge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayloadTooLarge"
                }
              }
            }
          },
          "415": {
            "description": "UnsupportedMediaType",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnsupportedMediaType"
                }
              }
            }
          },
          "429": {
            "description": "TooManyRequests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TooManyRequests"
                }
              }
            }
          },
          "500": {
            "description": "Internal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Internal"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Unavailable"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Access": {
        "type": "object",
        "description": "What the caller may do in the organization (`GET …/access`): each capability their role\nthere allows. A client shows each control by these, not by the name of the role.",
        "required": [
          "capabilities"
        ],
        "properties": {
          "capabilities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Capability"
            },
            "description": "The capabilities, each once, in a fixed order: read, spend, define, audit, keys, members,\nleave."
          }
        }
      },
      "Account": {
        "type": "object",
        "description": "The person a session is for, and the organizations they are in, with their role in each.",
        "required": [
          "person",
          "organizations"
        ],
        "properties": {
          "organizations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountOrganization"
            },
            "description": "Their organizations, by name."
          },
          "person": {
            "$ref": "#/components/schemas/AccountPerson",
            "description": "Who they are."
          }
        }
      },
      "AccountOrganization": {
        "type": "object",
        "description": "One of a person's organizations, with their role there.",
        "required": [
          "id",
          "name",
          "role"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/TenantId",
            "description": "The organization's id: its tenant's."
          },
          "name": {
            "$ref": "#/components/schemas/OrganizationName",
            "description": "Its name."
          },
          "role": {
            "$ref": "#/components/schemas/PersonRole",
            "description": "The person's role in it."
          }
        }
      },
      "AccountPerson": {
        "type": "object",
        "description": "The person an account is for.",
        "required": [
          "id",
          "email",
          "providers"
        ],
        "properties": {
          "email": {
            "$ref": "#/components/schemas/Email",
            "description": "Their email address."
          },
          "id": {
            "$ref": "#/components/schemas/PersonId",
            "description": "Their id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name, from the provider they last signed in with, or null until they first sign in."
          },
          "providers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SignInProvider"
            },
            "description": "The providers they sign in with, in this order: Google once they have signed in with it,\nGitHub once they have linked it."
          }
        }
      },
      "Actor": {
        "oneOf": [
          {
            "type": "object",
            "description": "A person, by their id.",
            "required": [
              "user",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Person"
                ]
              },
              "label": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ActorLabel",
                    "description": "What to show for them, as they were named when they acted, in place of looking them\nup among the organization's members: set for someone who isn't one."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "through": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/Through",
                    "description": "What they acted through, if not the pages: an agent, or a kind of access the\ndeployment names."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "user": {
                "type": "string",
                "description": "The person's id."
              }
            }
          },
          {
            "type": "object",
            "description": "An API key, by its id.",
            "required": [
              "key",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Key"
                ]
              },
              "key": {
                "$ref": "#/components/schemas/KeyId",
                "description": "The key's id."
              }
            }
          },
          {
            "type": "object",
            "description": "The deployment itself, with no person behind it: a scheduled job, or a command an\noperator runs on the server.",
            "required": [
              "label",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Deployment"
                ]
              },
              "label": {
                "$ref": "#/components/schemas/ActorLabel",
                "description": "What to show for it, as it named itself when it acted, such as `Maintenance job`."
              }
            }
          }
        ],
        "description": "Who made a change: a person, by their id, a key, or the deployment itself. The person's field\nis `user`, as the history has recorded people since Clerk named them, and it is a plain\nstring: the history keeps what it recorded.\n\nA person may also carry what they acted through and a label to show for them, each recorded\nwith the change, as it was then. A person who acted as themselves, signed in to the pages,\ncarries neither, as every change recorded before them did, and decodes that way.\n\nThe deployment acts itself, with no person behind it, in what it runs on a tenant of its own\naccord, such as a scheduled job or a command an operator runs on the server: the history\nrecords it as that, by the label it gives, rather than as some person. It names no person, so\nerasing one never needs to touch it."
      },
      "ActorLabel": {
        "type": "string",
        "maxLength": 200,
        "minLength": 1,
        "pattern": "^[^\\n\\r\\u2028\\u2029]+$"
      },
      "AlreadySettled": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "AlreadySettled"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "description": "A key, as the keys list shows it: never its secret, nor the secret's hash.",
        "required": [
          "id",
          "name",
          "role",
          "environment",
          "createdAt"
        ],
        "properties": {
          "app": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AppId",
                "description": "The app it spends for, or null for the organization."
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "When it was created."
          },
          "environment": {
            "$ref": "#/components/schemas/EnvironmentId",
            "description": "The environment it spends in."
          },
          "id": {
            "$ref": "#/components/schemas/KeyId",
            "description": "The key's id."
          },
          "lastUsedAt": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Timestamp",
                "description": "When it last authenticated a call, or null if it never has."
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "$ref": "#/components/schemas/KeyName",
            "description": "Who holds it."
          },
          "role": {
            "$ref": "#/components/schemas/KeyRole",
            "description": "What it may do."
          }
        }
      },
      "AppDefinition": {
        "type": "object",
        "description": "One of the tenant's apps. A key may belong to one, and every reservation the key makes is\nthen that app's. The request to define one, and the response.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/AppId",
            "description": "The app's id."
          }
        },
        "additionalProperties": false
      },
      "AppHasKeys": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "AppHasKeys"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AppHasSpend": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "AppHasSpend"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AppId": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "AppNotFound": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "AppNotFound"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "AuthorizationCheck": {
        "oneOf": [
          {
            "type": "object",
            "description": "The request may go ahead: the page asks the person.",
            "required": [
              "client",
              "redirect_uri",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Valid"
                ]
              },
              "client": {
                "$ref": "#/components/schemas/ConsentClient",
                "description": "The agent."
              },
              "redirect_uri": {
                "type": "string",
                "description": "Where the person will be sent back."
              }
            }
          },
          {
            "type": "object",
            "description": "The request can't go back to the agent; the page says why.",
            "required": [
              "message",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Invalid"
                ]
              },
              "message": {
                "type": "string",
                "description": "Why, for the person to read."
              }
            }
          },
          {
            "type": "object",
            "description": "The page sends the person to the agent's address, with an error.",
            "required": [
              "to",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Redirect"
                ]
              },
              "to": {
                "type": "string",
                "description": "The address."
              }
            }
          }
        ],
        "description": "What the server makes of an authorization request."
      },
      "AuthorizationDecision": {
        "type": "object",
        "description": "The consent page's decision on an authorization request.",
        "required": [
          "request",
          "decision"
        ],
        "properties": {
          "decision": {
            "$ref": "#/components/schemas/Decision",
            "description": "The person's answer."
          },
          "request": {
            "$ref": "#/components/schemas/AuthorizationRequest",
            "description": "The request, as the agent sent it."
          }
        },
        "additionalProperties": false
      },
      "AuthorizationOutcome": {
        "oneOf": [
          {
            "type": "object",
            "description": "The request can't go back to the agent; the page says why.",
            "required": [
              "message",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Invalid"
                ]
              },
              "message": {
                "type": "string",
                "description": "Why, for the person to read."
              }
            }
          },
          {
            "type": "object",
            "description": "The page sends the person to the agent's address, with a code or an error.",
            "required": [
              "to",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Redirect"
                ]
              },
              "to": {
                "type": "string",
                "description": "The address."
              }
            }
          }
        ],
        "description": "What the server answers a decision with: the page sends the person on, or says why it can't."
      },
      "AuthorizationRequest": {
        "type": "object",
        "description": "An agent's authorization request, as it sent it to `/oauth/authorize`, which the consent page\nhands on unchecked for the server to check. Each optional parameter may be absent or null,\nwhich mean the same.",
        "required": [
          "clientId"
        ],
        "properties": {
          "clientId": {
            "$ref": "#/components/schemas/Param",
            "description": "The agent's client id."
          },
          "codeChallenge": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Param",
                "description": "The PKCE challenge."
              },
              {
                "type": "null"
              }
            ]
          },
          "codeChallengeMethod": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Param",
                "description": "Must be `S256`."
              },
              {
                "type": "null"
              }
            ]
          },
          "redirectUri": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Param",
                "description": "Where to send the person back."
              },
              {
                "type": "null"
              }
            ]
          },
          "resource": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Param",
                "description": "The resource the agent wants tokens for: Tidegate's MCP endpoint, if given."
              },
              {
                "type": "null"
              }
            ]
          },
          "responseType": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Param",
                "description": "Must be `code`."
              },
              {
                "type": "null"
              }
            ]
          },
          "state": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Param",
                "description": "The agent's state, handed back as is."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "BadRequest": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "BadRequest"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Boundaries": {
        "type": "array",
        "items": {
          "type": "integer",
          "maximum": 253402300799999,
          "minimum": 0
        },
        "maxItems": 401,
        "minItems": 2
      },
      "BudgetConflict": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "BudgetConflict"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "BudgetDefinition": {
        "type": "object",
        "description": "A budget's definition: the request to define one, and what its state and the history show.\nTwo definitions are the same budget when every field is equal, with `meters` compared as a\nset.",
        "required": [
          "id",
          "meters",
          "unit",
          "limit",
          "labels",
          "splitBy",
          "window"
        ],
        "properties": {
          "app": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AppId",
                "description": "The budget counts only the reservations this app's keys make. Null counts every\nreservation, whichever app's key made it, or a key without one. Absent is null."
              },
              {
                "type": "null"
              }
            ]
          },
          "environment": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EnvironmentId",
                "description": "The budget counts only the reservations made in this environment. Null counts every\nenvironment's. Absent is null."
              },
              {
                "type": "null"
              }
            ]
          },
          "id": {
            "$ref": "#/components/schemas/BudgetId",
            "description": "The budget's id."
          },
          "labels": {
            "$ref": "#/components/schemas/Labels",
            "description": "The budget counts only reservations that carry every one of these labels."
          },
          "limit": {
            "$ref": "#/components/schemas/Quantity",
            "description": "The most spend each window may hold, in the budget's unit."
          },
          "meters": {
            "$ref": "#/components/schemas/MeterSet",
            "description": "The meters whose spend it counts, by id: 1 to 100, each once. A budget in units counts\nexactly one, since units of different meters don't add up; one in micro-dollars counts\nany number, at their prices."
          },
          "splitBy": {
            "$ref": "#/components/schemas/SplitKeys",
            "description": "Counted apart for each value of these labels; a reservation without one of them is not\ncounted."
          },
          "unit": {
            "$ref": "#/components/schemas/BudgetUnit",
            "description": "What its limit and spend are counted in: its one meter's `units`, or `microdollars`."
          },
          "window": {
            "$ref": "#/components/schemas/BudgetWindow",
            "description": "Its windows."
          }
        },
        "additionalProperties": false
      },
      "BudgetId": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "BudgetNotFound": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "BudgetNotFound"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "BudgetSpend": {
        "type": "object",
        "description": "Spend in a budget's current window, for one split.",
        "required": [
          "split",
          "quantity",
          "microdollars",
          "unpriced"
        ],
        "properties": {
          "microdollars": {
            "type": "integer",
            "format": "int64",
            "description": "What the priced part of `quantity` cost, each reservation at its meter's price then. A\nbudget in micro-dollars has no other part, so this is `quantity`.",
            "minimum": 0
          },
          "quantity": {
            "type": "integer",
            "format": "int64",
            "description": "What was spent, in the budget's unit, capped at 2^53 − 1.",
            "minimum": 0
          },
          "split": {
            "$ref": "#/components/schemas/Split",
            "description": "The values of the budget's split labels. Empty for a budget that does not split."
          },
          "unpriced": {
            "type": "integer",
            "format": "int64",
            "description": "The part of `quantity` reserved while its meter had no price: none, in micro-dollars.",
            "minimum": 0
          }
        }
      },
      "BudgetState": {
        "type": "object",
        "description": "A budget as it stands now: its definition, its status, and the spend in its current window.",
        "required": [
          "definition",
          "status",
          "spend"
        ],
        "properties": {
          "anchor": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Timestamp",
                "description": "Where its windows repeat from: the definition's anchor, else its first reservation, or\nnull before that. Budgets with the same anchor and window length have the same windows."
              },
              {
                "type": "null"
              }
            ]
          },
          "definition": {
            "$ref": "#/components/schemas/BudgetDefinition",
            "description": "The definition, with the budget's current limit."
          },
          "limitMicrodollars": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The limit in micro-dollars, capped at 2^53 − 1: a budget in micro-dollars' own, or a\nbudget in units' cost at its meter's price now, or null if the meter has no price now.",
            "minimum": 0
          },
          "spend": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BudgetSpend"
            },
            "description": "Spend in that window, for each split that has any."
          },
          "status": {
            "$ref": "#/components/schemas/BudgetStatus",
            "description": "Whether it is in effect: active, frozen, or archived."
          },
          "window": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Window",
                "description": "The window that holds the present, or null before the budget's first reservation."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "BudgetStatus": {
        "type": "string",
        "description": "Whether a budget is in effect: active; frozen, refusing every reservation it counts, whatever\nits spend; or archived, out of effect, counting nothing, kept for its record. A budget's\ndefinition never changes; its status can, back and forth.",
        "enum": [
          "active",
          "frozen",
          "archived"
        ]
      },
      "BudgetUnit": {
        "type": "string",
        "description": "What a budget's limit and spend are counted in: its one meter's own units, or micro-dollars,\neach reservation at its meters' prices when it was made.",
        "enum": [
          "units",
          "microdollars"
        ]
      },
      "BudgetWindow": {
        "type": "object",
        "description": "A budget's windows: how long each lasts, and where they repeat from.",
        "required": [
          "length",
          "anchor"
        ],
        "properties": {
          "anchor": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Timestamp",
                "description": "The start of one window; the rest repeat back to back from it in both directions. Null\nstarts the first window at the budget's first reservation. Required, though it may be\nnull."
              },
              {
                "type": "null"
              }
            ]
          },
          "length": {
            "$ref": "#/components/schemas/WindowLength",
            "description": "How long each window lasts."
          }
        },
        "additionalProperties": false
      },
      "Capability": {
        "type": "string",
        "description": "The capabilities, as values, for the role table and for reporting what a caller may do.",
        "enum": [
          "read",
          "spend",
          "define",
          "audit",
          "keys",
          "members",
          "leave"
        ]
      },
      "Change": {
        "oneOf": [
          {
            "type": "object",
            "description": "An app was defined.",
            "required": [
              "app",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "AppDefined"
                ]
              },
              "app": {
                "$ref": "#/components/schemas/AppDefinition",
                "description": "The app."
              }
            }
          },
          {
            "type": "object",
            "description": "An app was removed.",
            "required": [
              "app",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "AppRemoved"
                ]
              },
              "app": {
                "$ref": "#/components/schemas/AppDefinition",
                "description": "The app."
              }
            }
          },
          {
            "type": "object",
            "description": "A meter was defined.",
            "required": [
              "meter",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "MeterDefined"
                ]
              },
              "meter": {
                "$ref": "#/components/schemas/MeterDefinition",
                "description": "The meter."
              }
            }
          },
          {
            "type": "object",
            "description": "A meter was removed.",
            "required": [
              "meter",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "MeterRemoved"
                ]
              },
              "meter": {
                "$ref": "#/components/schemas/MeterDefinition",
                "description": "The meter."
              }
            }
          },
          {
            "type": "object",
            "description": "A price was set.",
            "required": [
              "price",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "PriceSet"
                ]
              },
              "price": {
                "$ref": "#/components/schemas/Price",
                "description": "The price."
              }
            }
          },
          {
            "type": "object",
            "description": "A price was removed.",
            "required": [
              "price",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "PriceRemoved"
                ]
              },
              "price": {
                "$ref": "#/components/schemas/Price",
                "description": "The price."
              }
            }
          },
          {
            "type": "object",
            "description": "A budget was defined.",
            "required": [
              "budget",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "BudgetDefined"
                ]
              },
              "budget": {
                "$ref": "#/components/schemas/BudgetDefinition",
                "description": "The budget's definition, as defined. One recorded before budgets could be in\nmicro-dollars has a single `meter`, and reads as that meter's, in its units."
              }
            }
          },
          {
            "type": "object",
            "description": "A budget's limit changed.",
            "required": [
              "budget",
              "before",
              "after",
              "unit",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "LimitChanged"
                ]
              },
              "after": {
                "$ref": "#/components/schemas/Quantity",
                "description": "The limit after."
              },
              "before": {
                "$ref": "#/components/schemas/Quantity",
                "description": "The limit before."
              },
              "budget": {
                "$ref": "#/components/schemas/BudgetId",
                "description": "The budget's id."
              },
              "unit": {
                "$ref": "#/components/schemas/BudgetUnit",
                "description": "What the limits are in. Recorded before budgets could be in micro-dollars, units."
              }
            }
          },
          {
            "type": "object",
            "description": "A budget was removed.",
            "required": [
              "budget",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "BudgetRemoved"
                ]
              },
              "budget": {
                "$ref": "#/components/schemas/BudgetDefinition",
                "description": "The budget's definition, as it stood, with its limit then. One recorded before\nbudgets could be in micro-dollars has a single `meter`, and reads as that meter's, in\nits units."
              }
            }
          },
          {
            "type": "object",
            "description": "A budget's status changed: it was frozen, archived, or made active again. Recorded only\nwhen the status differs from what it was.",
            "required": [
              "budget",
              "before",
              "after",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "BudgetStatusChanged"
                ]
              },
              "after": {
                "$ref": "#/components/schemas/BudgetStatus",
                "description": "The status after."
              },
              "before": {
                "$ref": "#/components/schemas/BudgetStatus",
                "description": "The status before."
              },
              "budget": {
                "$ref": "#/components/schemas/BudgetId",
                "description": "The budget's id."
              }
            }
          },
          {
            "type": "object",
            "description": "A key was created.",
            "required": [
              "key",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "KeyCreated"
                ]
              },
              "key": {
                "$ref": "#/components/schemas/KeyDescription",
                "description": "The key."
              }
            }
          },
          {
            "type": "object",
            "description": "A key was revoked.",
            "required": [
              "key",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "KeyRevoked"
                ]
              },
              "key": {
                "$ref": "#/components/schemas/KeyDescription",
                "description": "The key."
              }
            }
          },
          {
            "type": "object",
            "description": "A person was added.",
            "required": [
              "member",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "MemberAdded"
                ]
              },
              "member": {
                "$ref": "#/components/schemas/MemberDescription",
                "description": "The membership."
              }
            }
          },
          {
            "type": "object",
            "description": "A member's role changed.",
            "required": [
              "person",
              "email",
              "before",
              "after",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "MemberRoleChanged"
                ]
              },
              "after": {
                "$ref": "#/components/schemas/PersonRole",
                "description": "Their role after."
              },
              "before": {
                "$ref": "#/components/schemas/PersonRole",
                "description": "Their role before."
              },
              "email": {
                "type": "string",
                "description": "Their email address."
              },
              "person": {
                "type": "string",
                "description": "The person's id."
              }
            }
          },
          {
            "type": "object",
            "description": "A member was removed.",
            "required": [
              "member",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "MemberRemoved"
                ]
              },
              "member": {
                "$ref": "#/components/schemas/MemberDescription",
                "description": "The membership."
              }
            }
          },
          {
            "type": "object",
            "description": "An entry the deployment recorded of its own, in the history's sequence, made only from a\nchecked `DeploymentEntry`.",
            "required": [
              "kind",
              "summary",
              "subject",
              "details",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Deployment"
                ]
              },
              "details": {
                "type": "object",
                "description": "Whatever else the deployment keeps with the entry, for itself: an object, which names\nno one."
              },
              "kind": {
                "$ref": "#/components/schemas/Kind",
                "description": "What kind of entry it is, as the deployment names it."
              },
              "subject": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/Email",
                    "description": "The email of the person the entry is about, if any."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "summary": {
                "$ref": "#/components/schemas/Summary",
                "description": "What the history shows beside the actor. It names no one: where it holds\n`{subject}`, the subject is shown in its place."
              }
            }
          }
        ],
        "description": "A change to a tenant's apps, meters, prices, budgets, keys, or members, or an entry a\ndeployment recorded, as recorded."
      },
      "ConsentClient": {
        "type": "object",
        "description": "The agent, as the consent page shows it.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name it registered with."
          }
        }
      },
      "CreatedKey": {
        "type": "object",
        "description": "A new key, with its secret. The secret is shown only here; Tidegate keeps only its hash.",
        "required": [
          "key",
          "secret"
        ],
        "properties": {
          "key": {
            "$ref": "#/components/schemas/ApiKey",
            "description": "The key."
          },
          "secret": {
            "type": "string",
            "description": "Its secret: `tg_` and 43 base64url characters."
          }
        }
      },
      "Decision": {
        "oneOf": [
          {
            "type": "object",
            "description": "Let the agent act as the person in this organization.",
            "required": [
              "organization",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Allow"
                ]
              },
              "organization": {
                "$ref": "#/components/schemas/TenantId",
                "description": "The organization."
              }
            }
          },
          {
            "type": "object",
            "description": "Turn the agent away.",
            "required": [
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Deny"
                ]
              }
            }
          }
        ],
        "description": "The person's answer: let the agent in to one of their organizations, or not."
      },
      "Denied": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "budget",
          "split",
          "window",
          "unit",
          "limit",
          "spent",
          "requested",
          "frozen"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "Denied"
            ]
          },
          "budget": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "frozen": {
            "type": "boolean"
          },
          "limit": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "message": {
            "type": "string"
          },
          "requested": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "spent": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "split": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 256,
              "minLength": 1
            },
            "maxProperties": 4
          },
          "unit": {
            "type": "string",
            "description": "What a budget's limit and spend are counted in: its one meter's own units, or micro-dollars,\neach reservation at its meters' prices when it was made.",
            "enum": [
              "units",
              "microdollars"
            ]
          },
          "window": {
            "type": "object",
            "description": "One of a budget's windows: from `start` up to, not including, `end`, in epoch milliseconds.\nA window that holds an early moment may start before 1970, so these are plain integers.",
            "required": [
              "start",
              "end"
            ],
            "properties": {
              "end": {
                "type": "integer",
                "format": "int64",
                "description": "Where the next one starts."
              },
              "start": {
                "type": "integer",
                "format": "int64",
                "description": "Where it starts."
              }
            }
          }
        }
      },
      "DurationMs": {
        "type": "integer",
        "maximum": 3162240000000,
        "minimum": 1
      },
      "Email": {
        "type": "string",
        "maxLength": 254,
        "pattern": "^[^\\sA-Z@]+@[^\\sA-Z@]+\\.[^\\sA-Z@]+$"
      },
      "EnvironmentId": {
        "type": "string",
        "maxLength": 64,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "Forbidden": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "Forbidden"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "GroupBy": {
        "type": "array",
        "items": {
          "oneOf": [
            {
              "type": "object",
              "description": "The app whose key made the reservation (null for a key without one).",
              "required": [
                "_tag"
              ],
              "properties": {
                "_tag": {
                  "type": "string",
                  "enum": [
                    "App"
                  ]
                }
              }
            },
            {
              "type": "object",
              "description": "The environment it was made in.",
              "required": [
                "_tag"
              ],
              "properties": {
                "_tag": {
                  "type": "string",
                  "enum": [
                    "Environment"
                  ]
                }
              }
            },
            {
              "type": "object",
              "description": "The vendor of the meter charged.",
              "required": [
                "_tag"
              ],
              "properties": {
                "_tag": {
                  "type": "string",
                  "enum": [
                    "Vendor"
                  ]
                }
              }
            },
            {
              "type": "object",
              "description": "The meter charged.",
              "required": [
                "_tag"
              ],
              "properties": {
                "_tag": {
                  "type": "string",
                  "enum": [
                    "Meter"
                  ]
                }
              }
            },
            {
              "type": "object",
              "description": "A label's value (null for reservations without the label).",
              "required": [
                "key",
                "_tag"
              ],
              "properties": {
                "_tag": {
                  "type": "string",
                  "enum": [
                    "Label"
                  ]
                },
                "key": {
                  "$ref": "#/components/schemas/LabelKey",
                  "description": "The label's key."
                }
              }
            }
          ],
          "description": "A facet a spend report groups by: each of its values is a group."
        },
        "maxItems": 20
      },
      "HistoryEntry": {
        "type": "object",
        "description": "One change, with when and by whom.",
        "required": [
          "sequence",
          "at",
          "actor",
          "change"
        ],
        "properties": {
          "actor": {
            "$ref": "#/components/schemas/Actor",
            "description": "Who made it."
          },
          "at": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "When the change was made."
          },
          "change": {
            "$ref": "#/components/schemas/Change",
            "description": "What it was."
          },
          "sequence": {
            "type": "integer",
            "format": "int64",
            "description": "Increases with each change, so it orders the history and pages through it."
          }
        }
      },
      "HistoryPage": {
        "type": "object",
        "description": "Changes, newest first. `next` pages to the older ones, or is null at the first change.",
        "required": [
          "entries"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryEntry"
            },
            "description": "At most [`HISTORY_PAGE`] changes, newest first."
          },
          "next": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The `before` that asks for the next, older page, or null on the last page."
          }
        }
      },
      "Internal": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "Internal"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "KeyDescription": {
        "type": "object",
        "description": "What a key is, as its history records it: never its secret, nor the secret's hash. History\nwritten before apps and environments reads as the organization's, in production.",
        "required": [
          "id",
          "name",
          "role"
        ],
        "properties": {
          "app": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AppId",
                "description": "The app it spends for, or null for the organization."
              },
              {
                "type": "null"
              }
            ]
          },
          "environment": {
            "$ref": "#/components/schemas/EnvironmentId",
            "description": "The environment it spends in."
          },
          "id": {
            "$ref": "#/components/schemas/KeyId",
            "description": "The key's id."
          },
          "name": {
            "$ref": "#/components/schemas/KeyName",
            "description": "Who holds it."
          },
          "role": {
            "$ref": "#/components/schemas/KeyRole",
            "description": "What it may do."
          }
        }
      },
      "KeyId": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "KeyName": {
        "type": "string",
        "maxLength": 64,
        "minLength": 1
      },
      "KeyNotFound": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "KeyNotFound"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "KeyRequest": {
        "type": "object",
        "description": "A request to create a key.",
        "required": [
          "name",
          "role"
        ],
        "properties": {
          "app": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AppId",
                "description": "The app the key spends for, fixed once it is created. Null (or absent) is a key for the\norganization."
              },
              {
                "type": "null"
              }
            ]
          },
          "environment": {
            "$ref": "#/components/schemas/EnvironmentId",
            "description": "The environment the key spends in, fixed once it is created. Absent is production; null\nis refused."
          },
          "name": {
            "$ref": "#/components/schemas/KeyName",
            "description": "Who holds the key, such as the service that sends it."
          },
          "role": {
            "$ref": "#/components/schemas/KeyRole",
            "description": "What it may do."
          }
        },
        "additionalProperties": false
      },
      "KeyRole": {
        "type": "string",
        "description": "What a key may do: a spender key reserves, settles, and reads; a manager key also defines\napps, meters, prices, and budgets.",
        "enum": [
          "spender",
          "manager"
        ]
      },
      "Kind": {
        "type": "string",
        "maxLength": 64,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "LabelFilter": {
        "type": "object",
        "additionalProperties": {
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 256,
            "minLength": 1
          },
          "maxItems": 100,
          "minItems": 1
        },
        "maxProperties": 16
      },
      "LabelKey": {
        "type": "string",
        "maxLength": 64,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "Labels": {
        "type": "object",
        "additionalProperties": {
          "type": "string",
          "maxLength": 256,
          "minLength": 1
        },
        "maxProperties": 16
      },
      "LastAdmin": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "person"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "LastAdmin"
            ]
          },
          "message": {
            "type": "string"
          },
          "person": {
            "type": "string",
            "maxLength": 64,
            "pattern": "^user_[A-Za-z0-9]+$"
          }
        }
      },
      "LinkStart": {
        "type": "object",
        "description": "Where to send the person to link a provider's account to theirs: the provider's own sign-in\npage, which sends them back to Tidegate to finish.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "The provider's authorization URL."
          }
        }
      },
      "Member": {
        "type": "object",
        "description": "A person in an organization, with their role there.",
        "required": [
          "person",
          "email",
          "role"
        ],
        "properties": {
          "email": {
            "$ref": "#/components/schemas/Email",
            "description": "Their email address."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name, as Google gives it, or null until they first sign in."
          },
          "person": {
            "$ref": "#/components/schemas/PersonId",
            "description": "Who they are."
          },
          "role": {
            "$ref": "#/components/schemas/PersonRole",
            "description": "Their role."
          }
        }
      },
      "MemberConflict": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "email"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "MemberConflict"
            ]
          },
          "email": {
            "type": "string",
            "maxLength": 254,
            "pattern": "^[^\\sA-Z@]+@[^\\sA-Z@]+\\.[^\\sA-Z@]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "MemberDescription": {
        "type": "object",
        "description": "What a membership is, as its history records it. Plain strings: the history keeps what it\nrecorded, whatever the rules were then.",
        "required": [
          "person",
          "email",
          "role"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "Their email address."
          },
          "person": {
            "type": "string",
            "description": "The person's id."
          },
          "role": {
            "$ref": "#/components/schemas/PersonRole",
            "description": "Their role."
          }
        }
      },
      "MemberNotFound": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "person"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "MemberNotFound"
            ]
          },
          "message": {
            "type": "string"
          },
          "person": {
            "type": "string",
            "maxLength": 64,
            "pattern": "^user_[A-Za-z0-9]+$"
          }
        }
      },
      "MemberRequest": {
        "type": "object",
        "description": "A request to add the person with this email to an organization, whether or not they have\nsigned in yet.",
        "required": [
          "email",
          "role"
        ],
        "properties": {
          "email": {
            "$ref": "#/components/schemas/Email",
            "description": "Their email address, in lower case."
          },
          "role": {
            "$ref": "#/components/schemas/PersonRole",
            "description": "Their role."
          }
        },
        "additionalProperties": false
      },
      "MembershipNeedsAcceptance": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "MembershipNeedsAcceptance"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "MeterConflict": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "MeterConflict"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "MeterDefinition": {
        "type": "object",
        "description": "A meter's definition: the request to define one, and the response.",
        "required": [
          "id",
          "vendor",
          "vendorMeter"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/MeterId",
            "description": "The meter's id."
          },
          "vendor": {
            "$ref": "#/components/schemas/Vendor",
            "description": "The vendor that charges for this meter, such as `openai`."
          },
          "vendorMeter": {
            "$ref": "#/components/schemas/VendorMeter",
            "description": "The vendor's own name for what this meter counts, used to match the vendor's usage\nreports."
          }
        },
        "additionalProperties": false
      },
      "MeterHasSpend": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "MeterHasSpend"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "MeterId": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "MeterNotFound": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "MeterNotFound"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "MeterSet": {
        "type": "array",
        "items": {
          "type": "string",
          "maxLength": 128,
          "minLength": 1,
          "pattern": "^[A-Za-z0-9._:-]+$"
        },
        "maxItems": 100,
        "minItems": 1,
        "uniqueItems": true
      },
      "MetersMismatch": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "MetersMismatch"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Microdollars": {
        "type": "integer",
        "maximum": 9007199254740991,
        "minimum": 0
      },
      "MonthCount": {
        "type": "integer",
        "maximum": 1200,
        "minimum": 1
      },
      "NotAdmitted": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "code"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "NotAdmitted"
            ]
          },
          "code": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "string"
              }
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "OrganizationName": {
        "type": "string",
        "maxLength": 100,
        "minLength": 1,
        "pattern": "\\S"
      },
      "Param": {
        "type": "string",
        "maxLength": 4096,
        "minLength": 0
      },
      "PayloadTooLarge": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "PayloadTooLarge"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "PersonId": {
        "type": "string",
        "maxLength": 64,
        "pattern": "^user_[A-Za-z0-9]+$"
      },
      "PersonRole": {
        "type": "string",
        "description": "A person's role in an organization: an admin manages it, and a member only reads.",
        "enum": [
          "admin",
          "member"
        ]
      },
      "Price": {
        "type": "object",
        "description": "What a meter's units cost from `startsAt` on: `microdollars` for every `units` of them, as\nvendors quote \"$2.50 per million tokens\". A price lasts until the meter's next one starts.\nThe request to set one, and the response.",
        "required": [
          "meter",
          "startsAt",
          "microdollars",
          "units"
        ],
        "properties": {
          "meter": {
            "$ref": "#/components/schemas/MeterId",
            "description": "The meter it prices."
          },
          "microdollars": {
            "$ref": "#/components/schemas/Microdollars",
            "description": "The cost of `units` of the meter's units, in micro-dollars (millionths of a dollar)."
          },
          "startsAt": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "When it starts, in epoch milliseconds."
          },
          "units": {
            "$ref": "#/components/schemas/Units",
            "description": "How many units cost `microdollars`, so a unit may cost less than a micro-dollar."
          }
        },
        "additionalProperties": false
      },
      "PriceConflict": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "meter",
          "startsAt"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "PriceConflict"
            ]
          },
          "message": {
            "type": "string"
          },
          "meter": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "startsAt": {
            "type": "integer",
            "maximum": 253402300799999,
            "minimum": 0
          }
        }
      },
      "PriceInUse": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "meter",
          "startsAt",
          "budget"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "PriceInUse"
            ]
          },
          "budget": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          },
          "meter": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "startsAt": {
            "type": "integer",
            "maximum": 253402300799999,
            "minimum": 0
          }
        }
      },
      "PriceNotFound": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "meter",
          "startsAt"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "PriceNotFound"
            ]
          },
          "message": {
            "type": "string"
          },
          "meter": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "startsAt": {
            "type": "integer",
            "maximum": 253402300799999,
            "minimum": 0
          }
        }
      },
      "ProviderOff": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "provider"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "ProviderOff"
            ]
          },
          "message": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "description": "A provider a person signs in with. Google signs in anyone an organization added by email;\nGitHub signs in only someone who linked their GitHub account from a signed-in session.",
            "enum": [
              "google",
              "github"
            ]
          }
        }
      },
      "Quantities": {
        "type": "object",
        "additionalProperties": {
          "type": "integer",
          "maximum": 9007199254740991,
          "minimum": 0
        },
        "maxProperties": 16,
        "minProperties": 1
      },
      "Quantity": {
        "type": "integer",
        "maximum": 9007199254740991,
        "minimum": 0
      },
      "RecordedBudget": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/BudgetDefinition"
          },
          {
            "type": "object",
            "description": "A budget as clients defined one before budgets could count several meters or be in\nmicro-dollars: one meter, in its units.",
            "required": [
              "id",
              "meter",
              "limit",
              "labels",
              "splitBy",
              "window"
            ],
            "properties": {
              "app": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/AppId",
                    "description": "The budget counts only the reservations this app's keys make. Null counts every\nreservation, whichever app's key made it, or a key without one. Absent is null."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "environment": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/EnvironmentId",
                    "description": "The budget counts only the reservations made in this environment. Null counts every\nenvironment's. Absent is null."
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "id": {
                "$ref": "#/components/schemas/BudgetId",
                "description": "The budget's id."
              },
              "labels": {
                "$ref": "#/components/schemas/Labels",
                "description": "The budget counts only reservations that carry every one of these labels."
              },
              "limit": {
                "$ref": "#/components/schemas/Quantity",
                "description": "The most spend each window may hold, in the meter's units."
              },
              "meter": {
                "$ref": "#/components/schemas/MeterId",
                "description": "The one meter it counts, in its units."
              },
              "splitBy": {
                "$ref": "#/components/schemas/SplitKeys",
                "description": "Counted apart for each value of these labels; a reservation without one of them is not\ncounted."
              },
              "window": {
                "$ref": "#/components/schemas/BudgetWindow",
                "description": "Its windows."
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "Reservation": {
        "type": "object",
        "description": "A granted reservation.",
        "required": [
          "id",
          "reservedAt"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/ReservationId",
            "description": "The reservation's id."
          },
          "reservedAt": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "When it was made."
          }
        }
      },
      "ReservationConflict": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "ReservationConflict"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ReservationId": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9._:-]+$"
      },
      "ReservationNotFound": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "id"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "ReservationNotFound"
            ]
          },
          "id": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ReserveRequest": {
        "type": "object",
        "description": "A request to reserve quantities of one or more meters against every budget that counts them.",
        "required": [
          "id",
          "quantities",
          "labels"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/ReservationId",
            "description": "Chosen by the caller, so a retried reserve finds the reservation it already made."
          },
          "labels": {
            "$ref": "#/components/schemas/Labels",
            "description": "Labels budgets can match, such as `member` or `job`. Required, though it may be empty."
          },
          "quantities": {
            "$ref": "#/components/schemas/Quantities",
            "description": "The estimated quantity of each meter the call charges."
          }
        },
        "additionalProperties": false
      },
      "Retention": {
        "type": "object",
        "description": "The organization's retention, as the API reports it.",
        "properties": {
          "keptSince": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Timestamp",
                "description": "Where the organization's spend starts being whole: every reservation made from it on is\nkept, and spend reports count only those. Null until a purge first runs under a retention\nwindow; from then on nothing before it is kept, whether or not there was anything to\ndelete. It only moves forward."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "SafeInt": {
        "type": "integer",
        "maximum": 9007199254740991,
        "minimum": -9007199254740991
      },
      "SetLimit": {
        "type": "object",
        "description": "A request to change a budget's limit (`PUT …/budgets/{id}/limit`).",
        "required": [
          "limit"
        ],
        "properties": {
          "limit": {
            "$ref": "#/components/schemas/Quantity",
            "description": "The new limit, in the budget's unit, from the next reservation on."
          }
        },
        "additionalProperties": false
      },
      "SetRole": {
        "type": "object",
        "description": "A request to change a member's role (`PUT …/members/{person}/role`).",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "$ref": "#/components/schemas/PersonRole",
            "description": "The new role."
          }
        },
        "additionalProperties": false
      },
      "SetStatus": {
        "type": "object",
        "description": "A request to change a budget's status (`PUT …/budgets/{id}/status`).",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/BudgetStatus",
            "description": "The status the budget takes now: `frozen` refuses every reservation it counts, `archived`\ntakes it out of effect, and `active` puts it back in effect."
          }
        },
        "additionalProperties": false
      },
      "SettleRequest": {
        "type": "object",
        "description": "A request to settle a reservation at the actual quantities.",
        "required": [
          "id",
          "quantities"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/ReservationId",
            "description": "The reservation's id."
          },
          "quantities": {
            "$ref": "#/components/schemas/Quantities",
            "description": "The actual quantities, for exactly the meters the reservation charged."
          }
        },
        "additionalProperties": false
      },
      "Settlement": {
        "type": "object",
        "description": "A settled reservation.",
        "required": [
          "id",
          "settledAt"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/ReservationId",
            "description": "The reservation's id."
          },
          "settledAt": {
            "$ref": "#/components/schemas/Timestamp",
            "description": "When it was settled."
          }
        }
      },
      "SignInAgain": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "SignInAgain"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "SignInProvider": {
        "type": "string",
        "description": "A provider a person signs in with. Google signs in anyone an organization added by email;\nGitHub signs in only someone who linked their GitHub account from a signed-in session.",
        "enum": [
          "google",
          "github"
        ]
      },
      "SignInProviders": {
        "type": "object",
        "description": "The providers this Tidegate signs people in with: Google always, and GitHub when it is\nconfigured. The sign-in page offers each.",
        "required": [
          "providers"
        ],
        "properties": {
          "providers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SignInProvider"
            },
            "description": "Each provider, Google first."
          }
        }
      },
      "SpendFilter": {
        "type": "object",
        "description": "Which reservations a spend report counts. Each facet given narrows it to reservations with\none of its values, and the facets apply together. A facet left out counts every value; a\nfacet may not be `null`.",
        "properties": {
          "apps": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/AppId"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Reservations these apps' keys made; null is keys without an app.",
            "maxItems": 100,
            "minItems": 1
          },
          "environments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EnvironmentId"
            },
            "description": "Reservations made in these environments.",
            "maxItems": 100,
            "minItems": 1
          },
          "labels": {
            "$ref": "#/components/schemas/LabelFilter",
            "description": "Reservations carrying one of the given values of each of these label keys."
          },
          "meters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MeterId"
            },
            "description": "Charges to these meters.",
            "maxItems": 100,
            "minItems": 1
          },
          "vendors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Vendor"
            },
            "description": "Charges to these vendors' meters.",
            "maxItems": 100,
            "minItems": 1
          }
        },
        "additionalProperties": false
      },
      "SpendGroupBy": {
        "oneOf": [
          {
            "type": "object",
            "description": "The app whose key made the reservation (null for a key without one).",
            "required": [
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "App"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The environment it was made in.",
            "required": [
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Environment"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The vendor of the meter charged.",
            "required": [
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Vendor"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The meter charged.",
            "required": [
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Meter"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "A label's value (null for reservations without the label).",
            "required": [
              "key",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Label"
                ]
              },
              "key": {
                "$ref": "#/components/schemas/LabelKey",
                "description": "The label's key."
              }
            }
          }
        ],
        "description": "A facet a spend report groups by: each of its values is a group."
      },
      "SpendQuery": {
        "type": "object",
        "description": "A request for a spend report.",
        "required": [
          "boundaries"
        ],
        "properties": {
          "boundaries": {
            "$ref": "#/components/schemas/Boundaries",
            "description": "Where each period starts, then where the last one ends."
          },
          "filter": {
            "$ref": "#/components/schemas/SpendFilter",
            "description": "Which reservations to count. Absent counts every one; null is refused."
          },
          "groupBy": {
            "$ref": "#/components/schemas/GroupBy",
            "description": "The facets to keep spend apart by. Absent is none; null is refused."
          }
        },
        "additionalProperties": false
      },
      "SpendReport": {
        "type": "object",
        "description": "A spend report.",
        "required": [
          "rows",
          "labelKeys"
        ],
        "properties": {
          "keptSince": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Timestamp",
                "description": "Where the organization's kept spend starts, as the report read it: it counts only\nreservations made from then on, since older ones are no longer kept, and spend before it\nisn't zero but unknown. Null until a purge first runs under a retention window."
              },
              {
                "type": "null"
              }
            ]
          },
          "labelKeys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LabelKey"
            },
            "description": "The label keys on the reservations the filter counts, to group or filter by."
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SpendRow"
            },
            "description": "Every period, group, and meter with spend, by period, then group, then meter."
          }
        }
      },
      "SpendRow": {
        "type": "object",
        "description": "Spend in one period, on one meter, by one group. Each reservation counts at its settled\nquantity, or its estimate until it settles, in the period it was made in, priced at its\nmeter's price then.",
        "required": [
          "group",
          "period",
          "meter",
          "quantity",
          "microdollars",
          "unpriced"
        ],
        "properties": {
          "group": {
            "type": "array",
            "items": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": "The group: its value of each facet the query groups by, in the query's order. Null for\nreservations without one: a key without an app, or no such label. Empty for a report\nthat doesn't group."
          },
          "meter": {
            "$ref": "#/components/schemas/MeterId",
            "description": "The meter."
          },
          "microdollars": {
            "type": "integer",
            "format": "int64",
            "description": "What the priced part of `quantity` cost, capped at 2^53 − 1.",
            "minimum": 0
          },
          "period": {
            "type": "integer",
            "format": "int32",
            "description": "The period, by its place among the query's: 0 is the first.",
            "minimum": 0
          },
          "quantity": {
            "type": "integer",
            "format": "int64",
            "description": "The quantity, capped at 2^53 − 1.",
            "minimum": 0
          },
          "unpriced": {
            "type": "integer",
            "format": "int64",
            "description": "The part of `quantity` reserved while its meter had no price, capped at 2^53 − 1.",
            "minimum": 0
          }
        }
      },
      "Split": {
        "type": "object",
        "additionalProperties": {
          "type": "string",
          "maxLength": 256,
          "minLength": 1
        },
        "maxProperties": 4
      },
      "SplitKeys": {
        "type": "array",
        "items": {
          "type": "string",
          "maxLength": 64,
          "minLength": 1,
          "pattern": "^[A-Za-z0-9._:-]+$"
        },
        "maxItems": 4,
        "uniqueItems": true
      },
      "Summary": {
        "type": "string",
        "maxLength": 500,
        "minLength": 1,
        "pattern": "^[^\\n\\r\\u2028\\u2029]+$"
      },
      "TenantId": {
        "type": "string",
        "maxLength": 64,
        "pattern": "^org_[A-Za-z0-9]+$"
      },
      "Through": {
        "oneOf": [
          {
            "type": "object",
            "description": "An agent they let in, by the name its OAuth client registered with. The history keeps\nthe name it recorded, so it is a plain string.",
            "required": [
              "client",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Agent"
                ]
              },
              "client": {
                "type": "string",
                "description": "The agent's name."
              }
            }
          },
          {
            "type": "object",
            "description": "A kind of access the deployment names, such as `staff`.",
            "required": [
              "kind",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Deployment"
                ]
              },
              "kind": {
                "$ref": "#/components/schemas/Kind",
                "description": "The kind."
              }
            }
          }
        ],
        "description": "What a person acted through, when not the pages."
      },
      "Timestamp": {
        "type": "integer",
        "maximum": 253402300799999,
        "minimum": 0
      },
      "TooManyRequests": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "retryAfter"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "TooManyRequests"
            ]
          },
          "message": {
            "type": "string"
          },
          "retryAfter": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "Unauthorized": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "Unauthorized"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Unavailable": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "code",
          "retryAfter"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "Unavailable"
            ]
          },
          "code": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "string"
              }
            ]
          },
          "message": {
            "type": "string"
          },
          "retryAfter": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "integer",
                "format": "int32",
                "minimum": 0
              }
            ]
          }
        }
      },
      "Units": {
        "type": "integer",
        "maximum": 9007199254740991,
        "minimum": 1
      },
      "UnknownApp": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "app"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "UnknownApp"
            ]
          },
          "app": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "UnknownMeter": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "meter"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "UnknownMeter"
            ]
          },
          "message": {
            "type": "string"
          },
          "meter": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          }
        }
      },
      "UnpricedMeter": {
        "type": "object",
        "required": [
          "_tag",
          "message",
          "meter",
          "budget"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "UnpricedMeter"
            ]
          },
          "budget": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "message": {
            "type": "string"
          },
          "meter": {
            "type": "string",
            "maxLength": 128,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9._:-]+$"
          }
        }
      },
      "UnsupportedMediaType": {
        "type": "object",
        "required": [
          "_tag",
          "message"
        ],
        "properties": {
          "_tag": {
            "type": "string",
            "enum": [
              "UnsupportedMediaType"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Vendor": {
        "type": "string",
        "maxLength": 64,
        "minLength": 1
      },
      "VendorMeter": {
        "type": "string",
        "maxLength": 128,
        "minLength": 1
      },
      "Window": {
        "type": "object",
        "description": "One of a budget's windows: from `start` up to, not including, `end`, in epoch milliseconds.\nA window that holds an early moment may start before 1970, so these are plain integers.",
        "required": [
          "start",
          "end"
        ],
        "properties": {
          "end": {
            "type": "integer",
            "format": "int64",
            "description": "Where the next one starts."
          },
          "start": {
            "type": "integer",
            "format": "int64",
            "description": "Where it starts."
          }
        }
      },
      "WindowLength": {
        "oneOf": [
          {
            "type": "object",
            "description": "A number of calendar months (UTC).",
            "required": [
              "count",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Months"
                ]
              },
              "count": {
                "$ref": "#/components/schemas/MonthCount",
                "description": "How many: 1 to 1200."
              }
            }
          },
          {
            "type": "object",
            "description": "A fixed number of milliseconds.",
            "required": [
              "milliseconds",
              "_tag"
            ],
            "properties": {
              "_tag": {
                "type": "string",
                "enum": [
                  "Duration"
                ]
              },
              "milliseconds": {
                "$ref": "#/components/schemas/DurationMs",
                "description": "How many: 1 to a century."
              }
            }
          }
        ],
        "description": "How long each of a budget's windows lasts."
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "tags": [
    {
      "name": "system"
    },
    {
      "name": "account"
    },
    {
      "name": "tenant"
    }
  ],
  "externalDocs": {
    "url": "https://attune.inc/tidegate/guide",
    "description": "Tidegate's user guide"
  }
}
