方法路径摘要认证
GET/v1/traffic-packages/balancesList current-user balances grouped by metering bucket登录会话
GET/v1/traffic-packages/grantsList grants purchased by the authenticated tenant user登录会话
GET/v1/traffic-packages/grants/{grant_id}Read one grant purchased by the authenticated tenant user登录会话
GET/v1/traffic-packages/productsList current products visible to the authenticated tenant登录会话
POST/v1/traffic-packages/purchasesTraffic package purchase boundary登录会话
GET/v1/traffic-packages/usage-eventsList current-user consumption and refund results登录会话
GET/v1/traffic-packages/usage-events/{event_id}/allocationsList bounded allocation details for one visible usage event登录会话

契约文件:api/control-traffic-packages.openapi.yaml

接口详情

GET /v1/traffic-packages/balances

List current-user balances grouped by metering bucket

operationId
listMyTrafficPackageBalances
认证
  • 登录会话:主控登录后的 Bearer 会话,由客户本人在自己的主控里使用;插件不能要求客户交出会话。
所需权限

全部需要:traffic_packages.read

说明(契约原文)

All quantities are integer bytes. Only migration-051 grants purchased by the current user participate in the aggregation.

参数

listMyTrafficPackageBalances 参数
名称位置类型必填说明
limitqueryinteger否—
cursorquerystring否Opaque HMAC-signed cursor bound to endpoint, principal scope, target tenant, owner user, UTC-microsecond snapshot_at, and the applicable migration-066 catalog/usage snapshot_version or grant-state watermark.

响应

listMyTrafficPackageBalances 响应
状态码说明
200Current-user byte balances grouped by metering bucket.

字段:items: array<Balance> next_cursor?: string

400Malformed headers, query, JSON, UUID, cursor, unit, or range.
401Ordinary session authentication is required.
403Principal scope or required permission is absent.
408Read context was cancelled.
502Stored or core facts did not satisfy the public response contract.
503Read storage is unavailable.
504Read deadline expired.

失败时怎么办

  • 400 按字段说明修正参数或请求体再发;不要原样重试。
  • 401 检查凭据格式、是否过期或被轮换。
  • 403 检查 Key 范围与所有者当前权限、当前租户作用域;不要换更高权限账号绕过。
  • 503 依赖暂不可用:稍后用原 Idempotency-Key 重试。

↑ 回到列表

GET /v1/traffic-packages/grants

List grants purchased by the authenticated tenant user

operationId
listMyTrafficPackageGrants
认证
  • 登录会话:主控登录后的 Bearer 会话,由客户本人在自己的主控里使用;插件不能要求客户交出会话。
所需权限

全部需要:traffic_packages.read

说明(契约原文)

Both tenant and owner user are derived from the current principal. tenant_id is rejected.

参数

listMyTrafficPackageGrants 参数
名称位置类型必填说明
limitqueryinteger否—
cursorquerystring否Opaque HMAC-signed cursor bound to endpoint, principal scope, target tenant, owner user, UTC-microsecond snapshot_at, and the applicable migration-066 catalog/usage snapshot_version or grant-state watermark.
pagequeryinteger否Page-jump mode (1-based, max 10000, mutually exclusive with cursor). Uses OFFSET within the same frozen snapshot and returns total.
statusquerystring: active / exhausted / expired / reversed否Only grants whose current status matches; filtered before paging, and total follows the filter. A cursor is bound to the status it was issued for.

响应

listMyTrafficPackageGrants 响应
状态码说明
200Grants visible under the derived or explicit tenant scope.

字段:items: array<Grant> next_cursor?: string total?: integer(int64)

400Malformed headers, query, JSON, UUID, cursor, unit, or range.
401Ordinary session authentication is required.
403Principal scope or required permission is absent.
408Read context was cancelled.
502Stored or core facts did not satisfy the public response contract.
503Read storage is unavailable.
504Read deadline expired.

失败时怎么办

  • 400 按字段说明修正参数或请求体再发;不要原样重试。
  • 401 检查凭据格式、是否过期或被轮换。
  • 403 检查 Key 范围与所有者当前权限、当前租户作用域;不要换更高权限账号绕过。
  • 503 依赖暂不可用:稍后用原 Idempotency-Key 重试。

↑ 回到列表

GET /v1/traffic-packages/grants/{grant_id}

Read one grant purchased by the authenticated tenant user

operationId
getMyTrafficPackageGrant
认证
  • 登录会话:主控登录后的 Bearer 会话,由客户本人在自己的主控里使用;插件不能要求客户交出会话。
所需权限

全部需要:traffic_packages.read

说明(契约原文)

Same tenant and owner scope as the grant list; a grant of another tenant or user is 404. No query parameters are accepted.

参数

getMyTrafficPackageGrant 参数
名称位置类型必填说明
grant_idpathstring(uuid)是—

响应

getMyTrafficPackageGrant 响应
状态码说明
200One traffic package grant.

字段:id: string(uuid) owner_user_id?: object product_snapshot_id: string(uuid) product_name: string allowed_package_names: array<string> price_minor: integer(int64) granted_bytes: integer(int64) remaining_bytes: integer(int64) starts_at: string(date-time) expires_at: string(date-time) expiry_timezone: string priority: integer currency: string metering_scope: string metering_version: string status: string: active / exhausted / expired / reversed revision: integer(int64) created_at: string(date-time) updated_at: string(date-time)

400Malformed headers, query, JSON, UUID, cursor, unit, or range.
401Ordinary session authentication is required.
403Principal scope or required permission is absent.
404Resource is absent or not visible in the authorized scope.
408Read context was cancelled.
502Stored or core facts did not satisfy the public response contract.
503Read storage is unavailable.
504Read deadline expired.

失败时怎么办

  • 400 按字段说明修正参数或请求体再发;不要原样重试。
  • 401 检查凭据格式、是否过期或被轮换。
  • 403 检查 Key 范围与所有者当前权限、当前租户作用域;不要换更高权限账号绕过。
  • 404 资源不存在或不属于当前租户。
  • 503 依赖暂不可用:稍后用原 Idempotency-Key 重试。

↑ 回到列表

GET /v1/traffic-packages/products

List current products visible to the authenticated tenant

operationId
listAvailableTrafficPackageProducts
认证
  • 登录会话:主控登录后的 Bearer 会话,由客户本人在自己的主控里使用;插件不能要求客户交出会话。
所需权限

全部需要:traffic_packages.read

说明(契约原文)

Tenant scope is derived from the current principal. The result includes global products and products targeted to that tenant whose latest lifecycle fact is enabled. Disabled products remain in admin and history.

参数

listAvailableTrafficPackageProducts 参数
名称位置类型必填说明
limitqueryinteger否—
cursorquerystring否Opaque HMAC-signed cursor bound to endpoint, principal scope, target tenant, owner user, UTC-microsecond snapshot_at, and the applicable migration-066 catalog/usage snapshot_version or grant-state watermark.

响应

listAvailableTrafficPackageProducts 响应
状态码说明
200Current products or immutable revision history.

字段:items: array<Product> next_cursor?: string

400Malformed headers, query, JSON, UUID, cursor, unit, or range.
401Ordinary session authentication is required.
403Principal scope or required permission is absent.
408Read context was cancelled.
502Stored or core facts did not satisfy the public response contract.
503Read storage is unavailable.
504Read deadline expired.

失败时怎么办

  • 400 按字段说明修正参数或请求体再发;不要原样重试。
  • 401 检查凭据格式、是否过期或被轮换。
  • 403 检查 Key 范围与所有者当前权限、当前租户作用域;不要换更高权限账号绕过。
  • 503 依赖暂不可用:稍后用原 Idempotency-Key 重试。

↑ 回到列表

POST /v1/traffic-packages/purchases

Traffic package purchase boundary

operationId
purchaseTrafficPackageThroughCommerce
认证
  • 登录会话:主控登录后的 Bearer 会话,由客户本人在自己的主控里使用;插件不能要求客户交出会话。
所需权限

全部需要:package_subscriptions.manage

说明(契约原文)

Tenant and buyer are derived from the current principal. This route never calls trafficpackage.Grant directly. Until a reviewed adapter can invoke packagecommercehttp.Service.PurchaseTraffic unchanged, it always returns traffic_package_purchase_unavailable (503) and performs no write.

参数

purchaseTrafficPackageThroughCommerce 参数
名称位置类型必填说明
Idempotency-Keyheaderstring是—
X-Request-IDheaderstring是—
traceparentheaderstring是—

请求体

application/json · 必填:是

purchaseTrafficPackageThroughCommerce 请求体
名称类型必填说明
product_snapshot_idstring(uuid)是—
promotionPromotionReference否—
paymentBalancePayment | ProviderPayment是—

响应

purchaseTrafficPackageThroughCommerce 响应
状态码说明
400Malformed headers, query, JSON, UUID, cursor, unit, or range.
401Ordinary session authentication is required.
403Principal scope or required permission is absent.
503Reviewed package-commerce purchase wiring is absent; no write occurred.

失败时怎么办

  • 400 按字段说明修正参数或请求体再发;不要原样重试。
  • 401 检查凭据格式、是否过期或被轮换。
  • 403 检查 Key 范围与所有者当前权限、当前租户作用域;不要换更高权限账号绕过。
  • 503 依赖暂不可用:稍后用原 Idempotency-Key 重试。

↑ 回到列表

GET /v1/traffic-packages/usage-events

List current-user consumption and refund results

operationId
listMyTrafficPackageUsageEvents
认证
  • 登录会话:主控登录后的 Bearer 会话,由客户本人在自己的主控里使用;插件不能要求客户交出会话。
所需权限

全部需要:traffic_packages.read

说明(契约原文)

Only consume and refund operations are visible. Internal source event keys, request/trace IDs, product snapshots, ledger IDs, billing IDs, and provider payloads are omitted.

参数

listMyTrafficPackageUsageEvents 参数
名称位置类型必填说明
limitqueryinteger否—
cursorquerystring否Opaque HMAC-signed cursor bound to endpoint, principal scope, target tenant, owner user, UTC-microsecond snapshot_at, and the applicable migration-066 catalog/usage snapshot_version or grant-state watermark.
operationquerystring: consume / refund否—
grant_idquerystring(uuid)否只看该流量包(授予)的分录,amount_bytes 只计该包承担的部分。

响应

listMyTrafficPackageUsageEvents 响应
状态码说明
200Sanitized current-user usage and refund results.

字段:items: array<UsageEvent> next_cursor?: string

400Malformed headers, query, JSON, UUID, cursor, unit, or range.
401Ordinary session authentication is required.
403Principal scope or required permission is absent.
408Read context was cancelled.
502Stored or core facts did not satisfy the public response contract.
503Read storage is unavailable.
504Read deadline expired.

失败时怎么办

  • 400 按字段说明修正参数或请求体再发;不要原样重试。
  • 401 检查凭据格式、是否过期或被轮换。
  • 403 检查 Key 范围与所有者当前权限、当前租户作用域;不要换更高权限账号绕过。
  • 503 依赖暂不可用:稍后用原 Idempotency-Key 重试。

↑ 回到列表

GET /v1/traffic-packages/usage-events/{event_id}/allocations

List bounded allocation details for one visible usage event

operationId
listMyTrafficPackageUsageAllocations
认证
  • 登录会话:主控登录后的 Bearer 会话,由客户本人在自己的主控里使用;插件不能要求客户交出会话。
所需权限

全部需要:traffic_packages.read

说明(契约原文)

Tenant and owner user are derived from the authenticated principal. The command receipt never embeds allocations; clients page this immutable projection explicitly.

参数

listMyTrafficPackageUsageAllocations 参数
名称位置类型必填说明
event_idpathstring(uuid)是—
limitqueryinteger否—
cursorquerystring否Opaque HMAC-signed cursor bound to endpoint, principal scope, target tenant, owner user, UTC-microsecond snapshot_at, and the applicable migration-066 catalog/usage snapshot_version or grant-state watermark.

响应

listMyTrafficPackageUsageAllocations 响应
状态码说明
200Bounded page of immutable allocation details for one visible usage event.

字段:items: array<Allocation> next_cursor?: string

400Malformed headers, query, JSON, UUID, cursor, unit, or range.
401Ordinary session authentication is required.
403Principal scope or required permission is absent.
408Read context was cancelled.
502Stored or core facts did not satisfy the public response contract.
503Read storage is unavailable.
504Read deadline expired.

失败时怎么办

  • 400 按字段说明修正参数或请求体再发;不要原样重试。
  • 401 检查凭据格式、是否过期或被轮换。
  • 403 检查 Key 范围与所有者当前权限、当前租户作用域;不要换更高权限账号绕过。
  • 503 依赖暂不可用:稍后用原 Idempotency-Key 重试。

↑ 回到列表