ultrarouter docs
API reference

Billing

Billing endpoints.

Billing endpoints.

This page is GENERATED from the OpenAPI spec (openapi.yaml) — it can never drift from the served API. Set UR_BASE_URL (required: your gateway’s URL) and UR_API_KEY (an ur_sk_* key); secrets are always the $UR_API_KEY placeholder.

Read real credit and noncash evaluation balances

GET /v1/workspaces/{id}/billing/account

Auth: Session cookie + workspace RBAC.

curl -sS -X GET "$UR_BASE_URL/v1/workspaces/req_0000000000000000/billing/account" \
  -H "Cookie: better-auth.session_token=$UR_SESSION"

Choose UR credits or BYOK explicitly

POST /v1/workspaces/{id}/billing/funding

Changes authorization only; does not fund credits. Platform fallback from BYOK requires explicit permission.

Auth: Session cookie + workspace RBAC.

curl -sS -X POST "$UR_BASE_URL/v1/workspaces/req_0000000000000000/billing/funding" \
  -H "Cookie: better-auth.session_token=$UR_SESSION" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "ur_credits",
    "allowPlatformFallback": true,
    "requestKey": "string"
  }'

Purchase prepaid inference credits

POST /v1/workspaces/{id}/billing/credit-checkout

Minimum credit purchase is $5. A 5.5% service fee is added once at checkout, rounded to cents. $5 credits costs $5.28. Credits are funded only by verified payment settlement, never a return URL.

Auth: Session cookie + workspace RBAC.

curl -sS -X POST "$UR_BASE_URL/v1/workspaces/req_0000000000000000/billing/credit-checkout" \
  -H "Cookie: better-auth.session_token=$UR_SESSION" \
  -H "Content-Type: application/json" \
  -d '{
    "creditCents": 0,
    "requestKey": "string"
  }'

Start a $49 monthly Pro subscription

POST /v1/workspaces/{id}/billing/pro-checkout

Includes $5 monthly noncash evaluation allowance. Duplicate pending/active purchases are refused.

Auth: Session cookie + workspace RBAC.

curl -sS -X POST "$UR_BASE_URL/v1/workspaces/req_0000000000000000/billing/pro-checkout" \
  -H "Cookie: better-auth.session_token=$UR_SESSION" \
  -H "Content-Type: application/json" \
  -d '{
    "requestKey": "string"
  }'

Cancel Pro at the paid period end

POST /v1/workspaces/{id}/billing/pro-cancel

Auth: Session cookie + workspace RBAC.

curl -sS -X POST "$UR_BASE_URL/v1/workspaces/req_0000000000000000/billing/pro-cancel" \
  -H "Cookie: better-auth.session_token=$UR_SESSION" \
  -H "Content-Type: application/json" \
  -d '{}'