Skip to main content

Create Routing Rule

POST /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

ParameterTypeDescription
processorIdstring (uuid)Processor ID

Request Body

FieldTypeRequiredDescription
namestringYesHuman-readable rule name (e.g., "English leads")
workflow_idstring (uuid)YesTarget workflow when this rule matches
conditionsarrayYesArray of condition objects (AND logic — all must match)
positionintegerNoEvaluation order (lower = first). Auto-appended if omitted
is_activebooleanNoDefaults to true

Condition Object

Each condition evaluates a single field on the incoming lead payload:

FieldTypeRequiredDescription
fieldstringYesDotted path to the lead field (see supported fields below)
operatorstringYesComparison operator
valueanyDependsComparison value (not required for exists/not_exists)

Supported Fields

FieldSource
first_name, last_name, email, phone, source, company, titleTop-level lead fields
campaign_idCampaign association
metadata.<key>Any key inside the metadata object (e.g., metadata.language, metadata.budget)

Supported Operators

OperatorDescriptionApplies to
eqEqualsstring, number, boolean
neqNot equalsstring, number, boolean
gtGreater thannumber
gteGreater than or equalnumber
ltLess thannumber
lteLess than or equalnumber
containsSubstring match (case-insensitive)string
not_containsNo substring matchstring
inValue is in liststring, number
not_inValue is not in liststring, number
existsField is present and non-nullany
not_existsField is absent or nullany
regexRegex pattern matchstring

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"
}

500 — Internal server error