OpenAPI 3.1.0raw.githubusercontent.com2026-08-20135166549.8 KB

cea76e85cdac

routing

Set Policy

Create or update a stored policy, global or scoped to one user.

The spec is validated here and stored as given, so a row can never contain a body this build would refuse at load. The cache is refreshed twice: once before validating (so the shadowing checks see other writers' policies) and once after committing (so this worker serves the new policy immediately).

rename_from renames the row instead of keying on name. It is part of this write rather than an endpoint of its own so that an edit which both renames a policy and re-targets it cannot land half-applied, leaving the old name serving the new spec. The new name is validated exactly as a fresh one is, because a rename can walk a policy into every collision a create can. Sending the field asserts the named policy is stored, so it never falls back to creating one.

post/v1/routing/policies

Request body

namestring required

Model name callers send, e.g. 'fast'.

rename_fromstring nullable

Current name of the policy to rename, in the same scope. The stored row keeps its id and created_at and takes name and spec. Sending it asserts that policy exists, so a name with no stored row is a 404 rather than a create, even when it equals name. Omit to create or update the policy named name. Renaming changes what callers must send as model; usage already recorded keeps the old name.

specobject required

The policy body: select (with exactly one default entry, last), optional on_failure and guardrails. Same schema as a routing.policies entry in config.yml, and closed to unknown keys, so a typo is a 400 rather than a silently ignored setting.

user_idstring nullable

User this policy belongs to. Omit for a global policy every caller sees. A user-scoped policy resolves only for that user and shadows a global one of the same name.

Response

Successful Response

created_atstring nullable
is_dynamicboolean
namestring required
sourcestring required
specobject required
updated_atstring nullable
user_idstring nullable