# fees (operator)

Operator pricing: fee catalogue, pricing templates with typed rules, per-customer pricing, billing runs and fee charges.

## GET /billing-runs

operationId: `listBillingRuns`
Summary: Billing runs
API key scopes: `pricing:read`
Callable by: operator keys
Parameters: `X-Tenant-Id` (header, required), `X-Request-Id` (header), `cursor` (query), `limit` (query), `sort` (query), `filter` (query)
Responses: 200 `BillingRunPage`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:read` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## GET /billing-runs/{runId}

operationId: `getBillingRun`
Summary: Get billing run
API key scopes: `pricing:read`
Callable by: operator keys
Parameters: `runId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header)
Responses: 200 `BillingRun`, 401 `Problem`, 403 `Problem`, 404 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:read` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## GET /billing-runs/{runId}/items

operationId: `listBillingItems`
Summary: Billing run items (incl. funds required)
API key scopes: `pricing:read`
Callable by: operator keys
Parameters: `runId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header), `cursor` (query), `limit` (query), `sort` (query), `filter` (query)
Responses: 200 `BillingItemPage`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 404 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:read` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## POST /billing-runs/previews

operationId: `createBillingRunPreview`
Summary: Billing run dry run as a job (async)
API key scopes: `pricing:write`
Callable by: operator keys
Parameters: `X-Tenant-Id` (header, required), `X-Request-Id` (header)
Request body: `BillingRunPreviewCreate`
Responses: 202 `Job`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 409 `Problem`, 422 `Problem`, 429 `Problem`, default `Problem`

The dry run of `POST /billing-runs` with `dryRun: true`, computed by the platform in the background for operators with many customers (scalability audit X-15). Poll `GET /jobs/{jobId}` (kind `billing_run`); once `succeeded`, `resultUrl` downloads a JSON document `{period, items, posted, fundsRequired, waived, totals: [{currency, posted, fundsRequired, items}]}` (the `BillingRun.stats` of the synchronous dry run; amounts in minor units as strings).

**API key scopes:** `pricing:write` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## GET /customers/{customerId}/pricing

operationId: `getCustomerPricing`
Summary: Customer pricing (template + overrides + effective)
API key scopes: `customers:manage`
Callable by: operator keys
Parameters: `customerId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header), `If-None-Match` (header)
Responses: 200 `CustomerPricing`, 304, 401 `Problem`, 403 `Problem`, 404 `Problem`, 429 `Problem`, default `Problem`

Customers may read their effective pricing (capability `balance.view`).

**API key scopes:** `customers:manage` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## PUT /customers/{customerId}/pricing

operationId: `replaceCustomerPricing`
Summary: Set customer pricing
API key scopes: `customers:manage`
Callable by: operator keys
Parameters: `customerId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header), `If-Match` (header, required)
Request body: `CustomerPricingWrite`
Responses: 200 `CustomerPricing`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 404 `Problem`, 409 `Problem`, 412 `Problem`, 422 `Problem`, 428 `Problem`, 429 `Problem`, default `Problem`

**Concurrency:** `If-Match` with the current `ETag` is required (`428` if absent, `412` if stale).

**API key scopes:** `customers:manage` (operator-level keys only (`X-Tenant-Id` = the operator id)).

**Step-up and API keys (P15-T01):** API keys holding the scope call it without a step-up; every change made with a key is emailed to every operator owner (`control_changed_by_api_key`, locked category: what changed, the key name and prefix, a link to the screen) and audited with the key id. The route's validation applies to keys exactly as to sessions.

## GET /fee-catalogue

operationId: `listFeeCatalogue`
Summary: Fee catalogue
API key scopes: `pricing:read`
Callable by: operator keys
Parameters: `X-Tenant-Id` (header, required), `X-Request-Id` (header), `cursor` (query), `limit` (query), `sort` (query)
Responses: 200 `FeeCatalogueItemPage`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:read` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## POST /fee-catalogue

operationId: `createFeeCatalogueItem`
Summary: Add fee type
API key scopes: `pricing:write`
Callable by: operator keys
Parameters: `X-Tenant-Id` (header, required), `X-Request-Id` (header)
Request body: `FeeCatalogueWrite`
Responses: 201 `FeeCatalogueItem`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 409 `Problem`, 422 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:write` (operator-level keys only (`X-Tenant-Id` = the operator id)).

**Step-up and API keys (P15-T01):** API keys holding the scope call it without a step-up; every change made with a key is emailed to every operator owner (`control_changed_by_api_key`, locked category: what changed, the key name and prefix, a link to the screen) and audited with the key id. The route's validation applies to keys exactly as to sessions.

## GET /fee-catalogue/{feeId}

operationId: `getFeeCatalogueItem`
Summary: Get fee type
API key scopes: `pricing:read`
Callable by: operator keys
Parameters: `feeId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header), `If-None-Match` (header)
Responses: 200 `FeeCatalogueItem`, 304, 401 `Problem`, 403 `Problem`, 404 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:read` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## PATCH /fee-catalogue/{feeId}

operationId: `updateFeeCatalogueItem`
Summary: Update fee type
API key scopes: `pricing:write`
Callable by: operator keys
Parameters: `feeId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header), `If-Match` (header, required)
Request body: `FeeCatalogueWrite`
Responses: 200 `FeeCatalogueItem`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 404 `Problem`, 409 `Problem`, 412 `Problem`, 422 `Problem`, 428 `Problem`, 429 `Problem`, default `Problem`

**Concurrency:** `If-Match` with the current `ETag` is required (`428` if absent, `412` if stale).

**API key scopes:** `pricing:write` (operator-level keys only (`X-Tenant-Id` = the operator id)).

**Step-up and API keys (P15-T01):** API keys holding the scope call it without a step-up; every change made with a key is emailed to every operator owner (`control_changed_by_api_key`, locked category: what changed, the key name and prefix, a link to the screen) and audited with the key id. The route's validation applies to keys exactly as to sessions.

## GET /pricing-templates

operationId: `listPricingTemplates`
Summary: Pricing templates
API key scopes: `pricing:read`
Callable by: operator keys
Parameters: `X-Tenant-Id` (header, required), `X-Request-Id` (header), `cursor` (query), `limit` (query), `sort` (query), `filter` (query), `q` (query)
Responses: 200 `PricingTemplatePage`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:read` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## POST /pricing-templates

operationId: `createPricingTemplate`
Summary: Create pricing template
API key scopes: `pricing:write`
Callable by: operator keys
Parameters: `X-Tenant-Id` (header, required), `X-Request-Id` (header)
Request body: `PricingTemplateWrite`
Responses: 201 `PricingTemplate`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 409 `Problem`, 422 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:write` (operator-level keys only (`X-Tenant-Id` = the operator id)).

**Step-up and API keys (P15-T01):** API keys holding the scope call it without a step-up; every change made with a key is emailed to every operator owner (`control_changed_by_api_key`, locked category: what changed, the key name and prefix, a link to the screen) and audited with the key id. The route's validation applies to keys exactly as to sessions.

## GET /pricing-templates/{templateId}

operationId: `getPricingTemplate`
Summary: Get pricing template
API key scopes: `pricing:read`
Callable by: operator keys
Parameters: `templateId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header), `If-None-Match` (header)
Responses: 200 `PricingTemplate`, 304, 401 `Problem`, 403 `Problem`, 404 `Problem`, 429 `Problem`, default `Problem`

**API key scopes:** `pricing:read` (operator-level keys only (`X-Tenant-Id` = the operator id)).

## PUT /pricing-templates/{templateId}

operationId: `replacePricingTemplate`
Summary: Replace template (new version)
API key scopes: `pricing:write`
Callable by: operator keys
Parameters: `templateId` (path, required), `X-Tenant-Id` (header, required), `X-Request-Id` (header), `If-Match` (header, required)
Request body: `PricingTemplateWrite`
Responses: 200 `PricingTemplate`, 400 `Problem`, 401 `Problem`, 403 `Problem`, 404 `Problem`, 409 `Problem`, 412 `Problem`, 422 `Problem`, 428 `Problem`, 429 `Problem`, default `Problem`

**Concurrency:** `If-Match` with the current `ETag` is required (`428` if absent, `412` if stale).

**API key scopes:** `pricing:write` (operator-level keys only (`X-Tenant-Id` = the operator id)).

**Step-up and API keys (P15-T01):** API keys holding the scope call it without a step-up; every change made with a key is emailed to every operator owner (`control_changed_by_api_key`, locked category: what changed, the key name and prefix, a link to the screen) and audited with the key id. The route's validation applies to keys exactly as to sessions.
