SIP
The sip resource connects phone and SIP calls to rooms. For inbound, provision numbers and bind them to a room with a routing rule. For outbound, place a call through a routing rule or gateway.
Sub-resources: phoneNumbers, routingRules, calls, trunks, inboundGateways, outboundGateways, webhooks.
Phone numbers
Provisioning numbers also creates their inbound and outbound gateways.
- Node.js
- Go
await client.sip.phoneNumbers.create({
name: "Support line",
phoneNumbers: ["+14155550100"],
inbound: { sipRegion: "us002" },
outbound: { address: "sip.telnyx.com:5061", sipRegion: "us002" },
});
client.SIP.PhoneNumbers.Create(ctx, videosdk.CreatePhoneNumbersParams{
Name: "Support line",
PhoneNumbers: []string{"+14155550100"},
Inbound: videosdk.PhoneNumberInboundConfig{SIPRegion: videosdk.SIPRegionUS002},
Outbound: videosdk.PhoneNumberOutboundConfig{Address: "sip.telnyx.com:5061", SIPRegion: videosdk.SIPRegionUS002},
})
Also list, get, detach, updateGateway, release.
Routing rules
Bind provisioned numbers to a destination room. rule is either a fixed room (direct) or a fresh room per call (individual).
- Node.js
- Go
await client.sip.routingRules.create({
name: "inbound → support",
type: "inbound",
phoneNumbers: ["+14155550100"],
rule: { type: "direct", roomId: "support-line" },
});
client.SIP.RoutingRules.Create(ctx, videosdk.CreateRoutingRuleParams{
Name: "inbound → support",
Type: videosdk.SIPInbound,
PhoneNumbers: []string{"+14155550100"},
Rule: &videosdk.RoutingRuleTarget{Type: videosdk.RoutingRuleDirect, RoomID: "support-line"},
})
Also list, get, update, delete.
Calls
- Node.js
- Go
const call = await client.sip.calls.create({
routingRuleId: "rr_1",
callTo: "+14155550123",
callFrom: "+14155550100",
});
await client.sip.calls.transfer(call.id, { to: "+14155550199" });
await client.sip.calls.switchRoom(call.id, { roomId: "escalation" });
await client.sip.calls.end(call.id);
call, err := client.SIP.Calls.Create(ctx, videosdk.CreateSIPCallParams{
RoutingRuleID: "rr_1",
CallTo: "+14155550123",
CallFrom: "+14155550100",
})
client.SIP.Calls.Transfer(ctx, call.ID, videosdk.TransferSIPCallParams{To: "+14155550199"})
client.SIP.Calls.SwitchRoom(ctx, call.ID, videosdk.SwitchRoomParams{RoomID: "escalation"})
client.SIP.Calls.End(ctx, call.ID)
Also list and get.
Trunks and gateways
A trunk is a single directional gateway.
- Node.js
- Go
const outbound = await client.sip.trunks.createOutbound({
address: "sip.telnyx.com",
numbers: ["+14155550100"],
});
await client.sip.trunks.list();
await client.sip.trunks.delete(outbound);
outbound, err := client.SIP.Trunks.CreateOutbound(ctx, videosdk.CreateOutboundGatewayParams{
Address: "sip.telnyx.com",
Numbers: []string{"+14155550100"},
})
client.SIP.Trunks.List(ctx)
client.SIP.Trunks.Delete(ctx, outbound.ID, videosdk.SIPOutbound)
For full control, inboundGateways and outboundGateways each expose create, list, get, update, and delete.
Webhooks
Subscribe to call-lifecycle events (call-started, call-answered, call-hangup, and more).
- Node.js
- Go
await client.sip.webhooks.create({
url: "https://example.com/hook",
events: ["call-started", "call-hangup"],
});
client.SIP.Webhooks.Create(ctx, videosdk.CreateSIPWebhookParams{
URL: "https://example.com/hook",
Events: []videosdk.SIPWebhookEvent{videosdk.SIPWebhookCallStarted, videosdk.SIPWebhookCallHangup},
})
Also list, get, update, delete.
Got a Question? Ask us on discord

