> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a routing rule

> Create an alert routing rule, placed last.

```http theme={null}
POST /api/v1/alerts/routing/rules
```

Creates a [routing rule](https://docs.molesignal.com/en-US/alerting/routing.md#routing-rules). It requires `alerts.routing.manage`. A new rule goes last; [Reorder routing rules](https://docs.molesignal.com/en-US/api/alerting/reorder-routing-rules.md) moves it up. An organization has at most 200 routing rules.

| Field | Type | Description |
| - | - | - |
| `name` | string | Required; 1 to 128 characters once trimmed. |
| `enabled` | boolean | Defaults to `true`. |
| `conditions` | array | At most 16, empty by default. A `key` has 1 to 512 characters; `equals`, `not_equals` and `matches` take one value each, `in` takes 1 to 100, each at most 512 characters; the pattern of `matches` must compile. |
| `min_severity` | string \| null | `info`, `warning`, `error` or `critical`; any severity by default. |
| `origins` | array | Some of `rule`, `external` and `synthetic`; empty by default, meaning all. |
| `target` | object | Required. `{"kind": "team", "team_id": …}` must be a team of the organization, `{"kind": "policy", "policy_id": …}` an escalation policy of the organization. |

```bash cURL theme={null}
curl -X POST http://localhost:5080/api/v1/alerts/routing/rules \
  -H "authorization: Bearer $MS_TOKEN" \
  -H "content-type: application/json" \
  -d '{"name": "Payments in production", "conditions": [{"key": "env", "operator": "equals", "values": ["prod"]}], "min_severity": "error", "target": {"kind": "team", "team_id": "<team-id>"}}'
```

The response is the new rule; see [Rule fields](https://docs.molesignal.com/en-US/api/alerting/list-routing-rules.md#rule-fields).

**Errors**

| Status | Cause |
| - | - |
| `400` | A field is wrong: an empty name, the wrong number of values for a condition, a pattern that does not compile, a target team or policy that does not exist, or 200 rules already. |
| `403` | The token lacks `alerts.routing.manage`. |
| `422` | `name` or `target` is missing, or a value is not recognized, such as an unknown `operator`. The response is plain text. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.