---
title: "Create routing rule"
method: POST
path: "/api/governance/routing-rules"
tags: ["Governance"]
---

# Create routing rule

`POST /api/governance/routing-rules`

Creates a new CEL-based routing rule for intelligent request routing. Provider and model can be left empty to use the incoming request values.

## Request body

- CreateRoutingRuleRequest — Global scope routing rule
  - `name` string, required — Name of the routing rule
  - `description` string — Optional description
  - `enabled` boolean — Whether the rule is enabled
  - `cel_expression` string, required — CEL expression for matching
  - `targets` object[], required — 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 (required if scope is not global)
  - `priority` integer, required — Priority for rule evaluation (lower number = higher priority)
  - `query` object, nullable — Visual rule tree structure

## Response `200`

Routing rule created 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
- `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)
