---
title: "Set Policy"
method: POST
path: "/v1/routing/policies"
tags: ["routing"]
---

# Set Policy

`POST /v1/routing/policies`

Create or update a stored policy in one workspace, optionally for one user.

Omitting ``workspace_id`` means the deployment's default workspace, which is
where an operator acting deployment-wide writes.

## Request body

- PolicyRequest — Request to create or update a routing policy.
  - `name` string, required — Model name callers send, e.g. 'fast'.
  - `rename_from` string, nullable — Current name of the policy to rename, in the same scope, meaning the same workspace and the same user. A rename never moves a policy between them. 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.
  - `spec` object, 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_id` string, nullable — User this policy belongs to. Omit for a policy every caller in the workspace sees. A user-scoped policy resolves only for that user and shadows the workspace-wide one of the same name.
  - `workspace_id` string, uuid, nullable — Workspace this policy belongs to. Omit for the deployment's default workspace. The policy resolves only for requests in that workspace, so two workspaces can each define their own 'fast'.

## Response `200`

Successful Response

- PolicyResponse — A routing policy and where it is defined.
  - `created_at` string, nullable
  - `is_dynamic` boolean
  - `name` string, required
  - `source` string, required
  - `spec` object, required
  - `updated_at` string, nullable
  - `user_id` string, nullable
  - `workspace_id` string, uuid, nullable

## Other responses

- `422` — Validation Error

## Changes

- **2026-08-25** `daef1d31b5d1` — 2 info
  - added the new optional request property `workspace_id`
  - added the optional property `workspace_id` to the response with the `200` status
- **2026-08-12** `312a1df96fce` — 1 info
  - added the new optional request property `rename_from`
- **2026-08-05** `00866b0c5407` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/mozilla-ai/apis/otari/changes/v1/routing/policies/post.md)

---

[API](https://skmtc.dev/mozilla-ai/apis/otari.md) · [All operations](https://skmtc.dev/mozilla-ai/apis/otari/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/mozilla-ai/otari/revisions/b2f4d68a4c7c/schema)
