Authentication
Plan routes usegetAuthorizedProviderApp only: a logged-in provider dashboard session whose user is the app owner, a platform admin, or a providerAdmins team member. Confidential M2M / Basic auth is not accepted on /plans (unlike billing summary and the Usage API in pymthouse docs/builder-api.md).
POST, PUT, and DELETE additionally require canEditProviderApp (same session, with edit rights).
Base path
{clientId} is the public app_… OAuth client id.
List plans
Response shape
Each plan includes:id, clientId, name, type (free | subscription | usage), priceAmount, priceCurrency, status, includedUnits and overageRateWei as strings or null, and capabilities (array).
Create a plan
| Field | Required | Notes |
|---|---|---|
name | Yes | Display name. |
type | No | Defaults to free. subscription requires includedUnits and overageRateWei (non-negative integer strings). |
priceAmount, priceCurrency | No | Defaults 0 / USD. |
status | No | active or inactive; default active. |
capabilities | No | Array of { pipeline, modelId, slaTargetScore?, slaTargetP95Ms?, maxPricePerUnit? }. |
{ "id": "<new-plan-uuid>" }.
Update a plan
id (plan UUID). Omitted fields keep existing values. If capabilities is present, it replaces all bundles for that plan; omit the key to leave bundles unchanged.
200 OK: { "success": true }.
Delete a plan
status: inactive via PUT if subscribers might still reference the plan.
200 OK: { "success": true }. 404 if the plan is missing or not owned by this app.
Errors
| Status | Typical cause |
|---|---|
400 | Missing name, invalid subscription billing fields, malformed capabilities. |
403 | Session cannot edit this app. |
404 | Unknown clientId or plan id. |
Examples
Call GET/POST/PUT/DELETE from a trusted context that has the provider dashboard session (browser on the PymtHouse console, or server-side with the user’s session cookie). Example with session cookie:Implementation reference
Canonical contract:pymthouse docs/builder-api.md (Billing API → Plans). Code: src/app/api/v1/apps/[id]/plans/route.ts.