{
  "openapi": "3.1.0",
  "info": {
    "title": "LedgerUp API",
    "version": "0.1.0",
    "description": "OpenAPI contract for the LedgerUp API."
  },
  "tags": [
    {
      "name": "Health"
    },
    {
      "name": "Customers"
    },
    {
      "name": "Accounts"
    },
    {
      "name": "Grants"
    },
    {
      "name": "Currencies",
      "description": "Currencies discovered from reported usage events."
    },
    {
      "name": "Metrics"
    },
    {
      "name": "Refill Configurations",
      "description": "Automatic balance refill thresholds and targets for an account and metric."
    },
    {
      "name": "Events",
      "description": "Individual usage events reported against an account and either a metric or currency."
    },
    {
      "name": "Querying",
      "description": "Aggregated usage queries across metrics, currencies, and event properties."
    },
    {
      "name": "Test",
      "description": "Endpoints for test environment maintenance."
    },
    {
      "name": "Products",
      "x-group": "Billing",
      "description": "Sellable catalog objects. Products can map to Stripe products."
    },
    {
      "name": "Prices",
      "x-group": "Billing",
      "description": "Simple commercial terms for a product."
    },
    {
      "name": "Rate Cards",
      "x-group": "Billing",
      "description": "Reusable rating policies that convert engine facts into billable amounts."
    },
    {
      "name": "Contracts",
      "x-group": "Billing",
      "description": "Subscription-like commercial agreements. Contracts own contract lines and cancellation state."
    },
    {
      "name": "Invoice Preview",
      "x-group": "Billing"
    }
  ],
  "paths": {
    "/v2": {
      "get": {
        "tags": [
          "Health"
        ],
        "operationId": "getV2Root",
        "summary": "Health check.",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is healthy.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "x-hidden": true
      }
    },
    "/v2/": {
      "get": {
        "tags": [
          "Health"
        ],
        "operationId": "getV2RootSlash",
        "summary": "Health check.",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is healthy.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "x-hidden": true
      }
    },
    "/v2/health": {
      "get": {
        "tags": [
          "Health"
        ],
        "operationId": "getV2Health",
        "summary": "Check API health.",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is healthy.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v2/health/": {
      "get": {
        "tags": [
          "Health"
        ],
        "operationId": "getV2HealthSlash",
        "summary": "Health check.",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is healthy.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "x-hidden": true
      }
    },
    "/v2/accounts": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "listAccounts",
        "summary": "List accounts.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Return records following this resource id in the selected sort order."
            },
            "description": "Cursor resource id from the previous page."
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "customer_name"
              ],
              "default": "created_at"
            },
            "description": "Sort by newest creation time or case-insensitive customer name then account name. Accounts without a customer sort last."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of resources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "createAccount",
        "summary": "Create an account.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/accounts/external-id/{external_id}": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountByExternalId",
        "summary": "Retrieve an account by external_id.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "external_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Caller-supplied external identifier. Maximum 256 Unicode scalar values.",
              "maxLength": 256,
              "example": "crm_acme_001"
            },
            "description": "External identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/accounts/{account_id}": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccount",
        "summary": "Retrieve an account.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "patch": {
        "tags": [
          "Accounts"
        ],
        "operationId": "updateAccount",
        "summary": "Update an account.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/accounts/{account_id}/usage": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountUsage",
        "summary": "Get account usage for a time range.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          },
          {
            "name": "start_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Inclusive lower bound for event occurrence time."
          },
          {
            "name": "end_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Exclusive upper bound for event occurrence time."
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            },
            "description": "Aggregation applied to corrected usage events. Defaults to sum."
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Aggregate only events for this currency. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Account and usage aggregated by metric or currency.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountUsage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/accounts/{account_id}/usage/monthly": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountMonthlyUsage",
        "summary": "Get all monthly usage for an account.",
        "description": "Returns raw metric quantities from one ClickHouse query. No PostgreSQL query is performed.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            }
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Aggregate only events for this currency. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Account usage grouped by UTC calendar month and metric.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountMonthlyUsage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/accounts/{account_id}/usage/daily": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountDailyUsage",
        "summary": "Get account usage by UTC day for a time range.",
        "description": "Returns every UTC calendar day intersecting the requested half-open range. Days without usage have an empty data array.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            }
          },
          {
            "name": "start_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Inclusive lower bound for event occurrence time."
          },
          {
            "name": "end_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Exclusive upper bound for event occurrence time."
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Aggregate only events for this currency. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Raw metric quantities for every UTC day in the requested range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDailyUsage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/accounts/usage": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "listAccountUsage",
        "summary": "List accounts with usage for a time range.",
        "description": "Returns a page of accounts with usage aggregated by metric or currency. Metric sorting requires exactly one of metric_id or currency.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "start_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Inclusive lower bound for event occurrence time."
          },
          {
            "name": "end_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Exclusive upper bound for event occurrence time."
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Return the next records after this account id."
            },
            "description": "Cursor account id from the previous page."
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "created_at",
                "customer_name",
                "metric_ascending",
                "metric_descending"
              ],
              "default": "created_at"
            },
            "description": "Account ordering. Metric ordering requires metric_id or currency."
          },
          {
            "name": "metric_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "LedgerUp metric identifier.",
              "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^metric_[0-9a-f]{32}$"
            },
            "description": "Metric used for metric_ascending or metric_descending sorting."
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Currency used for metric_ascending or metric_descending sorting. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of accounts and aggregated usage.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountUsageList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/accounts/usage/lifetime": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountLifetimeUsage",
        "summary": "Retrieve lifetime usage for multiple accounts.",
        "description": "Returns corrected lifetime usage totals in one ClickHouse query for up to 100 accounts. No PostgreSQL query is performed.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_ids",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated LedgerUp account identifiers. Between 1 and 100 unique ids."
          }
        ],
        "responses": {
          "200": {
            "description": "Lifetime usage grouped by account and metric or currency.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountLifetimeUsage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/accounts/balances": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountBalances",
        "summary": "Retrieve balances for multiple accounts and all active usage sources.",
        "description": "Returns active grant totals, corrected usage totals, and balances for every active metric and granted currency across up to 100 accounts. The PostgreSQL and ClickHouse aggregates run in parallel.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_ids",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated LedgerUp account identifiers. Between 1 and 100 unique ids."
          }
        ],
        "responses": {
          "200": {
            "description": "Balances for the requested accounts and all active metrics and granted currencies.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AccountBalance"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/accounts/{account_id}/balance": {
      "get": {
        "tags": [
          "Accounts"
        ],
        "operationId": "getAccountBalance",
        "summary": "Retrieve an account balance for a usage source.",
        "description": "Returns active, effective, non-expired grants for the requested metric or currency minus corrected all-time usage for that source.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          },
          {
            "name": "metric_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "LedgerUp metric identifier.",
              "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^metric_[0-9a-f]{32}$"
            },
            "description": "Metric whose usage is subtracted from the account grants. Exactly one of metric_id or currency is required."
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Currency whose usage is subtracted from currency grants. Exactly one of metric_id or currency is required."
          }
        ],
        "responses": {
          "200": {
            "description": "Account balance for the requested metric or currency.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountBalance"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/grants": {
      "post": {
        "tags": [
          "Grants"
        ],
        "operationId": "createGrant",
        "summary": "Create a grant.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GrantRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Grant"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      },
      "get": {
        "tags": [
          "Grants"
        ],
        "operationId": "listGrants",
        "summary": "List grants.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Return records created after this resource id, ordered by created_at then id."
            },
            "description": "Cursor resource id from the previous page."
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Return only grants for this currency. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of resources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrantList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/grants/{grant_id}": {
      "get": {
        "tags": [
          "Grants"
        ],
        "operationId": "getGrant",
        "summary": "Retrieve a grant.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "grant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp grant identifier.",
              "example": "grant_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^grant_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Grant"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/grant-voids": {
      "get": {
        "tags": [
          "Grants"
        ],
        "operationId": "listGrantVoids",
        "summary": "List grant void records.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Return the next records after this grant void id, ordered by created_at then id."
            },
            "description": "Cursor resource id from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of grant void records.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrantVoidList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/grant-voids/{grant_void_id}": {
      "get": {
        "tags": [
          "Grants"
        ],
        "operationId": "getGrantVoid",
        "summary": "Retrieve a grant void record.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "grant_void_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp grant void identifier.",
              "example": "grant_void_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^grant_void_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Grant void record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrantVoid"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/currencies": {
      "get": {
        "tags": [
          "Currencies"
        ],
        "operationId": "listCurrencies",
        "summary": "List currencies with reported usage.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Currencies observed in usage events for this company and namespace.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrencyList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/metrics": {
      "get": {
        "tags": [
          "Metrics"
        ],
        "operationId": "listMetrics",
        "summary": "List metrics.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Return records created after this resource id, ordered by created_at then id."
            },
            "description": "Cursor resource id from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of resources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "post": {
        "tags": [
          "Metrics"
        ],
        "operationId": "createMetric",
        "summary": "Create a metric.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetricRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/metrics/usage/monthly": {
      "get": {
        "tags": [
          "Querying"
        ],
        "operationId": "getMetricMonthlyUsage",
        "summary": "Monthly usage by metric",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "start_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Inclusive lower bound for event occurrence time."
          },
          {
            "name": "end_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Exclusive upper bound for event occurrence time."
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            }
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Aggregate only events for this currency. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Namespace usage grouped by UTC calendar month and metric or currency.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricMonthlyUsage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/metrics/{metric_id}/usage/monthly": {
      "get": {
        "tags": [
          "Querying"
        ],
        "operationId": "getSingleMetricMonthlyUsage",
        "summary": "Monthly usage for one metric",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "metric_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^(metric_[0-9a-f]{32}|[A-Za-z]{3})$",
              "example": "usd"
            },
            "description": "LedgerUp metric identifier or three-letter currency code."
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Metric or currency usage grouped by UTC calendar month.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricMonthlyUsage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/metrics/{metric_id}": {
      "get": {
        "tags": [
          "Metrics"
        ],
        "operationId": "getMetric",
        "summary": "Retrieve a metric.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "metric_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp metric identifier.",
              "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^metric_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "patch": {
        "tags": [
          "Metrics"
        ],
        "operationId": "updateMetric",
        "summary": "Update a metric description.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "metric_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp metric identifier.",
              "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^metric_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetricUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metric"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/refill-configurations": {
      "get": {
        "tags": [
          "Refill Configurations"
        ],
        "operationId": "listRefillConfigurations",
        "summary": "List refill configurations.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Refill configurations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefillConfigurationList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "post": {
        "tags": [
          "Refill Configurations"
        ],
        "operationId": "createRefillConfiguration",
        "summary": "Create a refill configuration.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefillConfigurationRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefillConfiguration"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/refill-configurations/{account_id}/{metric_id}": {
      "get": {
        "tags": [
          "Refill Configurations"
        ],
        "operationId": "getRefillConfiguration",
        "summary": "Retrieve a refill configuration.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            },
            "description": "Account identifier."
          },
          {
            "name": "metric_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp metric identifier.",
              "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^metric_[0-9a-f]{32}$"
            },
            "description": "Metric identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefillConfiguration"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "patch": {
        "tags": [
          "Refill Configurations"
        ],
        "operationId": "updateRefillConfiguration",
        "summary": "Update a refill configuration.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            },
            "description": "Account identifier."
          },
          {
            "name": "metric_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp metric identifier.",
              "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^metric_[0-9a-f]{32}$"
            },
            "description": "Metric identifier."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefillConfigurationUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefillConfiguration"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/events": {
      "post": {
        "tags": [
          "Events"
        ],
        "operationId": "createEvent",
        "summary": "Queue a usage event for creation.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted and queued.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      },
      "get": {
        "tags": [
          "Events"
        ],
        "operationId": "listEvents",
        "summary": "List usage events.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Return the next records after this event id, ordered by accepted_at then id."
            },
            "description": "Cursor resource id from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of resources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/events/aggregate": {
      "get": {
        "tags": [
          "Querying"
        ],
        "operationId": "aggregateEventsByProperty",
        "summary": "Usage by event property",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "property",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_]+$",
              "maxLength": 100
            },
            "example": "ari_job_id"
          },
          {
            "name": "value",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            },
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            }
          },
          {
            "name": "start_at",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Inclusive lower bound for event occurrence time. Defaults to five years before the request."
          },
          {
            "name": "end_at",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Exclusive upper bound for event occurrence time. Defaults to the request time."
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Aggregate only matching events for this currency. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Metric totals for matching usage events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PropertyUsage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/events/aggregate/daily": {
      "get": {
        "tags": [
          "Events"
        ],
        "operationId": "aggregateDailyEventsByProperty",
        "summary": "Aggregate usage event quantities by UTC day for a property.",
        "description": "Returns every UTC calendar day intersecting the requested half-open range. Days without matching events have an empty data array.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "property",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_]+$",
              "maxLength": 100
            },
            "example": "ari_job_id"
          },
          {
            "name": "value",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            },
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          },
          {
            "name": "aggregation",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/UsageAggregation"
            }
          },
          {
            "name": "start_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Inclusive lower bound for event occurrence time."
          },
          {
            "name": "end_at",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/UnixTimestamp"
            },
            "description": "Exclusive upper bound for event occurrence time."
          },
          {
            "name": "currency",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{3}$",
              "example": "usd"
            },
            "description": "Aggregate only matching events for this currency. Normalized to lowercase."
          }
        ],
        "responses": {
          "200": {
            "description": "Metric usage for every UTC day in the requested range.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DailyPropertyUsage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/events/{event_id}": {
      "get": {
        "tags": [
          "Events"
        ],
        "operationId": "getEvent",
        "summary": "Retrieve a usage event.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "event_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp event identifier.",
              "example": "event_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^event_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Event"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/reset": {
      "post": {
        "tags": [
          "Test"
        ],
        "operationId": "resetNamespace",
        "summary": "Reset the test namespace.",
        "description": "Queues deletion of all usage data in the authenticated test namespace. Only test API keys can call this endpoint.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "202": {
            "description": "Test namespace reset accepted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/customers": {
      "get": {
        "tags": [
          "Customers"
        ],
        "operationId": "listCustomers",
        "summary": "List customers.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Return records created after this resource id, ordered by created_at then id."
            },
            "description": "Cursor resource id from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "Page of resources.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "post": {
        "tags": [
          "Customers"
        ],
        "operationId": "createCustomer",
        "summary": "Create a customer.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/customers/external-id/{external_id}": {
      "get": {
        "tags": [
          "Customers"
        ],
        "operationId": "getCustomerByExternalId",
        "summary": "Retrieve a customer by external id.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "external_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Caller-supplied external identifier.",
              "maxLength": 256,
              "example": "crm_acme_001"
            },
            "description": "External customer identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      }
    },
    "/v2/customers/{customer_id}": {
      "get": {
        "tags": [
          "Customers"
        ],
        "operationId": "getCustomer",
        "summary": "Retrieve a customer.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp customer UUID.",
              "example": "018f5f0c-1111-7abc-8def-123456789abc",
              "pattern": "^[0-9a-fA-F-]{36}$"
            },
            "description": "Customer UUID."
          }
        ],
        "responses": {
          "200": {
            "description": "Resource found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all"
      },
      "patch": {
        "tags": [
          "Customers"
        ],
        "operationId": "updateCustomer",
        "summary": "Update a customer.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "customer_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "description": "LedgerUp customer UUID.",
              "example": "018f5f0c-1111-7abc-8def-123456789abc"
            },
            "description": "Customer UUID."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/accounts/{account_id}/archive": {
      "post": {
        "tags": [
          "Accounts"
        ],
        "operationId": "archiveAccount",
        "summary": "Archive an account.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp account identifier.",
              "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^account_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "204": {
            "description": "Archived."
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/grants/{grant_id}/archive": {
      "post": {
        "tags": [
          "Grants"
        ],
        "operationId": "archiveGrant",
        "summary": "Archive a grant.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "grant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp grant identifier.",
              "example": "grant_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^grant_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "204": {
            "description": "Archived."
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/grants/{grant_id}/void": {
      "post": {
        "tags": [
          "Grants"
        ],
        "operationId": "voidGrant",
        "summary": "Void a grant.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "grant_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp grant identifier.",
              "example": "grant_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^grant_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Voided.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Grant"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "409": {
            "$ref": "#/components/responses/ConflictText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/metrics/{metric_id}/archive": {
      "post": {
        "tags": [
          "Metrics"
        ],
        "operationId": "archiveMetric",
        "summary": "Archive a metric.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "metric_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "LedgerUp metric identifier.",
              "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
              "pattern": "^metric_[0-9a-f]{32}$"
            },
            "description": "Resource identifier."
          }
        ],
        "responses": {
          "204": {
            "description": "Archived."
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "404": {
            "$ref": "#/components/responses/NotFoundText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all"
      }
    },
    "/v2/products": {
      "get": {
        "tags": [
          "Products"
        ],
        "operationId": "listProducts",
        "summary": "List products.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Cursor resource id from the previous page."
          }
        ]
      },
      "post": {
        "tags": [
          "Products"
        ],
        "operationId": "createProduct",
        "summary": "Create a product.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductRequest"
              }
            }
          }
        }
      }
    },
    "/v2/products/{product_id}": {
      "get": {
        "tags": [
          "Products"
        ],
        "operationId": "getProduct",
        "summary": "Get a product.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "tags": [
          "Products"
        ],
        "operationId": "updateProduct",
        "summary": "Update a product.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProductUpdateRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/products/{product_id}/archive": {
      "post": {
        "tags": [
          "Products"
        ],
        "operationId": "archiveProduct",
        "summary": "Archive a product.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "parameters": [
          {
            "name": "product_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/prices": {
      "get": {
        "tags": [
          "Prices"
        ],
        "operationId": "listPrices",
        "summary": "List prices.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Cursor resource id from the previous page."
          }
        ]
      },
      "post": {
        "tags": [
          "Prices"
        ],
        "operationId": "createPrice",
        "summary": "Create a price.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Price"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PriceRequest"
              }
            }
          }
        }
      }
    },
    "/v2/prices/{price_id}": {
      "get": {
        "tags": [
          "Prices"
        ],
        "operationId": "getPrice",
        "summary": "Get a price.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Price"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "price_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "tags": [
          "Prices"
        ],
        "operationId": "updatePrice",
        "summary": "Update a price.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Price"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PriceUpdateRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "price_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/prices/{price_id}/archive": {
      "post": {
        "tags": [
          "Prices"
        ],
        "operationId": "archivePrice",
        "summary": "Archive a price.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Price"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "parameters": [
          {
            "name": "price_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/rate-cards": {
      "get": {
        "tags": [
          "Rate Cards"
        ],
        "operationId": "listRateCards",
        "summary": "List rate cards.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateCardList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Cursor resource id from the previous page."
          }
        ]
      },
      "post": {
        "tags": [
          "Rate Cards"
        ],
        "operationId": "createRateCard",
        "summary": "Create a rate card.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateCard"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RateCardRequest"
              }
            }
          }
        }
      }
    },
    "/v2/rate-cards/{rate_card_id}": {
      "get": {
        "tags": [
          "Rate Cards"
        ],
        "operationId": "getRateCard",
        "summary": "Get a rate card.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateCard"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "rate_card_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "tags": [
          "Rate Cards"
        ],
        "operationId": "updateRateCard",
        "summary": "Update a rate card.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateCard"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RateCardUpdateRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "rate_card_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/rate-cards/{rate_card_id}/archive": {
      "post": {
        "tags": [
          "Rate Cards"
        ],
        "operationId": "archiveRateCard",
        "summary": "Archive a rate card.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateCard"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "parameters": [
          {
            "name": "rate_card_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/contracts": {
      "get": {
        "tags": [
          "Contracts"
        ],
        "operationId": "listContracts",
        "summary": "List contracts.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContractList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Cursor resource id from the previous page."
          }
        ]
      },
      "post": {
        "tags": [
          "Contracts"
        ],
        "operationId": "createContract",
        "summary": "Create a contract.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "description": "Contracts are subscription objects in LedgerUp Engine.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContractRequest"
              }
            }
          }
        }
      }
    },
    "/v2/contracts/{contract_id}": {
      "get": {
        "tags": [
          "Contracts"
        ],
        "operationId": "getContract",
        "summary": "Get a contract.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "tags": [
          "Contracts"
        ],
        "operationId": "updateContract",
        "summary": "Update a contract.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContractUpdateRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/contracts/{contract_id}/cancel": {
      "post": {
        "tags": [
          "Contracts"
        ],
        "operationId": "cancelContract",
        "summary": "Cancel a contract.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contract"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContractCancelRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/contracts/{contract_id}/lines": {
      "get": {
        "tags": [
          "Contracts"
        ],
        "operationId": "listContractLines",
        "summary": "List contract lines.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContractLineList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            },
            "description": "Maximum number of records to return. Defaults to 100."
          },
          {
            "name": "starting_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Cursor resource id from the previous page."
          }
        ]
      },
      "post": {
        "tags": [
          "Contracts"
        ],
        "operationId": "createContractLine",
        "summary": "Create a contract line.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContractLine"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "description": "A contract line maps to invoice line candidates and must reference exactly one of price_id or rate_card_id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContractLineRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/contracts/{contract_id}/lines/{line_id}": {
      "get": {
        "tags": [
          "Contracts"
        ],
        "operationId": "getContractLine",
        "summary": "Get a contract line.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContractLine"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "tags": [
          "Contracts"
        ],
        "operationId": "updateContractLine",
        "summary": "Update a contract line.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContractLine"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContractLineUpdateRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/contracts/{contract_id}/lines/{line_id}/cancel": {
      "post": {
        "tags": [
          "Contracts"
        ],
        "operationId": "cancelContractLine",
        "summary": "Cancel a contract line.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContractLine"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "write:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContractLineCancelRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v2/contracts/{contract_id}/invoice-preview": {
      "post": {
        "tags": [
          "Invoice Preview"
        ],
        "operationId": "previewContractInvoice",
        "summary": "Preview invoice lines for a contract period.",
        "security": [
          {
            "LedgerUpApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePreview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestText"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedText"
          },
          "403": {
            "$ref": "#/components/responses/ForbiddenText"
          },
          "408": {
            "$ref": "#/components/responses/RequestTimeoutText"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLargeText"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaTypeText"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableText"
          },
          "429": {
            "$ref": "#/components/responses/RateLimitedText"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerErrorText"
          }
        },
        "x-required-permission": "read:all",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoicePreviewRequest"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "contract_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "LedgerUpApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "LedgerUp API Key.",
        "x-displayName": "LedgerUp API Key"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "description": "Non-empty idempotency key for deduplicating write requests on the same route.",
          "example": "6f31c20e-725c-4be8-96f4-835042f67602"
        },
        "description": "Optional. Duplicate keys within the same company namespace and route return 409."
      }
    },
    "responses": {
      "BadRequestText": {
        "description": "Bad request, invalid header, invalid amount/quantity/currency, or text validation failure.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "UnauthorizedText": {
        "description": "Missing or invalid API key.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string",
              "example": "Invalid API key"
            }
          }
        }
      },
      "ForbiddenText": {
        "description": "API key lacks the required permission, or reset was attempted outside the test namespace.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "RequestTimeoutText": {
        "description": "Request exceeded the 30 second timeout.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "ConflictText": {
        "description": "Duplicate idempotency key, uniqueness conflict, or foreign-key conflict.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "PayloadTooLargeText": {
        "description": "Request body exceeded the 256 KiB limit.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "UnsupportedMediaTypeText": {
        "description": "Write request content type was not application/json.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "UnprocessableText": {
        "description": "Semantically invalid request, such as a service period with start greater than end.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "RateLimitedText": {
        "description": "Rate limit exceeded.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string",
              "example": "rate limit exceeded"
            }
          }
        }
      },
      "NotFoundText": {
        "description": "Referenced or requested resource was not found.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string",
              "example": "not found"
            }
          }
        }
      },
      "InternalServerErrorText": {
        "description": "Internal server error or queue failure.",
        "content": {
          "text/plain": {
            "schema": {
              "type": "string"
            }
          }
        }
      }
    },
    "schemas": {
      "UnixTimestamp": {
        "type": "integer",
        "format": "int64",
        "description": "Unix timestamp in seconds.",
        "example": 1767225600
      },
      "UsageAggregation": {
        "type": "string",
        "description": "Aggregation applied to corrected usage events. latest returns the quantity from the event with the latest occurred_at; ties use accepted_at then event ID. count returns the number of events.",
        "enum": [
          "sum",
          "min",
          "max",
          "avg",
          "latest",
          "count"
        ],
        "default": "sum",
        "example": "sum"
      },
      "LedgerId": {
        "type": "string",
        "description": "LedgerUp resource identifier.",
        "pattern": "^[a-z_]+_[0-9a-f]{32}$"
      },
      "Properties": {
        "description": "Arbitrary JSON object or value. If omitted on write endpoints, the service stores an empty object.",
        "default": {}
      },
      "AccountRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "Human-readable name. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "Acme"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Maximum 2048 Unicode scalar values.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional caller-supplied external identifier. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "crm_acme_001"
          },
          "ledgerup_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional LedgerUp billing customer UUID.",
            "example": "0194f4e3-a2b7-7c6a-a91c-4f6b4db2a980"
          }
        },
        "required": [
          "name"
        ],
        "description": "Create-account request. Unknown JSON fields are rejected."
      },
      "AccountUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "Human-readable name. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "Acme"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Send null to clear.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional caller-supplied external identifier. Send null to clear.",
            "maxLength": 256,
            "example": "crm_acme_001"
          },
          "ledgerup_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional LedgerUp billing customer UUID. Send null to clear.",
            "example": "0194f4e3-a2b7-7c6a-a91c-4f6b4db2a980"
          }
        },
        "description": "Update-account request. Unknown JSON fields are rejected. Omitted fields are unchanged."
      },
      "Account": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional caller-supplied external identifier. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "crm_acme_001"
          },
          "ledgerup_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional LedgerUp billing customer UUID.",
            "example": "0194f4e3-a2b7-7c6a-a91c-4f6b4db2a980"
          },
          "name": {
            "type": "string",
            "description": "Human-readable name. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "Acme"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Maximum 2048 Unicode scalar values.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "archived_at": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "external_id",
          "ledgerup_customer_id",
          "name",
          "description",
          "created_at",
          "updated_at",
          "archived_at"
        ]
      },
      "AccountMetricUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier, or the lowercase currency code for currency usage.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^(metric_[0-9a-f]{32}|[a-z]{3})$"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lowercase currency code for currency usage. Null for normal metric usage.",
            "example": "usd",
            "pattern": "^[a-z]{3}$"
          },
          "metric_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Metric name. Null for currency usage.",
            "example": "Tokens"
          },
          "measurement_units": {
            "$ref": "#/components/schemas/MeasurementUnits"
          },
          "quantity": {
            "type": "string",
            "description": "Summed decimal quantity serialized as a string.",
            "example": "1250.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          }
        },
        "required": [
          "metric_id",
          "currency",
          "metric_name",
          "measurement_units",
          "quantity"
        ]
      },
      "MetricQuantity": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier, or the lowercase currency code for currency usage.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^(metric_[0-9a-f]{32}|[a-z]{3})$"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lowercase currency code for currency usage. Null for normal metric usage.",
            "example": "usd",
            "pattern": "^[a-z]{3}$"
          },
          "quantity": {
            "type": "string",
            "description": "Aggregated decimal quantity serialized as a string.",
            "example": "1250.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          }
        },
        "required": [
          "metric_id",
          "currency",
          "quantity"
        ]
      },
      "AccountMetricQuantity": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier, or the lowercase currency code for currency usage.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^(metric_[0-9a-f]{32}|[a-z]{3})$"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lowercase currency code for currency usage. Null for normal metric usage.",
            "example": "usd",
            "pattern": "^[a-z]{3}$"
          },
          "quantity": {
            "type": "string",
            "description": "Lifetime decimal quantity serialized as a string.",
            "example": "1250.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          }
        },
        "required": [
          "account_id",
          "metric_id",
          "currency",
          "quantity"
        ]
      },
      "AccountLifetimeUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountMetricQuantity"
            }
          }
        },
        "required": [
          "data"
        ]
      },
      "MonthlyMetricQuantities": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "period_start_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricQuantity"
            }
          }
        },
        "required": [
          "period_start_at",
          "data"
        ]
      },
      "DailyMetricUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "period_start_at": {
            "$ref": "#/components/schemas/UnixTimestamp",
            "description": "Start of the UTC calendar day."
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricQuantity"
            },
            "description": "Matching metric aggregates. Empty when the day has no matching events."
          }
        },
        "required": [
          "period_start_at",
          "data"
        ]
      },
      "AccountDailyUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "aggregation": {
            "$ref": "#/components/schemas/UsageAggregation"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyMetricUsage"
            }
          }
        },
        "required": [
          "aggregation",
          "data"
        ]
      },
      "MetricMonthlyUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "aggregation": {
            "$ref": "#/components/schemas/UsageAggregation"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthlyMetricQuantities"
            }
          }
        },
        "required": [
          "aggregation",
          "data"
        ]
      },
      "AccountMonthlyUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "aggregation": {
            "$ref": "#/components/schemas/UsageAggregation"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthlyMetricQuantities"
            }
          }
        },
        "required": [
          "aggregation",
          "data"
        ]
      },
      "PropertyUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "property": {
            "type": "string",
            "example": "ari_job_id"
          },
          "value": {
            "type": "string",
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          },
          "aggregation": {
            "$ref": "#/components/schemas/UsageAggregation"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricQuantity"
            }
          }
        },
        "required": [
          "property",
          "value",
          "aggregation",
          "data"
        ]
      },
      "DailyPropertyUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "property": {
            "type": "string",
            "example": "ari_job_id"
          },
          "value": {
            "type": "string",
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          },
          "aggregation": {
            "$ref": "#/components/schemas/UsageAggregation"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyMetricUsage"
            }
          }
        },
        "required": [
          "property",
          "value",
          "aggregation",
          "data"
        ]
      },
      "AccountUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "account": {
            "$ref": "#/components/schemas/Account"
          },
          "events_consumed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountMetricUsage"
            }
          }
        },
        "required": [
          "account",
          "events_consumed"
        ]
      },
      "MeasurementUnits": {
        "type": [
          "string",
          "null"
        ],
        "description": "Optional unit of measure for the metric, such as m, ft, seconds, or tokens.",
        "maxLength": 256,
        "example": "m"
      },
      "MetricRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "Human-readable name. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "Acme"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Maximum 2048 Unicode scalar values.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          },
          "measurement_units": {
            "$ref": "#/components/schemas/MeasurementUnits"
          }
        },
        "required": [
          "name"
        ],
        "description": "Create-metric request. Unknown JSON fields are rejected."
      },
      "MetricUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Send null to clear.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          }
        },
        "required": [
          "description"
        ],
        "description": "Update-metric request. Unknown JSON fields are rejected."
      },
      "Metric": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "LedgerUp metric identifier.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "name": {
            "type": "string",
            "description": "Human-readable name. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "Acme"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Maximum 2048 Unicode scalar values.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          },
          "measurement_units": {
            "$ref": "#/components/schemas/MeasurementUnits"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "archived_at": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "measurement_units",
          "created_at",
          "updated_at",
          "archived_at"
        ]
      },
      "GrantRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Maximum 2048 Unicode scalar values.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          },
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier. Required when currency is omitted.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "currency": {
            "type": "string",
            "description": "Three-letter ISO 4217-style currency code. Amount is expressed in major currency units, not minor units. Required when metric_id is omitted. Stored lowercase; metric_id remains null.",
            "example": "usd",
            "pattern": "^[A-Za-z]{3}$"
          },
          "amount": {
            "type": "string",
            "description": "Decimal amount as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "expires_at": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "contract_v1_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional public.contracts identifier."
          },
          "effective_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          }
        },
        "required": [
          "account_id",
          "amount",
          "effective_at"
        ],
        "oneOf": [
          {
            "required": [
              "metric_id"
            ]
          },
          {
            "required": [
              "currency"
            ]
          }
        ],
        "description": "Create-grant request. Exactly one of metric_id or currency is required. Unknown JSON fields are rejected. When provided, expires_at must be after effective_at."
      },
      "Grant": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "LedgerUp grant identifier.",
            "example": "grant_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^grant_[0-9a-f]{32}$"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional description. Maximum 2048 Unicode scalar values.",
            "maxLength": 2048,
            "example": "Usage tracked for Acme."
          },
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "metric_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "LedgerUp metric identifier. Null for currency grants.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Three-letter lowercase currency code. Amount is expressed in major currency units, not minor units. Null for metric grants.",
            "example": "usd",
            "pattern": "^[a-z]{3}$"
          },
          "amount": {
            "type": "string",
            "description": "Decimal amount serialized as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "expires_at": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "accepted_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "status": {
            "type": "string",
            "description": "Derived grant status. Voided and archived take precedence over expiration and scheduled activation.",
            "enum": [
              "active",
              "scheduled",
              "voided",
              "archived",
              "expired"
            ],
            "example": "active"
          },
          "archived_at": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "contract_v1_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional public.contracts identifier."
          },
          "effective_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          }
        },
        "required": [
          "id",
          "description",
          "account_id",
          "metric_id",
          "currency",
          "amount",
          "expires_at",
          "accepted_at",
          "created_at",
          "updated_at",
          "status",
          "archived_at",
          "contract_v1_id",
          "effective_at"
        ]
      },
      "EventRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier. Required when currency is null.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "currency": {
            "type": "string",
            "description": "Three-letter ISO 4217-style currency code. Quantity is expressed in major currency units, not minor units. Required when metric_id is omitted. Stored lowercase and also used as metric_id.",
            "example": "usd",
            "pattern": "^[A-Za-z]{3}$"
          },
          "quantity": {
            "type": "string",
            "description": "Decimal quantity as a string.",
            "example": "1250.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "occurred_at": {
            "$ref": "#/components/schemas/UnixTimestamp",
            "description": "Must be within five years before or after the current time."
          },
          "properties": {
            "$ref": "#/components/schemas/Properties"
          }
        },
        "required": [
          "quantity",
          "account_id",
          "occurred_at"
        ],
        "oneOf": [
          {
            "required": [
              "metric_id"
            ]
          },
          {
            "required": [
              "currency"
            ]
          }
        ],
        "description": "Create-event request. Exactly one of metric_id or currency is required. Unknown JSON fields are rejected."
      },
      "ReplaceEventMetricRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "quantity": {
            "type": "string",
            "description": "Replacement decimal quantity as a string.",
            "example": "1250.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          }
        },
        "required": [
          "metric_id",
          "quantity"
        ]
      },
      "ReplaceEventsRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "span_start": {
            "$ref": "#/components/schemas/UnixTimestamp",
            "description": "Inclusive start at midnight in America/Los_Angeles."
          },
          "span_end": {
            "$ref": "#/components/schemas/UnixTimestamp",
            "description": "Exclusive end at the next midnight in America/Los_Angeles. The elapsed duration is 23, 24, or 25 hours depending on daylight saving time."
          },
          "occurred_at": {
            "$ref": "#/components/schemas/UnixTimestamp",
            "description": "Event timestamp inside the span; must be within five years before or after the current time."
          },
          "properties": {
            "$ref": "#/components/schemas/Properties"
          },
          "metrics": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/ReplaceEventMetricRequest"
            }
          }
        },
        "required": [
          "account_id",
          "span_start",
          "span_end",
          "occurred_at",
          "metrics"
        ],
        "description": "Replace usage for unique metrics in one America/Los_Angeles midnight-to-midnight calendar day. Unknown JSON fields are rejected."
      },
      "ReplaceEventMetric": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier."
          },
          "prior_quantity": {
            "type": "string",
            "description": "Quantity removed from the span."
          },
          "replacement_quantity": {
            "type": "string",
            "description": "Quantity present after replacement."
          },
          "replaced_event_count": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "replacement_event_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Inserted event identifier, or null when replacement quantity is zero."
          }
        },
        "required": [
          "metric_id",
          "prior_quantity",
          "replacement_quantity",
          "replaced_event_count",
          "replacement_event_id"
        ]
      },
      "ReplaceEvents": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "replacement_audit_id": {
            "type": "string",
            "format": "uuid",
            "description": "Correlation ID for the replacement audit records. Uses the Idempotency-Key when it is a UUID; otherwise generated by the server."
          },
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier."
          },
          "span_start": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "span_end": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "occurred_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "properties": {
            "$ref": "#/components/schemas/Properties"
          },
          "metrics": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReplaceEventMetric"
            }
          }
        },
        "required": [
          "replacement_audit_id",
          "account_id",
          "span_start",
          "span_end",
          "occurred_at",
          "properties",
          "metrics"
        ]
      },
      "Event": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "LedgerUp event identifier.",
            "example": "event_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^event_[0-9a-f]{32}$"
          },
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier, or the lowercase three-letter currency code for currency usage events.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^(metric_[0-9a-f]{32}|[a-z]{3})$"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Three-letter lowercase currency code. Quantity is expressed in major currency units, not minor units. Null for metric usage events.",
            "example": "usd",
            "pattern": "^[a-z]{3}$"
          },
          "quantity": {
            "type": "string",
            "description": "Decimal quantity serialized as a string.",
            "example": "1250.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "occurred_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "properties": {
            "$ref": "#/components/schemas/Properties"
          },
          "accepted_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "created_at": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ],
            "description": "ClickHouse insertion timestamp. Null in the initial 202 response while the event is queued."
          }
        },
        "required": [
          "id",
          "metric_id",
          "currency",
          "quantity",
          "account_id",
          "occurred_at",
          "properties",
          "accepted_at",
          "created_at"
        ]
      },
      "AccountList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Account"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when additional records are available after the returned page.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "AccountUsageList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountUsage"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when additional records are available after the returned page.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "MetricList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Metric"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when additional records are available after the returned page.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "CurrencyList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Lowercase three-letter currency code observed in usage events.",
              "pattern": "^[a-z]{3}$",
              "example": "usd"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "Always false because all observed currencies are returned.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "CustomerRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "Customer name. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "Acme"
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional caller-supplied external identifier. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "crm_acme_001"
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional Stripe customer identifier. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "cus_NffrFeUfNV2Hib"
          },
          "quickbooks_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional QuickBooks customer UUID.",
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          }
        },
        "required": [
          "name"
        ],
        "description": "Create-customer request. Unknown JSON fields are rejected."
      },
      "CustomerUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "Customer name. Maximum 256 Unicode scalar values.",
            "maxLength": 256,
            "example": "Acme"
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional caller-supplied external identifier. Send null to clear.",
            "maxLength": 256,
            "example": "crm_acme_001"
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional Stripe customer identifier. Send null to clear.",
            "maxLength": 256,
            "example": "cus_NffrFeUfNV2Hib"
          },
          "quickbooks_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional QuickBooks customer UUID. Send null to clear.",
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          }
        },
        "description": "Update-customer request. Unknown JSON fields are rejected. Omitted fields are unchanged."
      },
      "Customer": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Customer UUID.",
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          },
          "name": {
            "type": "string",
            "description": "Customer name.",
            "maxLength": 256,
            "example": "Acme"
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional caller-supplied external identifier.",
            "maxLength": 256,
            "example": "crm_acme_001"
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional Stripe customer identifier.",
            "maxLength": 256,
            "example": "cus_NffrFeUfNV2Hib"
          },
          "quickbooks_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Optional QuickBooks customer UUID.",
            "example": "018f5f0c-1111-7abc-8def-123456789abc"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          }
        },
        "required": [
          "id",
          "name",
          "external_id",
          "stripe_customer_id",
          "quickbooks_customer_id",
          "created_at",
          "updated_at"
        ]
      },
      "CustomerList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Customer"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when additional records are available after the returned page.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "GrantList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Grant"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when additional records are available after the returned page.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "GrantVoid": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "LedgerUp grant void identifier.",
            "example": "grant_void_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^grant_void_[0-9a-f]{32}$"
          },
          "grant_id": {
            "type": "string",
            "description": "Voided LedgerUp grant identifier.",
            "example": "grant_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^grant_[0-9a-f]{32}$"
          },
          "account_id": {
            "type": "string",
            "description": "Account associated with the voided grant.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          }
        },
        "required": [
          "id",
          "grant_id",
          "account_id",
          "created_at"
        ]
      },
      "GrantVoidList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GrantVoid"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when additional records are available after the returned page.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "EventList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "True when additional records are available after the returned page.",
            "example": false
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "BillingMode": {
        "type": "string",
        "description": "How a price or rate converts a contract line into invoice amount.",
        "enum": [
          "flat",
          "per_unit",
          "per_seat",
          "usage_sum",
          "last_metric_reported",
          "tiered_usage",
          "package",
          "minimum_commit"
        ],
        "example": "last_metric_reported"
      },
      "BillingInterval": {
        "type": "string",
        "description": "How often the line is evaluated for billing.",
        "enum": [
          "month",
          "quarter",
          "year",
          "one_time",
          "contract_term"
        ],
        "example": "month"
      },
      "BillingTiming": {
        "type": "string",
        "description": "Whether the line is billed before or after the service period.",
        "enum": [
          "advance",
          "arrears",
          "point_in_time"
        ],
        "example": "arrears"
      },
      "ProrationMode": {
        "type": "string",
        "description": "How partial periods are handled.",
        "enum": [
          "none",
          "prorate"
        ],
        "example": "prorate"
      },
      "RateSource": {
        "type": "string",
        "description": "LedgerUp Engine source used by a rate card rate.",
        "enum": [
          "metric_units",
          "grants"
        ],
        "example": "metric_units"
      },
      "RateAggregation": {
        "type": "string",
        "description": "Aggregation applied to source facts in the invoice period.",
        "enum": [
          "sum",
          "count",
          "latest",
          "max",
          "min"
        ],
        "example": "sum"
      },
      "ContractStatus": {
        "type": "string",
        "enum": [
          "draft",
          "active",
          "canceled",
          "expired"
        ],
        "example": "active"
      },
      "ContractLineStatus": {
        "type": "string",
        "enum": [
          "active",
          "canceled",
          "ended"
        ],
        "example": "active"
      },
      "ProductRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "example": "Text-to-speech"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "example": "Hosted or self-hosted TTS usage."
          },
          "stripe_product_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "prod_123"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "ProductUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "stripe_product_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "Product": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "stripe_product_id",
          "metadata",
          "created_at",
          "updated_at",
          "archived_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/LedgerId",
            "example": "product_tts"
          },
          "name": {
            "type": "string",
            "example": "Text-to-speech"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "stripe_product_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "prod_123"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "archived_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ProductList": {
        "type": "object",
        "required": [
          "data",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "PriceRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "product_id",
          "billing_mode",
          "currency_code",
          "interval"
        ],
        "description": "A simple product price. Use a rate card directly on a contract line for richer usage rating.",
        "properties": {
          "product_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "stripe_price_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "price_123"
          },
          "billing_mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "currency_code": {
            "type": "string",
            "example": "USD"
          },
          "interval": {
            "$ref": "#/components/schemas/BillingInterval"
          },
          "unit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1000
          },
          "unit_scale": {
            "type": [
              "string",
              "null"
            ],
            "description": "Units represented by one billable quantity. Example: 1000000 characters.",
            "example": "1000000"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "PriceUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "product_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "stripe_price_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "billing_mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "currency_code": {
            "type": "string"
          },
          "interval": {
            "$ref": "#/components/schemas/BillingInterval"
          },
          "unit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "unit_scale": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "Price": {
        "type": "object",
        "required": [
          "id",
          "product_id",
          "stripe_price_id",
          "billing_mode",
          "currency_code",
          "interval",
          "unit_amount_minor_units",
          "unit_scale",
          "metadata",
          "created_at",
          "updated_at",
          "archived_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/LedgerId",
            "example": "price_tts_2026"
          },
          "product_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "stripe_price_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "price_123"
          },
          "billing_mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "currency_code": {
            "type": "string",
            "example": "USD"
          },
          "interval": {
            "$ref": "#/components/schemas/BillingInterval"
          },
          "unit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "unit_scale": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "archived_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "PriceList": {
        "type": "object",
        "required": [
          "data",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Price"
            }
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "RateTier": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "up_to",
          "unit_amount_minor_units",
          "flat_amount_minor_units"
        ],
        "properties": {
          "up_to": {
            "type": [
              "string",
              "null"
            ],
            "description": "Exclusive upper bound. Null means infinity.",
            "example": "1000000"
          },
          "unit_amount_minor_units": {
            "type": "integer",
            "format": "int64",
            "example": 1000
          },
          "flat_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          }
        }
      },
      "RateCardRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "currency_code",
          "rates"
        ],
        "properties": {
          "name": {
            "type": "string",
            "example": "Rime 2026 usage"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency_code": {
            "type": "string",
            "example": "USD"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          },
          "rates": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/RateCardRateRequest"
            },
            "description": "Rules that turn usage or grant facts into billable invoice amounts."
          }
        },
        "description": "Create a rate card and its rating rules in one request. Use a single rate for simple usage billing, or multiple rates with the same invoice_group_key when several Engine facts should roll up into one invoice line."
      },
      "RateCardUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency_code": {
            "type": "string"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        },
        "description": "Update rate card details. Create a new rate card when the billing rules need to change."
      },
      "RateCard": {
        "type": "object",
        "required": [
          "id",
          "name",
          "description",
          "currency_code",
          "rates",
          "metadata",
          "created_at",
          "updated_at",
          "archived_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/LedgerId",
            "example": "rate_card_rime_2026"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency_code": {
            "type": "string",
            "example": "USD"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "archived_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "rates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RateCardRate"
            },
            "description": "Rating rules attached to this rate card."
          }
        },
        "description": "A reusable usage rating policy for contract lines."
      },
      "RateCardList": {
        "type": "object",
        "required": [
          "data",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RateCard"
            }
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "RateCardRateRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source",
          "source_id",
          "billing_mode",
          "aggregation"
        ],
        "description": "One rating rule. It selects Engine facts, converts units when needed, and prices the resulting quantity.",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/RateSource",
            "description": "Engine fact type to rate."
          },
          "source_id": {
            "$ref": "#/components/schemas/LedgerId",
            "description": "Metric or grant id to read from."
          },
          "billing_mode": {
            "$ref": "#/components/schemas/BillingMode",
            "description": "Pricing behavior for this rule."
          },
          "aggregation": {
            "$ref": "#/components/schemas/RateAggregation",
            "description": "How source facts are collapsed for the invoice period."
          },
          "source_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Unit reported by the source facts, such as characters, seconds, calls, or dollars.",
            "example": "characters"
          },
          "billing_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Unit produced by conversion and shown for billing, such as million_characters, credits, seats, or hours.",
            "example": "million_characters"
          },
          "conversion_mode": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnitConversionMode"
              },
              {
                "type": "null"
              }
            ],
            "description": "Conversion from source_unit to billing_unit. identity leaves the quantity unchanged, scale divides by unit_scale, and multiply multiplies by unit_scale."
          },
          "invoice_group_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Rates with the same key can contribute to a single invoice preview line after conversion to a shared billing_unit.",
            "example": "usage_credits"
          },
          "unit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "unit_scale": {
            "type": [
              "string",
              "null"
            ],
            "example": "1000000"
          },
          "package_size": {
            "type": [
              "string",
              "null"
            ]
          },
          "included_quantity": {
            "type": [
              "string",
              "null"
            ]
          },
          "minimum_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "commit_quantity": {
            "type": [
              "string",
              "null"
            ]
          },
          "commit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "markup_percent": {
            "type": [
              "string",
              "null"
            ],
            "example": "15"
          },
          "tiers": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/RateTier"
            }
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "RateCardRate": {
        "type": "object",
        "required": [
          "id",
          "source",
          "source_id",
          "billing_mode",
          "aggregation",
          "source_unit",
          "billing_unit",
          "conversion_mode",
          "invoice_group_key",
          "unit_amount_minor_units",
          "unit_scale",
          "package_size",
          "included_quantity",
          "minimum_amount_minor_units",
          "commit_quantity",
          "commit_amount_minor_units",
          "markup_percent",
          "tiers",
          "metadata",
          "created_at",
          "updated_at",
          "archived_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/LedgerId",
            "example": "rate_chars_overage"
          },
          "source": {
            "$ref": "#/components/schemas/RateSource"
          },
          "source_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "billing_mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "aggregation": {
            "$ref": "#/components/schemas/RateAggregation"
          },
          "source_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Unit reported by the source facts, such as characters, seconds, calls, or dollars.",
            "example": "characters"
          },
          "billing_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Unit produced by conversion and shown for billing, such as million_characters, credits, seats, or hours.",
            "example": "million_characters"
          },
          "conversion_mode": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnitConversionMode"
              },
              {
                "type": "null"
              }
            ],
            "description": "Conversion from source_unit to billing_unit. identity leaves the quantity unchanged, scale divides by unit_scale, and multiply multiplies by unit_scale."
          },
          "invoice_group_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Rates with the same key can contribute to a single invoice preview line after conversion to a shared billing_unit.",
            "example": "usage_credits"
          },
          "unit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "unit_scale": {
            "type": [
              "string",
              "null"
            ]
          },
          "package_size": {
            "type": [
              "string",
              "null"
            ]
          },
          "included_quantity": {
            "type": [
              "string",
              "null"
            ]
          },
          "minimum_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "commit_quantity": {
            "type": [
              "string",
              "null"
            ]
          },
          "commit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "markup_percent": {
            "type": [
              "string",
              "null"
            ]
          },
          "tiers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RateTier"
            }
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "archived_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "description": "A rating rule attached to a rate card."
      },
      "ContractRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "account_id",
          "customer_id",
          "currency_code",
          "billing_interval",
          "starts_at"
        ],
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency_code": {
            "type": "string",
            "example": "USD"
          },
          "billing_interval": {
            "$ref": "#/components/schemas/BillingInterval"
          },
          "starts_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "ends_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "payment_terms": {
            "type": [
              "string",
              "null"
            ],
            "example": "net_30"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "ContractUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "account_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency_code": {
            "type": "string"
          },
          "billing_interval": {
            "$ref": "#/components/schemas/BillingInterval"
          },
          "starts_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "ends_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "payment_terms": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "ContractCancelRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "cancel_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null means cancel at the current billing period end."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Contract": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "customer_id",
          "stripe_customer_id",
          "status",
          "currency_code",
          "billing_interval",
          "starts_at",
          "ends_at",
          "payment_terms",
          "metadata",
          "created_at",
          "updated_at",
          "canceled_at",
          "cancel_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/LedgerId",
            "example": "contract_attune_rime_2026"
          },
          "account_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/ContractStatus"
          },
          "currency_code": {
            "type": "string"
          },
          "billing_interval": {
            "$ref": "#/components/schemas/BillingInterval"
          },
          "starts_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "ends_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "payment_terms": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "canceled_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "cancel_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ContractList": {
        "type": "object",
        "required": [
          "data",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Contract"
            }
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "ContractLineRequest": {
        "description": "Create a contract line with exactly one billing reference: price_id for simple subscription pricing, or rate_card_id for usage rating.",
        "allOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "price_id": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/LedgerId"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "rate_card_id": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/LedgerId"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "string",
                  "null"
                ],
                "default": "1"
              },
              "starts_at": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/UnixTimestamp"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "ends_at": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/UnixTimestamp"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "billing_timing": {
                "$ref": "#/components/schemas/BillingTiming"
              },
              "proration": {
                "$ref": "#/components/schemas/ProrationMode"
              },
              "metadata": {
                "$ref": "#/components/schemas/Properties"
              }
            }
          },
          {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "price_id"
                ],
                "properties": {
                  "price_id": {
                    "$ref": "#/components/schemas/LedgerId"
                  },
                  "rate_card_id": {
                    "type": "null"
                  }
                }
              },
              {
                "type": "object",
                "required": [
                  "rate_card_id"
                ],
                "properties": {
                  "price_id": {
                    "type": "null"
                  },
                  "rate_card_id": {
                    "$ref": "#/components/schemas/LedgerId"
                  }
                }
              }
            ]
          }
        ]
      },
      "ContractLineUpdateRequest": {
        "description": "Update a contract line.",
        "allOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "price_id": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/LedgerId"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "rate_card_id": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/LedgerId"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "string",
                  "null"
                ],
                "default": "1"
              },
              "starts_at": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/UnixTimestamp"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "ends_at": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/UnixTimestamp"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "billing_timing": {
                "$ref": "#/components/schemas/BillingTiming"
              },
              "proration": {
                "$ref": "#/components/schemas/ProrationMode"
              },
              "metadata": {
                "$ref": "#/components/schemas/Properties"
              }
            }
          }
        ]
      },
      "ContractLineCancelRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "cancel_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ContractLine": {
        "type": "object",
        "required": [
          "id",
          "contract_id",
          "price_id",
          "rate_card_id",
          "description",
          "quantity",
          "status",
          "starts_at",
          "ends_at",
          "billing_timing",
          "proration",
          "metadata",
          "created_at",
          "updated_at",
          "canceled_at",
          "cancel_at"
        ],
        "description": "A subscription line that maps to one or more LedgerUp invoice lines. Exactly one of price_id or rate_card_id is set.",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/LedgerId",
            "example": "contract_line_tts_chars"
          },
          "contract_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "price_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LedgerId"
              },
              {
                "type": "null"
              }
            ]
          },
          "rate_card_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LedgerId"
              },
              {
                "type": "null"
              }
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "quantity": {
            "type": "string",
            "example": "1"
          },
          "status": {
            "$ref": "#/components/schemas/ContractLineStatus"
          },
          "starts_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "ends_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "billing_timing": {
            "$ref": "#/components/schemas/BillingTiming"
          },
          "proration": {
            "$ref": "#/components/schemas/ProrationMode"
          },
          "metadata": {
            "$ref": "#/components/schemas/Properties"
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "canceled_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "cancel_at": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UnixTimestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ContractLineList": {
        "type": "object",
        "required": [
          "data",
          "has_more"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContractLine"
            }
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "InvoicePreviewRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "period_start_at",
          "period_end_at"
        ],
        "properties": {
          "period_start_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "period_end_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          }
        }
      },
      "InvoicePreviewLine": {
        "type": "object",
        "required": [
          "contract_line_id",
          "product_id",
          "price_id",
          "rate_card_id",
          "invoice_group_key",
          "stripe_product_id",
          "stripe_price_id",
          "description",
          "quantity",
          "unit_amount_minor_units",
          "amount_minor_units",
          "currency_code",
          "service_period_start_at",
          "service_period_end_at",
          "source_breakdown"
        ],
        "properties": {
          "contract_line_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "product_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "price_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LedgerId"
              },
              {
                "type": "null"
              }
            ]
          },
          "rate_card_id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LedgerId"
              },
              {
                "type": "null"
              }
            ]
          },
          "invoice_group_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Grouping key from the contributing rate card rates, when multiple converted sources are combined into one line.",
            "example": "usage_credits"
          },
          "stripe_product_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "stripe_price_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "string"
          },
          "unit_amount_minor_units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64"
          },
          "amount_minor_units": {
            "type": "integer",
            "format": "int64"
          },
          "currency_code": {
            "type": "string"
          },
          "service_period_start_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "service_period_end_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "source_breakdown": {
            "$ref": "#/components/schemas/Properties"
          }
        }
      },
      "InvoicePreview": {
        "type": "object",
        "required": [
          "contract_id",
          "period_start_at",
          "period_end_at",
          "currency_code",
          "lines"
        ],
        "properties": {
          "contract_id": {
            "$ref": "#/components/schemas/LedgerId"
          },
          "period_start_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "period_end_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "currency_code": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoicePreviewLine"
            }
          }
        }
      },
      "UnitConversionMode": {
        "type": "string",
        "description": "How a source quantity is converted into the billing unit before pricing.",
        "enum": [
          "identity",
          "scale",
          "multiply"
        ],
        "example": "scale"
      },
      "RefillConfigurationRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "minimum_balance": {
            "type": "string",
            "description": "Decimal balance serialized as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "target_balance": {
            "type": "string",
            "description": "Decimal balance serialized as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "is_active": {
            "type": "boolean",
            "description": "Whether automatic refills are enabled.",
            "example": true
          }
        },
        "required": [
          "account_id",
          "metric_id",
          "minimum_balance",
          "target_balance",
          "is_active"
        ],
        "description": "Create-refill-configuration request. target_balance must be greater than minimum_balance. Unknown JSON fields are rejected."
      },
      "RefillConfigurationUpdateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "minimum_balance": {
            "type": "string",
            "description": "Decimal balance serialized as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "target_balance": {
            "type": "string",
            "description": "Decimal balance serialized as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "is_active": {
            "type": "boolean",
            "description": "Whether automatic refills are enabled.",
            "example": true
          }
        },
        "description": "Update-refill-configuration request. Omitted fields are unchanged. target_balance must remain greater than minimum_balance. Unknown JSON fields are rejected."
      },
      "RefillConfiguration": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "metric_id": {
            "type": "string",
            "description": "LedgerUp metric identifier.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "minimum_balance": {
            "type": "string",
            "description": "Decimal balance serialized as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "target_balance": {
            "type": "string",
            "description": "Decimal balance serialized as a string.",
            "example": "100.0",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "is_active": {
            "type": "boolean",
            "description": "Whether automatic refills are enabled.",
            "example": true
          },
          "created_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          },
          "updated_at": {
            "$ref": "#/components/schemas/UnixTimestamp"
          }
        },
        "required": [
          "account_id",
          "metric_id",
          "minimum_balance",
          "target_balance",
          "is_active",
          "created_at",
          "updated_at"
        ]
      },
      "RefillConfigurationList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RefillConfiguration"
            }
          },
          "has_more": {
            "type": "boolean",
            "description": "Always false because refill configurations are returned in full."
          }
        },
        "required": [
          "data",
          "has_more"
        ]
      },
      "AccountBalance": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "account_id": {
            "type": "string",
            "description": "LedgerUp account identifier.",
            "example": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^account_[0-9a-f]{32}$"
          },
          "metric_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "LedgerUp metric identifier. Null for a currency balance.",
            "example": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
            "pattern": "^metric_[0-9a-f]{32}$"
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lowercase currency code. Null for a metric balance.",
            "example": "usd",
            "pattern": "^[a-z]{3}$"
          },
          "grant_total": {
            "type": "string",
            "description": "Sum of all grants for the account, serialized as a string.",
            "example": "1000",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "usage_total": {
            "type": "string",
            "description": "Sum of corrected usage events for the metric, serialized as a string.",
            "example": "275.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          },
          "balance": {
            "type": "string",
            "description": "grant_total minus usage_total, serialized as a string.",
            "example": "724.5",
            "pattern": "^-?\\d+(\\.\\d+)?$"
          }
        },
        "required": [
          "account_id",
          "metric_id",
          "currency",
          "grant_total",
          "usage_total",
          "balance"
        ]
      }
    }
  }
}
