Update monthly spend cap with PATCH /api/v1/workspaces/{workspaceId}/billing/spend-controls. Requires a signed-in workspace owner, in the web app or the CLI; API keys are not accepted and MCP cannot call it.
Request
| Parameter | In | Type | Required |
|---|---|---|---|
workspaceId |
path | UUID | Yes |
| Body field | Type | Required |
|---|---|---|
version |
integer | Yes |
monthlySpendCapMicros |
integer or null | Yes |
Response
- HTTP 200:
WorkspaceBillingwithworkspaceId,plan,status,paymentStatus,interval,gateway,periodStart,periodEnd,cancelAtPeriodEnd,creditBalanceMicros,creditBalance,spendControls,currentPeriod.plan:payg,pro,platform,enterprisestatus:active,trialing,past_due,canceled,incomplete,unpaidpaymentStatus:ok,payment_required,insufficient_credit,spend_cap_reachedgateway:fake,stripe
The OpenAPI document has each field’s type.
Examples
const billing = await workspace.billing.updateSpendControls({
version: 4,
monthlySpendCapMicros: 50000000,
});Create this client with a signed-in person’s accessToken, not an apiKey.
The Python SDK authenticates with a workspace API key, which this operation does not accept, so it has no method for it.
curl -X PATCH "https://pubnio.com/api/v1/workspaces/$WORKSPACE_ID/billing/spend-controls" \
-H "Authorization: Bearer $PUBNIO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"version":4,"monthlySpendCapMicros":50000000}'pnio billing spend-cap --version 4 --file spend-controls.jsonasync () => {
const response = await codemode.request({
method: "PATCH",
path: `/api/v1/workspaces/${codemode.workspaceId}/billing/spend-controls`,
body: { version: 4, monthlySpendCapMicros: 50000000 },
});
return response.data;
};Errors
invalid-billing-date-range: HTTP 400, Invalid billing date rangebilling-revision-conflict: HTTP 409, Billing settings changed concurrently
It also declares the problems most operations declare.
Idempotency
No key. The required version makes a stale retry fail instead of applying twice.
Limits
- API keys and MCP cannot call it. A signed-in person runs it from the CLI after
pnio auth loginor in the web app.