Channels
Updated
A channel is a case-sensitive name used to organize TURN requests, signaling peers, and statistics. Create channels in the dashboard or through the /_ns API.
Channel names are complete identifiers: use one name such as myChannel or myOtherChannel. Do not use forward slashes to create parent, application, or room segments.
Valid examples:
myChannel
myOtherChannelURL-encode the complete channel name when constructing a request. Use the same exact name for TURN, signaling tokens, and statistics when those services should share one logical channel.
Create a Channel
/_ns/{channel}PUT /_ns/{channel} creates the requested channel.
curl --request PUT \
--user "$XIRSYS_IDENT:$XIRSYS_SECRET" \
"https://global.xirsys.net/_ns/myChannel"{
"s": "ok",
"v": "myChannel"
}Each request creates one complete channel name. Do not put unvalidated user input directly into a channel URL.
List Channels
/_ns?depth=100GET /_ns?depth=100 lists the account's channels. Returned values are complete channel names, not slash-delimited hierarchy segments.
curl --user "$XIRSYS_IDENT:$XIRSYS_SECRET" \
"https://global.xirsys.net/_ns?depth=100"For example, myChannel and myOtherChannel are two separate channels.
Delete a Channel
/_ns/{channel}DELETE /_ns/{channel} removes the exact channel.
curl --request DELETE \
--user "$XIRSYS_IDENT:$XIRSYS_SECRET" \
"https://global.xirsys.net/_ns/myChannel"Destructive operation: resolve and display the exact channel name before deletion. Keep production channel administration on a trusted backend with appropriate authorization.
Node.js Example
This server-side example uses the built-in fetch available in Node.js 18 and later:
const baseUrl = 'https://global.xirsys.net';
const auth = Buffer.from(
`${process.env.XIRSYS_IDENT}:${process.env.XIRSYS_SECRET}`
).toString('base64');
async function createChannel(channel) {
const encodedChannel = encodeURIComponent(channel);
const response = await fetch(`${baseUrl}/_ns/${encodedChannel}`, {
method: 'PUT',
headers: { Authorization: `Basic ${auth}` }
});
const data = await response.json();
if (!response.ok || data.s !== 'ok') {
throw new Error(`Channel request failed (${response.status})`);
}
return data.v;
}Store credentials in a secret manager or protected environment variables. Never call this endpoint directly from browser code.