Replace routing rules
curl --request PUT \
--url https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": true
}
'import requests
url = "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload = {
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": True
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": True
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
rules: [
{
name: 'Existing customers',
conditions: [
{
field: 'first_message_text',
operator: 'regex',
value: '(my order|tracking|refund)'
}
],
target_workflow_id: '33333333-3333-4333-8333-333333333333',
is_active: true
},
{
name: 'Chile web leads',
conditions: [
{field: 'channel', operator: 'eq', value: 'webchat'},
{field: 'metadata.country', operator: 'eq', value: 'CL'}
],
target_workflow_id: '55555555-5555-4555-8555-555555555555'
}
],
confirm: true
})
};
fetch('https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'rules' => [
[
'name' => 'Existing customers',
'conditions' => [
[
'field' => 'first_message_text',
'operator' => 'regex',
'value' => '(my order|tracking|refund)'
]
],
'target_workflow_id' => '33333333-3333-4333-8333-333333333333',
'is_active' => true
],
[
'name' => 'Chile web leads',
'conditions' => [
[
'field' => 'channel',
'operator' => 'eq',
'value' => 'webchat'
],
[
'field' => 'metadata.country',
'operator' => 'eq',
'value' => 'CL'
]
],
'target_workflow_id' => '55555555-5555-4555-8555-555555555555'
]
],
'confirm' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload := strings.NewReader("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}"
response = http.request(request)
puts response.read_body{
"agent_group_id": "11111111-1111-4111-8111-111111111111",
"rules": [
{
"id": "9b2f7c1e-0000-4000-8000-000000000002",
"position": 0,
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"id": "9b2f7c1e-0000-4000-8000-000000000003",
"position": 1,
"is_active": true,
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
]
}{
"error": "invalid_rule_target_workflow"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "inbound_router_not_enabled"
}{
"error": "agent_group_not_found"
}{
"error": "internal_error"
}Replace routing rules
Replace an agent’s routing rules in one call. Array order is priority. Requires confirm: true.
PUT
/
master-workflows
/
{id}
/
router
/
rules
Replace routing rules
curl --request PUT \
--url https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": true
}
'import requests
url = "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload = {
"rules": [
{
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": True
},
{
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
],
"confirm": True
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
rules: [
{
name: 'Existing customers',
conditions: [
{
field: 'first_message_text',
operator: 'regex',
value: '(my order|tracking|refund)'
}
],
target_workflow_id: '33333333-3333-4333-8333-333333333333',
is_active: true
},
{
name: 'Chile web leads',
conditions: [
{field: 'channel', operator: 'eq', value: 'webchat'},
{field: 'metadata.country', operator: 'eq', value: 'CL'}
],
target_workflow_id: '55555555-5555-4555-8555-555555555555'
}
],
confirm: true
})
};
fetch('https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'rules' => [
[
'name' => 'Existing customers',
'conditions' => [
[
'field' => 'first_message_text',
'operator' => 'regex',
'value' => '(my order|tracking|refund)'
]
],
'target_workflow_id' => '33333333-3333-4333-8333-333333333333',
'is_active' => true
],
[
'name' => 'Chile web leads',
'conditions' => [
[
'field' => 'channel',
'operator' => 'eq',
'value' => 'webchat'
],
[
'field' => 'metadata.country',
'operator' => 'eq',
'value' => 'CL'
]
],
'target_workflow_id' => '55555555-5555-4555-8555-555555555555'
]
],
'confirm' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules"
payload := strings.NewReader("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.getnexor.ai/api/public/master-workflows/{id}/router/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rules\": [\n {\n \"name\": \"Existing customers\",\n \"conditions\": [\n {\n \"field\": \"first_message_text\",\n \"operator\": \"regex\",\n \"value\": \"(my order|tracking|refund)\"\n }\n ],\n \"target_workflow_id\": \"33333333-3333-4333-8333-333333333333\",\n \"is_active\": true\n },\n {\n \"name\": \"Chile web leads\",\n \"conditions\": [\n {\n \"field\": \"channel\",\n \"operator\": \"eq\",\n \"value\": \"webchat\"\n },\n {\n \"field\": \"metadata.country\",\n \"operator\": \"eq\",\n \"value\": \"CL\"\n }\n ],\n \"target_workflow_id\": \"55555555-5555-4555-8555-555555555555\"\n }\n ],\n \"confirm\": true\n}"
response = http.request(request)
puts response.read_body{
"agent_group_id": "11111111-1111-4111-8111-111111111111",
"rules": [
{
"id": "9b2f7c1e-0000-4000-8000-000000000002",
"position": 0,
"name": "Existing customers",
"conditions": [
{
"field": "first_message_text",
"operator": "regex",
"value": "(my order|tracking|refund)"
}
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333",
"is_active": true
},
{
"id": "9b2f7c1e-0000-4000-8000-000000000003",
"position": 1,
"is_active": true,
"name": "Chile web leads",
"conditions": [
{
"field": "channel",
"operator": "eq",
"value": "webchat"
},
{
"field": "metadata.country",
"operator": "eq",
"value": "CL"
}
],
"target_workflow_id": "55555555-5555-4555-8555-555555555555"
}
]
}{
"error": "invalid_rule_target_workflow"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "inbound_router_not_enabled"
}{
"error": "agent_group_not_found"
}{
"error": "internal_error"
}This call replaces the whole list. To add, edit, or reorder a single rule, read the list with List rules, change it, and send it back complete.
Text comparisons ignore upper and lower case. Before going live, check the order with Test a message.
- Array order is priority: the first rule is checked first.
rules: []removes every rule.- Every saved rule gets a new
id. - If one rule is invalid, nothing is saved.
target_workflow_idmust be one of the agent’s tasks, otherwise 400invalid_rule_target_workflow.
{
"rules": [
{
"name": "Existing customers",
"conditions": [
{ "field": "first_message_text", "operator": "regex", "value": "(my order|tracking|refund)" }
],
"target_workflow_id": "33333333-3333-4333-8333-333333333333"
},
{
"name": "Web chat from Chile",
"conditions": [
{ "field": "channel", "operator": "eq", "value": "webchat" },
{ "field": "metadata.country", "operator": "eq", "value": "CL" }
],
"target_workflow_id": "22222222-2222-4222-8222-222222222222"
}
],
"confirm": true
}
Conditions
All conditions of a rule must match. A rule without conditions matches every conversation, so put it last.field | What it checks |
|---|---|
channel | Channel of the conversation, such as whatsapp, webchat, or email. |
first_message_text | The lead’s first message. |
source | Where the lead came from, as saved on the lead. |
phone, email | The lead’s phone number and email. |
tags | The lead’s tags. |
metadata.country | Any value in the lead’s metadata, written as a dotted path. |
operator | Matches when the value |
|---|---|
eq, neq | is equal, or different. |
gt, gte, lt, lte | is greater or less than a number. |
contains, not_contains | contains a piece of text, or does not. |
in, not_in | is one of the values of an array, or none of them. |
regex | matches a regular expression. |
exists, not_exists | has a value, or has none. These two do not use value. |
Authorizations
API key for authentication. Keys are prefixed with nxr_live_.
Path Parameters
Agent ID (master_workflow in the API). A malformed ID returns 400 invalid_group_id.
Body
application/json
Last modified on September 28, 2026
⌘I