POST/api/orgs/{org_id}/budgets

Create a shared budget

A named spend limit any number of keys draw from, resetting every UTC day, week, month or year (reset_period, default monthly). api_key_ids attaches keys now, moving each off any other shared budget (a key draws from at most one). The limit counts the spend of the keys attached now, in the current window. Setting a budget on a key replaces any older per-key spend cap. Org admin or the provisioning key.

Authentication: Bearer API key in the Authorization header

Path parameters

  • org_idstringrequired

    Your organization id (uuid). GET /api/whoami returns it.

Request body

  • namestringrequired

    Unique among the org's shared budgets.

  • limit_nano_usdintegerrequired

    Integer nano-USD (1 USD = 1,000,000,000) per window. 0 refuses every request.

  • reset_periodenum

    The UTC window the limit counts.

    "daily""weekly""monthly""yearly"
    Default: "monthly"
  • api_key_idsarray | null

    Keys to attach now.

Responses

  • 201

    The budget.

    Response
    • budget_idstringrequired
    • periodstringrequired

      YYYY-MM, or * for recurring.

    • scope_kindenumrequired

      keys is a shared budget; key is an older per-key budget.

      "team""identity""key""model""pool""deployment""keys"
    • api_key_idstring | nullrequired
    • identity_idstring | nullrequired
    • alias_idstring | nullrequired
    • pool_idstring | nullrequired
    • deployment_idstring | nullrequired
    • limit_nano_usdintegerrequired

      The cap, integer nano-USD. 0 is a hard zero cap.

    • reserved_nano_usdintegerrequired

      In flight, integer nano-USD.

    • settled_nano_usdintegerrequired

      Spent this month, integer nano-USD.

    • remaining_nano_usdintegerrequired

      Integer nano-USD.

    • created_by_kindenumrequired
      "session""api_key"
    • created_by_api_key_idstring | nullrequired

      The authoring key, when a key wrote the row.

    • namestring | null

      Shared budgets only.

    • reset_periodenum

      Shared budgets only.

      "daily""weekly""monthly""yearly"null
    • api_key_idsarray | null

      Shared budgets only: the keys drawing from it.

  • 401

    Missing, unknown or revoked API key.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 403

    The key is not a provisioning key (inference keys are refused, reads included), or it is a customer-plan key.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 404

    Unknown organization or key.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 409

    A shared budget with this name exists.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one (for example pro_required).

    • actionstring

      Stable remediation action, when the route defines one.

    • detailsobject

      Customer-safe string facts the caller needs to act (for example a suggested identifier).

  • 422

    Unknown reset period, or body validation failed.

Request

curl -X POST 'https://api.experientiallabs.ai/api/orgs/3f6c2a1e-8b7d-4c2a-9e51-6a0d4b2f7c10/budgets' \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Interns",
  "limit_nano_usd": 200000000000,
  "reset_period": "monthly",
  "api_key_ids": [
    "6d1f8a2b-4c3e-4f5a-9b7c-2e8d0a1f3b4c"
  ]
}'

Response

{
  "budget_id": "c4a2e8f1-7b3d-4e9a-8c15-3f0d6b2a9e71",
  "period": "*",
  "scope_kind": "keys",
  "api_key_id": null,
  "identity_id": null,
  "alias_id": null,
  "pool_id": null,
  "deployment_id": null,
  "limit_nano_usd": 200000000000,
  "reserved_nano_usd": 0,
  "settled_nano_usd": 0,
  "remaining_nano_usd": 200000000000,
  "created_by_kind": "api_key",
  "created_by_api_key_id": "6b1d2f4e-3c8a-4f0e-9a21-7e5c0d9b4a33",
  "name": "Interns",
  "reset_period": "monthly",
  "api_key_ids": [
    "6d1f8a2b-4c3e-4f5a-9b7c-2e8d0a1f3b4c"
  ]
}

https://api.experientiallabs.ai/api/orgs/3f6c2a1e-8b7d-4c2a-9e51-6a0d4b2f7c10/budgets