Self-serve plan config API
The self-serve plan/tier definitions — the model allowlist, cross-vendor fallback, monthly budget, cap-soft-degrade config, scheduled-tasks cap and seat cap — are stored in the database and editable through this endpoint. Prices are not part of this config: what a plan costs is the product catalog, which mirrors Stripe and is the only price authority. The trial credit a new trial workspace receives lives in the catalog too (trial_credit_eur on the trial row). Changing a plan takes effect immediately: the write invalidates the cached plan configuration across all workers and flushes the cached gateway configuration of every gateway whose workspace is on that plan (the plan's model allowlist is folded into each gateway's effective config), so the next request reads the new values. A plan's budget_usd is not a workspace budget: tenant-level spend is governed by the workspace's wallet plus its own optional spend_cap_usd, which the plan does not bound (see Tenants & gateways). The plan's budget_usd seeds the per-gateway caps of a new trial workspace's gateways when it is provisioned; editing it here does not rewrite existing workspaces or gateways. Both flushes are per node: on a multi-site deployment the other nodes pick the change up when their own caches expire — the plan values within the plan cache lifetime (60 s), and a gateway configuration folded from them within that plus the gateway-config cache lifetime (config_cache_ttl, 30 s by default), so up to about 90 s in the worst case.
These definitions used to be deployment settings; they were migrated into the database (one row per plan) and back-filled from the previous values on first boot, so behaviour is unchanged across the cutover. Secrets are never part of this config: the Stripe secret key and webhook secret, and the self-serve provider-key pool binding, are not editable here.
Custom plan models. Migration 0327 sets the self_serve_custom model list to claude-haiku-4-5, claude-sonnet-5, qwen3.8-27b, gemma-4-31b-it, mistral-small-4 on every environment (before it, the paid plan's list was empty on prod and beta, so every model was refused). The Myra-hosted entries are usable only with the EU-Gov add-on — see Tenant entitlements. Which models are Myra-hosted is decided by the provider (myra), not by this list; to offer a new model, add its id here.
Base URL: https://<your-gateway-host>/admin/v1
Every endpoint requires the platform permission PLANS_MANAGE (held by the platform admin role); a caller without it is 403, an unauthenticated caller 401. Access is re-gated server-side — the client is never the authorization boundary.
List plans
Returns one object per configured plan. The admin console's plan editor (/platform/plans/{plan}/edit) takes the plan name from its address and edits the row of this list whose plan equals it exactly; any other name shows "does not exist" and nothing is saved.
[
{
"plan": "self_serve_custom",
"budget_usd": 15,
"models": ["claude-3-5-haiku-20241022", "gpt-4o-mini"],
"efficient_models": ["claude-3-5-haiku-20241022"],
"fallback": "myra:qwen3.8-27b",
"degrade_provider": "openai",
"degrade_model": "claude-3-5-haiku-20241022",
"degrade_multiplier": 2.0,
"scheduled_tasks": 10,
"max_seats": 500,
"updated_at": 1750000000,
"updated_by": "<admin-user-id>"
}
]
Own provider keys on self-serve plans
Self-serve plans hold no own provider keys. Storing one is refused (400 own_key_not_available_on_plan, see Tenants & gateways), and moving a workspace onto a self-serve plan deletes its stored own keys — gateway-level keys of every provider (anthropic, openai, …) and the tenant-level anthropic-admin key — in the same transaction as the plan change. Each deleted key is audited (gateway.provider_key.deleted / tenant.provider_key.deleted, reason plan_change_self_serve; see Audit log). Keyless myra / mock entries are kept, and Myra's platform pool gateway is exempt (its keys are Myra's keys). Changes between non-self-serve plans, and from a self-serve plan to another, delete nothing. After an upgrade off self-serve the keys must be entered again. A deleted key stops being used within the key-cache lifetime (byok_cache_ttl, per node). Own keys that tenants already on a self-serve plan stored before this rule existed are removed once by an operator, after Sales has seen the list; those deletions are audited with reason legacy_self_serve_cleanup (actor: the system).
Updating a plan
Upserts the plan named in the body. On success the response is 200 {"ok": true}. The change is audited (entity plan_config, action update, or create on the first write of a plan) and the change and its audit row commit together (one transaction; if the audit row cannot be written the edit is rolled back). Answers: 503 (nothing written; retry), a sanitised 500 (not applied, or outcome unknown), and 409 plan_config_changed_concurrently when another container changed the plan between this request's read and its save. It takes effect immediately (the plan cache and the gateway configs of every workspace on the plan are invalidated on success — see above).
Model picker copy follows automatically. The short model lines a self-serve user sees in the picker are written for the set of models the workspace is offered (the plan's models intersected with the EU-Gov add-on gate), relative to each other — e.g. which model is the cheapest or the only one that sees images. Changing models changes the set, so the next picker load generates copy for the new set; nothing needs to be edited by hand. See Tagline resolution and the kill switch plan_model_copy_enabled.
Accepted body
| Field | Type | Rule |
|---|---|---|
plan |
string | Required. Must be self_serve_custom or self_serve_trial. |
budget_usd |
number | Required. >= 0. Kept with every digit: the cached plan configuration reads back the stored value, not a 14-digit rounding. |
models |
array of strings | Required (may be empty). Exact model_price.model ids the plan may use — bare model ids, not provider:model. Every id is checked against the model catalog on write (see below). |
efficient_models |
array of strings | Optional (default []). The over-cap efficient subset; entries outside models are dropped when the config is read (the degrade set can never widen the plan). |
fallback |
string or null |
Optional. provider:model (e.g. myra:qwen3.8-27b) or null to disable the plan's cross-vendor failover. The provider must be one a self-serve gateway can actually be keyed for — see the rejection rule below. |
degrade_provider / degrade_model |
string or null |
Optional; both or neither. The cap-soft-degrade swap target. |
degrade_multiplier |
number or null |
Optional. Must be in (1.0, 10.0]. null disables the secondary hard cap (disarms degrade). |
scheduled_tasks |
integer | Required. >= 0 (0 disables scheduled tasks — used by the self_serve_trial plan). Max active scheduled prompt-tasks per user. |
max_seats |
integer | Required. 1–10000. Max active (non-deleted) users a self-serve tenant on this plan may have; the invite path rejects over-cap adds with 403 seat_limit_reached. |
| (retired) | — | The former Stripe price-id fields and the trial credit are retired: prices come only from the product catalog, and the trial credit is edited there. A body that carries one of them with null (or not at all) is accepted and the field ignored — so a browser tab opened before the change keeps saving; a non-null value is refused (below). The GET no longer returns them. |
Rejected (fail closed — nothing is persisted)
Every rejection is a 400 {"error": "<reason>"} unless noted; on rejection the row is not written:
-
body missing or not a JSON object.
-
planmissing or not one of the two known plans (self_serve_custom,self_serve_trial). budget_usdmissing, non-numeric, negative, or above1000000→code: invalid_plan_budget_usd.scheduled_tasksmissing, non-integer (a numeric string, a fraction and a boolean count as non-integer),< 0, or beyond the 32-bit integer range →code: invalid_scheduled_tasks.max_seatsmissing, non-integer,< 1, or> 10000→code: invalid_max_seats.models(orefficient_models) not a JSON array, or containing a non-string / empty entry.models(orefficient_models) naming a model the gateway does not know — nomodel_pricerow for that id. A plan can only entitle a model that exists, because the model allowlist is fail-closed: an unknown id is not "ignored", it is simply never offered or routed, and nothing says why.models(orefficient_models) naming a deprecated model (model_price.deprecated_atset). Entitling one denies it to every tenant on that tier.models(orefficient_models) naming a model served by the platform key pool (provideranthropic) that has no price (bothinput_per_1kandoutput_per_1kare0). Such a model would be served on Myra's own key while cost calculation prices it at0, so spend would never be metered and the tenant budget would never be reached.fallbackpresent but notprovider:model.fallbacknaming a provider a self-serve gateway can never hold a key for. Self-serve tenants have noprovider_configrows at all, so only two kinds of provider can carry their traffic: a platform-managed keyless provider (e.g.myra), oranthropicwhen the managed key pool is wired. Anything else is refused, because the cross-vendor failover swap would otherwise convert a key-pool outage into424 provider_key_missing— telling a customer to add a provider key in gateway settings they do not have, for a vendor they never chose. Checked only when the value changes: this endpoint rewrites every column, so a row written before this rule keeps saving (an edit that only changesbudget_usdis not blocked by a legacyfallback). Set it tonullto clear one. A legacy unservable value is reported once per boot as across-vendor FAILOVER DISARMEDwarning, and at request time the failover is skipped and the turn fails closed with a retryable503 provider_quota_exhaustedrather than the misdirected 424.fallback,degrade_providerordegrade_modelpresent but not a string ornull(an empty string counts asnull).- only one of
degrade_provider/degrade_modelset. degrade_multiplierpresent but not a number in(1.0, 10.0](an object, array, string or boolean is refused too; onlynullor absent disarms) →code: invalid_degrade_multiplier.fallback's model half, anddegrade_model, must pass a catalog check — an unknown or deprecated model is rejected, and the target must be priced (a0/0price is rejected for any provider here, unlike the entitlement list; see the zero-price note below) — anddegrade_providermust be a servable self-serve provider just likefallback's provider. When any of these validations cannot read the model catalog, the write returns503(not400).- a retired field with a value (absent,
nulland""count as not sent and are ignored) →400 {"error":"field_retired","field":"<name>","message":"The field '<name>' was removed. Reload the page."}. Retired:stripe_price_monthly,stripe_price_annual,trial_credit_eur. - a second plan-config edit is already in progress →
409(retry).
Two different zero-price rules apply, by role:
- In the entitlement list (
models/efficient_models), a zero price is only rejected for pool-served models. Locally hosted models (providermyra) are legitimately zero-priced and stay entitleable — a blanket "must be billable" rule would reject every future edit of a plan that includes one, including an edit that only changes the budget or the seat cap, because this endpoint rewrites every column. - As a swap target (
fallback's model half ordegrade_model), a0/0price is rejected for every provider, includingmyra: the platform silently swaps traffic onto this target during an outage, so an unpriced target would be unmetered and the tenant budget would never be reached. So a locally hosted model that is fine to entitle at zero price cannot be used as the fallback/degrade target unless it is priced.
If the model catalog cannot be read, the request is rejected with 503 { "error": "temporarily unavailable; retry later" } (retryable; no cause text) rather than 400: the submitted model list may be perfectly valid and the database merely unreachable. A failed read of the plan configuration (GET, or the read before a PUT) is the same 503 { "error": "temporarily unavailable; retry later" }; a failed write is 500 { "error": "internal error", "request_id": "…" } (re-read before repeating).
An empty models array remains valid and means deny all — a deliberate fail-safe state, not an error.
Prices are not stored here: signup and conversion checkout charge the plan's catalog slot (the component price the product catalog resolves from its Stripe mirror). When the catalog cannot resolve a price for the chosen plan and interval, checkout answers 503 checkout_unavailable rather than billing a wrong or missing price — never a silent mis-bill.