Create Routing Rule
/processors/:processorId/rules
Add a routing rule to a processor. Rules are evaluated top to bottom by position — the first rule where all conditions match determines the target workflow.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
processorId | string (uuid) | Processor ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Human-readable rule name (e.g., "English leads") |
workflow_id | string (uuid) | Yes | Target workflow when this rule matches |
conditions | array | Yes | Array of condition objects (AND logic — all must match) |
position | integer | No | Evaluation order (lower = first). Auto-appended if omitted |
is_active | boolean | No | Defaults to true |
Condition Object
Each condition evaluates a single field on the incoming lead payload:
| Field | Type | Required | Description |
|---|---|---|---|
field | string | Yes | Dotted path to the lead field (see supported fields below) |
operator | string | Yes | Comparison operator |
value | any | Depends | Comparison value (not required for exists/not_exists) |
Supported Fields
| Field | Source |
|---|---|
first_name, last_name, email, phone, source, company, title | Top-level lead fields |
campaign_id | Campaign association |
metadata.<key> | Any key inside the metadata object (e.g., metadata.language, metadata.budget) |
Supported Operators
| Operator | Description | Applies to |
|---|---|---|
eq | Equals | string, number, boolean |
neq | Not equals | string, number, boolean |
gt | Greater than | number |
gte | Greater than or equal | number |
lt | Less than | number |
lte | Less than or equal | number |
contains | Substring match (case-insensitive) | string |
not_contains | No substring match | string |
in | Value is in list | string, number |
not_in | Value is not in list | string, number |
exists | Field is present and non-null | any |
not_exists | Field is absent or null | any |
regex | Regex pattern match | string |
Logic
- Multiple conditions within a rule use AND logic — all must match.
- For OR logic, create separate rules pointing to the same workflow.
- First match wins — once a rule matches, evaluation stops.
- If no rule matches, the processor's default workflow is used.
Examples
Simple language-based routing
curl -X POST https://api.getnexor.ai/api/public/processors/abc-123-uuid/rules \
-H "Content-Type: application/json" \
-H "X-API-Key: nxr_live_your_api_key" \
-d '{
"name": "English leads",
"workflow_id": "uuid-of-en-workflow",
"position": 1,
"conditions": [
{
"field": "metadata.language",
"operator": "eq",
"value": "EN"
}
]
}'
Multi-condition rule (AND logic)
Route high-budget leads from CDMX to a premium workflow:
curl -X POST https://api.getnexor.ai/api/public/processors/abc-123-uuid/rules \
-H "Content-Type: application/json" \
-H "X-API-Key: nxr_live_your_api_key" \
-d '{
"name": "Premium CDMX",
"workflow_id": "uuid-of-premium-workflow",
"position": 1,
"conditions": [
{
"field": "metadata.budget",
"operator": "gte",
"value": 5000000
},
{
"field": "metadata.city",
"operator": "eq",
"value": "CDMX"
}
]
}'
Using in operator for multiple values
curl -X POST https://api.getnexor.ai/api/public/processors/abc-123-uuid/rules \
-H "Content-Type: application/json" \
-H "X-API-Key: nxr_live_your_api_key" \
-d '{
"name": "Coastal regions",
"workflow_id": "uuid-of-coastal-workflow",
"position": 2,
"conditions": [
{
"field": "metadata.state",
"operator": "in",
"value": ["Quintana Roo", "Yucatan", "Baja California"]
}
]
}'
Responses
201 — Rule created
{
"success": true,
"rule": {
"id": "rule-uuid",
"processor_id": "abc-123-uuid",
"name": "English leads",
"workflow_id": "uuid-of-en-workflow",
"workflow": {
"id": "uuid-of-en-workflow",
"name": "Payment Link Sent"
},
"conditions": [
{
"field": "metadata.language",
"operator": "eq",
"value": "EN"
}
],
"position": 1,
"is_active": true,
"created_at": "2026-03-31T12:00:00Z"
}
}
400 — Validation error
{
"error": "Validation error",
"message": "workflow_id not found or does not belong to your account"
}
Other validation errors:
"name is required""conditions must be an array""Invalid operator: must be one of eq, neq, gt, gte, lt, lte, contains, not_contains, in, not_in, exists, not_exists, regex""Invalid field: must be a lead field or metadata.<key> path"
401 — Authentication error
See Authentication.
404 — Processor not found
{
"error": "Not found",
"message": "Processor not found or does not belong to your account"
}