---
title: "Update routing rule"
method: PUT
path: "/api/governance/routing-rules/{rule_id}"
tags: ["Governance"]
---

# Update routing rule

`PUT /api/governance/routing-rules/{rule_id}`

Updates an existing routing rule's configuration.

## Path parameters

- `rule_id` string, required

## Request body

- UpdateRoutingRuleRequest — Request to update a routing rule (all fields optional; providing `targets` replaces all existing targets)
  - `name` string
  - `description` string
  - `enabled` boolean
  - `cel_expression` string
  - `targets` object[] — Replaces all existing targets when provided; weights must sum to 1
    - `provider` string, nullable — Target provider (omit or empty to use the incoming request provider)
    - `model` string, nullable — Target model (omit or empty to use the incoming request model)
    - `key_id` string, nullable — UUID of the API key to pin for this target (omit for load-balanced key selection)
    - `weight` number, double, required — Probability weight for this target (must be > 0; all target weights in a rule must sum to 1, e.g. 0.7 + 0.3 = 1.0)
  - `fallbacks` string[]
  - `priority` integer
  - `query` object, nullable

## Response `200`

Routing rule updated successfully

- RoutingRuleResponse — Response containing created/updated routing rule
  - `message` string
  - `rule` RoutingRule — Global scope routing rule
    - `id` string — Unique identifier for the routing rule
    - `name` string — Name of the routing rule
    - `description` string — Description of what the rule does
    - `enabled` boolean — Whether the rule is enabled and active
    - `cel_expression` string — CEL (Common Expression Language) expression for matching
    - `targets` object[] — Weighted routing targets; weights must sum to 1; target is selected probabilistically at request time
      - `provider` string, nullable — Target provider (omit or empty to use the incoming request provider)
      - `model` string, nullable — Target model (omit or empty to use the incoming request model)
      - `key_id` string, nullable — UUID of the API key to pin for this target (omit for load-balanced key selection)
      - `weight` number, double, required — Probability weight for this target (must be > 0; all target weights in a rule must sum to 1, e.g. 0.7 + 0.3 = 1.0)
    - `fallbacks` string[] — Fallback providers in format "provider/model"
    - `scope` 'global', required — Scope level for the rule
    - `scope_id` string, nullable — ID for the scope (empty for global scope)
    - `priority` integer — Priority for rule evaluation (lower number = higher priority)
    - `query` object, nullable — Visual rule tree structure from query builder
    - `created_at` string, date-time
    - `updated_at` string, date-time

## Other responses

- `400` — Bad request
- `404` — Routing rule not found
- `500` — Internal server error

---

[API](https://skmtc.net/getbifrost/apis/bifrost-api.md) · [All operations](https://skmtc.net/getbifrost/apis/bifrost-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/getbifrost/bifrost-api/versions/f8cab88f64ea/schema)
