echoing-lamp-18687
03/09/2026, 9:21 AM<address>
• SIP Port: <port>
• Transport Protocol: UDP
• SIP Authentication Method: IP-based authentication
• Supported Codecs: G.711 and G.729
When I went to the LiveKit dashboard and tried creating an Outbound Trunk, I noticed:
I couldn’t find an option for IP-based authentication.
1. In the codec settings, G.711 and G.729 were not listed.
Is it possible to configure a SIP provider like this in LiveKit?
If so, what’s the correct way to handle IP-based authentication and these codecs?tall-airline-16756
03/09/2026, 9:21 AMtall-airline-16756
03/09/2026, 9:21 AMPCMU and/or PCMA for G.711 and G729 for G.729 in the trunk’s codecs array so RTP/SDP negotiation includes those codecs.
Example (conceptual; adapt to your SDK/language)
trunk = SIPOutboundTrunkInfo(
name="My IP Auth Trunk",
protocol="udp",
gateway="<address>",
gateway_port=<port>,
allowed_addresses=["<provider-public-ip>"],
codecs=["PCMU", "PCMA", "G729"]
)
# then call the create trunk API with this trunk object
Notes on the codec names
• G.711 is represented as PCMU (μ-law) and PCMA (A-law).
• G.729 is represented as G729.
Validation and testing tips
• Make sure your provider will send from the listed IP(s) and that you enter the correct public IP(s) in allowed_addresses.
• Confirm your provider supports the same codec names in SDP offers (PCMU/PCMA/G729).
• After creating the trunk, place a test call and inspect the SDP to confirm the negotiated codec is one of the requested codecs and that RTP flows correctly.
If you’d like, tell me:
• Which SDK or CLI you want to use (Python, Go, CLI), and I’ll give the exact command or code snippet you can run.
• The provider public IP(s) and preferred codec order, and I’ll draft a ready-to-run request (with placeholders for your address/port). Sources: sip | livekit/livekit_composite | DeepWiki | server-sdk-kotlin | livekit/livekit_composite | DeepWikiechoing-lamp-18687
03/09/2026, 9:24 AMtall-airline-16756
03/09/2026, 9:24 AM// Template: create an outbound SIP trunk in Node.js
// Replace placeholders: <API_BASE_URL>, <API_KEY>, <API_SECRET>, <address>, <port>, <provider_ip>
const fetch = require('node-fetch'); // or use axios
const crypto = require('crypto');
const API_BASE = '<API_BASE_URL>'; // e.g. <https://your-livekit-instance/api>
const API_KEY = '<API_KEY>';
const API_SECRET = '<API_SECRET>';
// Example: simple HMAC auth header if your LiveKit instance uses API key/secret.
// Adjust auth to match your LiveKit deployment authentication method.
function makeAuthHeader() {
const ts = Math.floor(Date.now() / 1000).toString();
const mac = crypto.createHmac('sha256', API_SECRET).update(API_KEY + ts).digest('hex');
return `APIKEY ${API_KEY}:${mac}:${ts}`;
}
async function createOutboundTrunk() {
const url = `${API_BASE}/v1/sip/outbound_trunks`; // adjust path if different
const body = {
trunk: {
name: "My IP Auth Trunk",
protocol: "udp",
gateway: "<address>", // SIP Server Address
gateway_port: <port>, // SIP Port (number)
allowed_addresses: ["<provider-public-ip>"], // IP-based auth (whitelist)
codecs: ["PCMU", "PCMA", "G729"], // G.711 as PCMU/PCMA, plus G729
// optional fields you may include:
// numbers: ["+12223334444"],
// krisp_enabled: false,
}
};
const res = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': makeAuthHeader(), // adapt as needed
},
body: JSON.stringify(body),
});
if (!res.ok) {
const text = await res.text();
throw new Error(`Failed to create trunk: ${res.status} ${text}`);
}
const data = await res.json();
return data;
}
createOutboundTrunk()
.then((r) => {
console.log('Trunk created:', JSON.stringify(r, null, 2));
})
.catch((err) => {
console.error('Error creating trunk:', err.message);
});
Notes and how to adapt
• Authentication: Replace the example HMAC auth with whatever your LiveKit API expects (API key header, JWT, or other). The template shows one possible approach but must match your deployment.
• Endpoint path: I used /v1/sip/outbound_trunks as an example. If your LiveKit API path differs, change url accordingly.
• Codecs: Use PCMU / PCMA for G.711 (μ-law / A-law) and G729 for G.729.
• IP auth: Add your provider’s public IP(s) to allowed_addresses to enable IP‑based authentication.
• If your environment uses the official Node.js SDK (not raw HTTP), the payload fields are the same — you would construct the equivalent SDK request object and call the SDK method to create the trunk.
If you want, I can:
• Convert this template to use a specific HTTP library (axios) or the official LiveKit Node SDK if you confirm which SDK version/installation you have.
• Fill in a complete example for your auth method (API key header vs JWT) if you tell me how your LiveKit instance is secured.
• Verify the exact API path if you share the LiveKit version or API base path you’re using. Sources: sip | livekit/livekit_composite | DeepWiki | Python SDKs | livekit/livekit_composite | DeepWiki | Creating SIP Inbound Trunks and Dispatch Rules with Python SDKechoing-lamp-18687
03/09/2026, 9:31 AMtall-airline-16756
03/09/2026, 9:31 AMechoing-lamp-18687
03/09/2026, 9:35 AMtall-airline-16756
03/09/2026, 9:36 AMoutbound-trunk.json.
2. Run the CLI command to create the trunk:
◦ lk sip outbound create outbound-trunk.json
1. Verify the trunk was created:
◦ lk sip outbound list
◦ Optionally inspect the created trunk: lk sip outbound get <trunk_id>
Sample JSON payload Save this as outbound-trunk.json and replace placeholders with your values (address, port, provider IPs, numbers if needed):
{
"trunk": {
"name": "My Outbound Trunk",
"outbound": {
"address": "<http://sip.provider.com|sip.provider.com>",
"port": 5060,
"transport": "udp",
"allowed_auth_identity": "",
"allowed_addresses": [
"203.0.113.10",
"203.0.113.11"
],
"codecs": [
"PCMU",
"PCMA",
"G729"
]
},
"numbers": [
"+12223334444"
],
"krisp_enabled": false
}
}
Notes on fields and values
• `outbound.address`: SIP server address provided by your SIP provider.
• `outbound.port`: SIP port (commonly 5060 for UDP).
• `outbound.transport`: udp to match your provider’s transport protocol.
• `allowed_auth_identity`: left empty for IP‑based auth (no username).
• `allowed_addresses`: provider public IP(s) — this is the IP‑based authentication (whitelist).
• `codecs`: use `PCMU`/`PCMA` for G.711 (μ-law / A-law) and G729 for G.729.
• `numbers`: optional list of DID numbers to assign to the trunk.
• `krisp_enabled`: optional boolean; include if you want noise suppression disabled/enabled.
Validation & testing tips
• Confirm the provider will send traffic from the public IPs you list in allowed_addresses.
• After creation, place a test call and inspect the SDP to ensure the negotiated codec is one of the specified codecs.
• Ensure any firewalls/NAT allow SIP (UDP 5060/other port) and RTP media ports to/from LiveKit and the provider.
If you want, I can:
• Adapt this JSON for an inbound trunk instead.
• Provide the exact lk CLI command syntax if your lk CLI version uses a different path/flags.
• Convert the payload into a Node.js SDK request if you prefer using code instead of the CLI. Which would you like next? Sources: Making calls overview | LiveKit Documentation