Open source / Rust / MIT Field guide / indexed
Field guide / Metering APIReviewable source / main

Metering API

Usage metering and chargeback: usage reads, chargeback reports, and chargeback rate management.

4 routes

Response metadata: x-api-version, x-request-id, and traceresponse apply to normal routed responses and are omitted from the per-operation header tables below.

GET/api/metering/chargeback

audit access

Allocate cost per site by applying the per-request-type rates to the usage in the window.

AUDIT-tier (cross-site cost data). The window defaults to the last 90 days. NOTE: the totals assume a SINGLE currency across the active rates; a request type with no rate contributes 0 cost. 503 when no DB.

Permissions

Access classCredentialScoping
auditAn authenticated session or API bearer token is required.The access class is enforced first; site and environment scopes narrow resources on scoped operations.

HTTP request

GET https://<your-host>/api/metering/chargeback

Path parameters

This operation has no path parameters.

Query parameters

NameTypeRequirementDescription
sincestringOptionalValue supplied for the since query parameter.
untilstringOptionalValue supplied for the until query parameter.
sitestringOptionalSite identifier used to scope or filter the operation.

Request headers

NameTypeRequirementDescription
AuthorizationstringOptionalHuman credential alternative: supply one Bearer rys_... session token, ryk_... API token, or validated identity-provider JWT here. Do not combine it with X-Ryuki-Session-Id or the session cookie; conflicting carriers fail closed.
X-Ryuki-Session-IdstringOptionalOpaque rys_... session-token carrier used by the portal for mutations. Administrative session UUIDs cannot authenticate. Supply exactly one credential carrier per request.
traceparentstringOptionalOptional correlation input. When the second dash-separated segment has 32 characters, Ryuki reuses it as the request correlation identifier; this is not full W3C validation.

Request body

This operation does not accept a request body.

Response

StatusDescriptionBody
200OKValue

200 response body

Structure: Value.

NameTypeRequirementDescription
sitesJSON valueRequiredValue of sites returned in the response body.
total_costJSON valueRequiredValue of total_cost returned in the response body.
currencyJSON valueRequiredValue of currency returned in the response body.
unrated_request_typesJSON valueRequiredValue of unrated_request_types returned in the response body.
completeJSON valueRequiredValue of complete returned in the response body.
basisstringRequiredValue of basis returned in the response body.
window_sinceJSON valueRequiredValue of window_since returned in the response body.
window_untilJSON valueRequiredValue of window_until returned in the response body.

Errors

JSON failures use one of the platform error envelopes and include the request correlation metadata when routing reaches the API middleware. See Errors for the exact shapes, authentication failures, retry guidance, and transport-level exceptions.

Examples

Request

curl --silent --show-error --globoff \
  --request GET \
  --header 'Authorization: Bearer <token>' \
  'https://<your-host>/api/metering/chargeback'

Schematic response body

Illustrative shape generated from the extracted field types, not a recorded live response. Values are placeholders; null marks a field whose type could not be resolved.

Success status: 200

{
  "sites": null,
  "total_cost": null,
  "currency": null,
  "unrated_request_types": null,
  "complete": null,
  "basis": "<string>",
  "window_since": null,
  "window_until": null
}

GET/api/metering/chargeback/rates

audit access

List the configured cost rates.

Audit-tier.

Permissions

Access classCredentialScoping
auditAn authenticated session or API bearer token is required.The access class is enforced first; site and environment scopes narrow resources on scoped operations.

HTTP request

GET https://<your-host>/api/metering/chargeback/rates

Path parameters

This operation has no path parameters.

Query parameters

NameTypeRequirementDescription
limitintegerOptionalMaximum number of results requested.
offsetintegerOptionalNumber of results to skip before returning the page.

Request headers

NameTypeRequirementDescription
AuthorizationstringOptionalHuman credential alternative: supply one Bearer rys_... session token, ryk_... API token, or validated identity-provider JWT here. Do not combine it with X-Ryuki-Session-Id or the session cookie; conflicting carriers fail closed.
X-Ryuki-Session-IdstringOptionalOpaque rys_... session-token carrier used by the portal for mutations. Administrative session UUIDs cannot authenticate. Supply exactly one credential carrier per request.
traceparentstringOptionalOptional correlation input. When the second dash-separated segment has 32 characters, Ryuki reuses it as the request correlation identifier; this is not full W3C validation.

Request body

This operation does not accept a request body.

Response

StatusDescriptionBody
200OKValue

200 response body

Structure: Value.

NameTypeRequirementDescription
ratesJSON valueRequiredValue of rates returned in the response body.
durablebooleanRequiredValue of durable returned in the response body.
totalJSON valueRequiredTotal number of matching items before the returned page is applied.
limitJSON valueRequiredPage-size limit applied to this response.
offsetJSON valueRequiredNumber of matching items skipped before this response page.

Returns a paginated JSON object with total/limit/offset keys.

Errors

JSON failures use one of the platform error envelopes and include the request correlation metadata when routing reaches the API middleware. See Errors for the exact shapes, authentication failures, retry guidance, and transport-level exceptions.

Examples

Request

curl --silent --show-error --globoff \
  --request GET \
  --header 'Authorization: Bearer <token>' \
  'https://<your-host>/api/metering/chargeback/rates'

Schematic response body

Illustrative shape generated from the extracted field types, not a recorded live response. Values are placeholders; null marks a field whose type could not be resolved.

Success status: 200

{
  "rates": null,
  "durable": false,
  "total": null,
  "limit": null,
  "offset": null
}

POST/api/metering/chargeback/rates

admin access

Set (upsert) a request-type unit cost.

ADMIN-tier: billing rates must not be rewritable by any operator who can run workload. 503 when no DB.

Permissions

Access classCredentialScoping
adminAn authenticated session or API bearer token is required.The access class is enforced first; site and environment scopes narrow resources on scoped operations.

HTTP request

POST https://<your-host>/api/metering/chargeback/rates

Path parameters

This operation has no path parameters.

Query parameters

This operation has no query parameters.

Request headers

NameTypeRequirementDescription
AuthorizationstringOptionalHuman credential alternative: supply one Bearer rys_... session token, ryk_... API token, or validated identity-provider JWT here. Do not combine it with X-Ryuki-Session-Id or the session cookie; conflicting carriers fail closed.
Content-TypestringRequiredRequired by the resolved Axum Json<T> request extractor; send application/json.
X-Ryuki-Session-IdstringOptionalOpaque rys_... session-token carrier used by the portal for mutations. Administrative session UUIDs cannot authenticate. Supply exactly one credential carrier per request.
Idempotency-KeystringOptionalOptional at-most-once retry key for human mutations. When omitted, the idempotency middleware passes the request through without deduplication.
traceparentstringOptionalOptional correlation input. When the second dash-separated segment has 32 characters, Ryuki reuses it as the request correlation identifier; this is not full W3C validation.

Request body

JSON structure: CostRateRequest.

NameTypeRequirementDescription
request_typestringRequiredValue of request_type in the JSON request body.
unit_costnumberRequiredValue of unit_cost in the JSON request body.
currencystringOptionalValue of currency in the JSON request body.

Response

StatusDescriptionBody
200OKValue

200 response body

Structure: Value.

NameTypeRequirementDescription
request_typeJSON valueRequiredValue of request_type returned in the response body.
unit_costJSON valueRequiredValue of unit_cost returned in the response body.
currencyJSON valueRequiredValue of currency returned in the response body.
setbooleanRequiredValue of set returned in the response body.

Errors

JSON failures use one of the platform error envelopes and include the request correlation metadata when routing reaches the API middleware. See Errors for the exact shapes, authentication failures, retry guidance, and transport-level exceptions.

Examples

Request

curl --silent --show-error --globoff \
  --request POST \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: <idempotency-key>' \
  --data '{"request_type":"<string>","unit_cost":0.0}' \
  'https://<your-host>/api/metering/chargeback/rates'

Schematic response body

Illustrative shape generated from the extracted field types, not a recorded live response. Values are placeholders; null marks a field whose type could not be resolved.

Success status: 200

{
  "request_type": null,
  "unit_cost": null,
  "currency": null,
  "set": false
}

GET/api/metering/usage

audit access

Per-site usage, metered as the count of requests raised in the window, broken down by status.

AUDIT-tier: this exposes cross-site operational/chargeback volume, so it sits with the read-only reporting role, not every operator. Both window endpoints are constrained to the last 90 days of server time, so neither an old lower bound nor an old historical slice can turn this into an attacker-selected history scan. 503 when no database is configured.

Permissions

Access classCredentialScoping
auditAn authenticated session or API bearer token is required.The access class is enforced first; site and environment scopes narrow resources on scoped operations.

HTTP request

GET https://<your-host>/api/metering/usage

Path parameters

This operation has no path parameters.

Query parameters

NameTypeRequirementDescription
sincestringOptionalValue supplied for the since query parameter.
untilstringOptionalValue supplied for the until query parameter.
sitestringOptionalSite identifier used to scope or filter the operation.

Request headers

NameTypeRequirementDescription
AuthorizationstringOptionalHuman credential alternative: supply one Bearer rys_... session token, ryk_... API token, or validated identity-provider JWT here. Do not combine it with X-Ryuki-Session-Id or the session cookie; conflicting carriers fail closed.
X-Ryuki-Session-IdstringOptionalOpaque rys_... session-token carrier used by the portal for mutations. Administrative session UUIDs cannot authenticate. Supply exactly one credential carrier per request.
traceparentstringOptionalOptional correlation input. When the second dash-separated segment has 32 characters, Ryuki reuses it as the request correlation identifier; this is not full W3C validation.

Request body

This operation does not accept a request body.

Response

StatusDescriptionBody
200OKValue

200 response body

Structure: Value.

NameTypeRequirementDescription
sitesJSON valueRequiredValue of sites returned in the response body.
site_countJSON valueRequiredValue of site_count returned in the response body.
total_requestsJSON valueRequiredValue of total_requests returned in the response body.
window_sinceJSON valueRequiredValue of window_since returned in the response body.
window_untilJSON valueRequiredValue of window_until returned in the response body.

Errors

JSON failures use one of the platform error envelopes and include the request correlation metadata when routing reaches the API middleware. See Errors for the exact shapes, authentication failures, retry guidance, and transport-level exceptions.

Examples

Request

curl --silent --show-error --globoff \
  --request GET \
  --header 'Authorization: Bearer <token>' \
  'https://<your-host>/api/metering/usage'

Schematic response body

Illustrative shape generated from the extracted field types, not a recorded live response. Values are placeholders; null marks a field whose type could not be resolved.

Success status: 200

{
  "sites": null,
  "site_count": null,
  "total_requests": null,
  "window_since": null,
  "window_until": null
}
Last updated 2026-07-16 · Generated from the API route registrations.