Create Routing Rule - API
Creates a routing rule and attaches it to the supplied phone numbers. A routing rule defines how SIP calls for those numbers are dispatched — either into a VideoSDK room (static or dynamic) and/or to an AI agent.
Header field rules:
headersis only allowed on outbound rules — these custom SIP headers are attached to outgoing INVITEs.headersToAttributesis only allowed on inbound rules — it maps incoming SIP headers to participant attributes.- Sending the wrong one for the rule's
typereturns400.
Validations:
nameis required.typemust be one ofinbound,outbound.phoneNumbersmust be an array of numbers that already exist on your account (provisioned via the Phone Numbers API).- Inbound rules cannot reuse numbers already attached to another inbound rule (returns
400). apiKey, if provided, must be a valid API key.
Responses:
201success — returns the created routing rule.400validation failure.500internal server error.
HTTP method and endpoint
|
values: YOUR_TOKEN_WITHOUT_ANY_PREFIX
This will be a JWT token generate using VideoSDK ApiKey and Secret.
Note that the token will not include any prefix such as "Basic " or "Bearer ". Just pass a token as value.
You can generate a new token by refering this Guide: Generate Auth token
values: application/json
This is usefull for json body parameters, so that VideoSDK servers can understand that the incoming body parameter will be a JSON string.
inbound, outbound. Cannot be changed after creation. 400 Invalid API Key otherwise. { team: 'support' }). Room dispatch config.
type:static|dynamic.prefix: prefix used when creating dynamic rooms (e.g.blank).id: room ID, used whentype = static.pin: optional room PIN.
ALL, SIP_X_HEADERS, NONE. 400 on outbound rules. 400 on inbound rules. true, the caller's phone number is hidden when dispatching the call. inbound or outbound. { type, prefix, id, pin }. Top-level (no dispatch wrapper). null. apiKey was supplied at create time. ALL, SIP_X_HEADERS, or NONE. import fetch from 'node-fetch';
const options = {
method: "POST",
headers: {
"Authorization": "$YOUR_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "Inbound support rule",
"type": "inbound",
"phoneNumbers": [
"+14155551234"
],
"apiKey": "$YOUR_API_KEY",
"agentId": "$YOUR_AGENT_ID",
"agentMetadata": {
"team": "support"
},
"room": {
"type": "dynamic",
"prefix": "blank"
},
"includeHeaders": "SIP_X_HEADERS",
"headersToAttributes": {
"X-Caller-Id": "callerId"
},
"headers": {
"X-Customer-Id": "cust_42"
},
"allowedNumbers": [],
"allowedIpAddresses": [],
"tags": [
"support",
"v2"
],
"recording": false,
"dtmf": false,
"noiseCancellation": false,
"hidePhoneNumber": true
}),
};
const url= `https://api.videosdk.live/v2/sip/routing-rule`;
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
{
"id": "rr_abc123",
"name": "Inbound support rule",
"type": "inbound",
"numbers": [
"+14155551234"
],
"room": {
"type": "dynamic",
"prefix": "blank",
"id": null,
"pin": null
},
"agentId": "agent_xyz",
"agentMetadata": {
"team": "support"
},
"hidePhoneNumber": true,
"tags": [
"support",
"v2"
],
"apiKey": "ak_resolved",
"recording": false,
"dtmf": false,
"noiseCancellation": false,
"allowedNumbers": [],
"allowedIpAddresses": [],
"includeHeaders": "SIP_X_HEADERS",
"headersToAttributes": {
"X-Caller-Id": "callerId"
},
"createdAt": "2026-05-11T10:00:00.000Z",
"updatedAt": "2026-05-11T10:00:00.000Z"
}
Got a Question? Ask us on discord