diff --git a/services/www/src/docs/content/console/api/budgets.mdx b/services/www/src/docs/content/console/api/budgets.mdx deleted file mode 100644 index 82143e6c552..00000000000 --- a/services/www/src/docs/content/console/api/budgets.mdx +++ /dev/null @@ -1,112 +0,0 @@ ---- -title: "Budgets API" -description: "Read effective monthly budgets for every workspace member and manage each member's custom budget." ---- - -Read effective monthly budgets for every workspace member and manage each member's custom budget from an integration. - -These `/api/v1/budgets` endpoints manage each member's monthly budget and keep working after migration to budget -policies. Use **Controls** to manage shared, tag-based, or model-specific policies. - -## Quick start - -Create a [service account](/console/api#service-accounts) API key in the [Console](https://opencode.ai/console) with -**All** [permissions](/console/api#permissions), or **Restricted** with **Budgets** set to **Write**. **Budgets › Read** -is enough to list budgets. - -```bash -export CONSOLE_URL="https://opencode.ai/console" -export SERVICE_API_KEY="oc_sk_..." -``` - -List member budgets: - -```bash -curl --fail-with-body \ - "${CONSOLE_URL}/api/v1/budgets/members" \ - --header "Authorization: Bearer ${SERVICE_API_KEY}" \ - --header "Accept: application/json" -``` - -## List member budgets - -```text -GET /api/v1/budgets/members -``` - -The response includes every current member, ordered by email. In policy-based workspaces, it reports each member's lowest -monthly limit, including tag-based limits. Shared and model-specific budgets are not included. - -Source `custom` means a single-member limit; `default` means a limit from a broader audience. A null limit and source -mean the member has no individual limit; other policies can still cap spend. Before migration, `custom` -means a member override and `default` means the workspace default. - -```json -[ - { - "user_id": "user_...", - "email": "alice@example.com", - "limit_micro_cents": "7525000000", - "spent_micro_cents": "1250000000", - "exceeded": false, - "resets_at": "2026-10-01T00:00:00.000Z", - "source": "custom", - "updated_at": "2026-09-03T12:00:00.000Z" - } -] -``` - -Monetary response fields are decimal strings in microcents so integrations do not lose precision. There are -100,000,000 microcents per US dollar. Spend and reset timestamps cover the current UTC calendar month. In policy-based -workspaces, `updated_at` is the reported rule's update time, or null when no rule applies. Before migration, it is -null when there is no custom member override. - -## Set a custom budget - -```text -PUT /api/v1/budgets/members/:user_id -``` - -Set a $75.25 monthly budget for one member: - -```bash -curl --fail-with-body --request PUT \ - "${CONSOLE_URL}/api/v1/budgets/members/user_..." \ - --header "Authorization: Bearer ${SERVICE_API_KEY}" \ - --header "Content-Type: application/json" \ - --data '{"budget_dollars":75.25}' -``` - -`budget_dollars` accepts a non-negative US-dollar amount with at most two decimal places. The PUT is idempotent and -returns HTTP 204. Use the member ID returned by the list operation. - -A migrated member budget changed to a shared, tag-based, or model-specific rule in **Controls** cannot be overwritten -through this API. Conflicting rules, such as multiple single-member limits, also return HTTP `409`. - -## Remove a custom budget - -```text -DELETE /api/v1/budgets/members/:user_id -``` - -Remove the custom override: - -```bash -curl --fail-with-body --request DELETE \ - "${CONSOLE_URL}/api/v1/budgets/members/user_..." \ - --header "Authorization: Bearer ${SERVICE_API_KEY}" -``` - -Deleting a single-member limit does not delete the member. Other applicable policies still cap spend. For legacy or -migrated defaults, deleting the override restores the workspace default, if one exists. Repeating a successful -request is safe and returns HTTP 204. - -## Errors - -| Status | Meaning | -| ------ | --------------------------------------------------------------------------------- | -| `400` | Invalid member ID or budget amount. | -| `401` | Missing, invalid, expired, or revoked service API key. | -| `403` | The API key does not have permission to manage budgets. | -| `404` | The member is not in the workspace bound to the API key. | -| `409` | The budget cannot be changed through this API. Manage it in **Controls** instead. | diff --git a/services/www/src/docs/content/console/api/index.mdx b/services/www/src/docs/content/console/api/index.mdx index f61ac771026..00826d2f10d 100644 --- a/services/www/src/docs/content/console/api/index.mdx +++ b/services/www/src/docs/content/console/api/index.mdx @@ -3,11 +3,10 @@ title: "API Overview" description: "Authenticate with the OpenCode Console API using personal API keys or service account keys, and scope what each key can do." --- -The Console API lets your scripts and integrations call models and manage budgets. Every request authenticates with -an API key. +The Console API lets your scripts and integrations call models. Every request authenticates with an API key. ```bash -curl --fail-with-body "https://opencode.ai/console/api/v1/budgets/members" \ +curl --fail-with-body "https://opencode.ai/inference/v1/models" \ --header "Authorization: Bearer oc_sk_..." ``` @@ -15,7 +14,6 @@ curl --fail-with-body "https://opencode.ai/console/api/v1/budgets/members" \ | ----------------------------------- | ------------------------------------------ | | [Inference](/console/api/inference) | `https://opencode.ai/inference/...` | | [Providers](/console/api/providers) | `https://opencode.ai/inference/custom/...` | -| [Budgets](/console/api/budgets) | `/api/v1/budgets/members` | ## API keys @@ -105,11 +103,11 @@ Set each resource to **None**, **Read**, or **Write**. **Write** includes **Read | **This account's API keys** | **Write** | **Models › Read** lists models, and **Models › Request** also calls them through the [Inference](/console/api/inference) -and [Providers](/console/api/providers) APIs. For example, a key for a budget integration only needs: +and [Providers](/console/api/providers) APIs. For example, a key that only calls models needs: ```text Permissions: Restricted -Budgets: Write +Models: Request ``` Keys created as **Inference only** before scoped permissions show as **Restricted** with **Models** set to **Request**. diff --git a/services/www/src/docs/content/console/budgets.mdx b/services/www/src/docs/content/console/budgets.mdx index 2d746b2ef63..fe066e27ef9 100644 --- a/services/www/src/docs/content/console/budgets.mdx +++ b/services/www/src/docs/content/console/budgets.mdx @@ -86,9 +86,3 @@ including budget details and reset dates. Owners and admins can open **Activity › Usage** from the spending chart. It breaks down cost by day, model, and person, and the **Export usage** button downloads daily totals for the last 7, 30, or 90 days as CSV. - -## Automate budgets - -Use the [Budgets API](/console/api/budgets) to read individual monthly all-spend limits and manage single-member -limits, including after migration to budget policies. Manage shared, tag-based, and model-specific policies in -**Controls**. diff --git a/services/www/src/docs/lib/navigation.ts b/services/www/src/docs/lib/navigation.ts index 5e0de891ca3..d8d58a10cc5 100644 --- a/services/www/src/docs/lib/navigation.ts +++ b/services/www/src/docs/lib/navigation.ts @@ -158,7 +158,6 @@ export const docsSections: DocsSection[] = [ { title: "Overview", slug: "console/api" }, { title: "Inference", slug: "console/api/inference" }, { title: "Providers", slug: "console/api/providers" }, - { title: "Budgets", slug: "console/api/budgets" }, ], }, {