Skip to main content

Request ICE Credentials

POST /credentials/ice​

Request ICE credentials for your project to establish peer-to-peer WebRTC connections via Turnix's global TURN infrastructure.

πŸ” Simple Request Example​

curl -X POST \
https://turnix.io/api/v1/credentials/ice \
-H 'Authorization: Bearer YOUR_API_BEARER_TOKEN' \
-H 'Content-Type: application/json'
Response
{
"iceServers": [
{
"urls": [
"stun:stun.turnix.io:3478"
]
},
{
"username": "35bb4eb4-b518-4059-9399-272efdefc5d9",
"credential": "7ea616da55d417f4aaf6427016140416",
"urls": [
"turn:some-region.tunix.io:3478?transport=udp",
"turn:some-region.tunix.io:3478?transport=tcp"
]
}
]
}

πŸ“ Parameters​

ParameterTypeDescription
initiator_clientOptionalIdentifier for the initiating client.
receiver_clientOptionalIdentifier for the receiving client.
roomOptionalRoom/session name used for grouping connections.
ttlOptionalTime-to-live in seconds for credentials. Default: 30 seconds.
fixed_regionOptionalForce allocation in a specific region. Fails if the region is unavailable.
preferred_regionOptionalPreferred region for TURN relay. Falls back to nearest available region if unavailable.

🧾 Headers​

HeaderTypeDescription
AuthorizationRequiredBearer YOUR_API_TOKEN β€” used to authenticate the request.
X-TURN-CLIENT-IPOptionalIP address of the client (used for geo-based region routing).

🌍 GeoIP-Based Region Selection​

Turnix automatically selects the nearest TURN server using GeoIP, based on the client’s IP address. If your server is making the request on behalf of the client (which is recommended to avoid exposing API tokens), you can forward the client’s IP manually.

➀ Region Selection​

Use region parameters to influence TURN server location:

curl -X POST \
https://turnix.io/api/v1/credentials/ice \
-H 'Authorization: Bearer YOUR_API_BEARER_TOKEN' \
-d 'preffered_region=eu-central'
curl -X POST \
https://turnix.io/api/v1/credentials/ice \
-H 'Authorization: Bearer YOUR_API_BEARER_TOKEN' \
-d 'fixed_region=eu-central'
Response
{
"iceServers": [
{
"urls": [
"stun:stun.turnix.io:3478"
]
},
{
"username": "35bb4eb4-b518-4059-9399-272efdefc5d9",
"credential": "7ea616da55d417f4aaf6427016140416",
"urls": [
"turn:some-region.tunix.io:3478?transport=udp",
"turn:some-region.tunix.io:3478?transport=tcp"
]
}
]
}

➀ Forwarding Client IP​

Forward the original client’s IP address in the X-TURN-CLIENT-IP header:

curl -X POST \
https://turnix.io/api/v1/credentials/ice \
-H 'Authorization: Bearer YOUR_API_BEARER_TOKEN' \
-H 'X-TURN-CLIENT-IP: 12.34.56.78' \
Response
{
"iceServers": [
{
"urls": [
"stun:stun.turnix.io:3478"
]
},
{
"username": "35bb4eb4-b518-4059-9399-272efdefc5d9",
"credential": "7ea616da55d417f4aaf6427016140416",
"urls": [
"turn:some-region.tunix.io:3478?transport=udp",
"turn:some-region.tunix.io:3478?transport=tcp"
]
}
]
}

πŸ‘₯ Clients and Room Context​

Specifying initiator_client, receiver_client, and room improves observability and lets you trace interactions in the Turnix Console.

  • Initiator Client: the endpoint initiating the WebRTC connection
  • Receiver Client: the endpoint that receives the connection
  • Room: an optional grouping for multiple clients (useful for multiparty or tracking)

This metadata is visible in the Turnix Console and can be linked back to your system.

curl -X POST \
https://turnix.io/api/v1/credentials/ice \
-H 'Authorization: Bearer YOUR_API_BEARER_TOKEN' \
-d 'initiator_client=OPTIONAL_INITIATOR_CLIENT_VALUE' \
-d 'receiver_client=OPTIONAL_RECEIVER_CLIENT_VALUE' \
-d 'room=OPTIONAL_ROOM_NAME_VALUE'
Response
{
"iceServers": [
{
"urls": [
"stun:stun.turnix.io:3478"
]
},
{
"username": "35bb4eb4-b518-4059-9399-272efdefc5d9",
"credential": "7ea616da55d417f4aaf6427016140416",
"urls": [
"turn:some-region.tunix.io:3478?transport=udp",
"turn:some-region.tunix.io:3478?transport=tcp"
]
}
]
}