Get TURN Credentials for a Project
Use this endpoint to retrieve the TURN credentials associated with a specific project.
You can authenticate by providing either the secretKey
(for your entire application) or the projectApiKey
(for a specific project).
GET
https://<appname>.metered.live/api/v2/turn/project/:projectId/credentials
<appname>
- Replace with the name of your app.
:projectId
- The unique ID of the project whose credentials you want to fetch.
Request
GET /api/v2/turn/project/:projectId/credentials
Path Parameter
Parameter | Description | Data Type |
---|---|---|
projectId | The unique ID of the project | String |
Query Parameters (Authentication)
Parameter | Description | Data Type |
---|---|---|
secretKey | The secret key for your application. Found in Dashboard → Developers → Secret Key. | String |
projectApiKey | The API key for an individual project (retrieved when the project was created). | String |
Note: You only need to provide one of
secretKey
orprojectApiKey
.
Other Query Parameters
Parameter | Description | Data Type |
---|---|---|
page | Page number for pagination (default 1 ). There are 50 records per page. | Number |
all | If set, retrieves all credentials (including expired). If not set, only returns credentials that are not expired. | Any (presence check) |
label | Filter credentials by a custom label. Only those credentials whose label matches the provided value will be returned. | String |
Example:
GET /api/v2/turn/project/:projectId/credentials?secretKey=<YOUR_SECRET_KEY>&page=2&label=special-client
Retrieves the second page of credentials labeled "special-client"
for the specified project.
Responses
Success Response
Returns a JSON object containing:
Field | Description | Data Type |
---|---|---|
data | An array of credential objects. | Array |
pagination | Metadata about pagination (total records, current page, total pages, next/prev pages). | Object |
Each credential object in data
has:
Field | Description | Data Type |
---|---|---|
_id | Unique identifier for the credential. | String |
project | The project ID to which this credential belongs. | String |
username | The TURN username. | String |
password | The TURN password. | String |
apiKey | The API Key used when creating this credential. | String |
manuallyDisabled | Indicates if the credential was explicitly disabled by the user. | Boolean |
disabledByProjectRule | Indicates if the credential was disabled automatically (e.g., quota exceeded). | Boolean |
HTTP Status: 200 OK
Example Success Response
{
"data": [
{
"_id": "67928a5879c65dbab7524880",
"project": "67927a9f79c65dbab7524787",
"username": "c7e21d0a812c0c3fdb3af925",
"password": "lrwWgwswMGQDXA1w",
"apiKey": "7fd90780bfa95adb5df34015e2810b71c30f",
"manuallyDisabled": false,
"disabledByProjectRule": false
}
],
"pagination": {
"total_records": 1,
"current_page": 1,
"total_pages": 1,
"next_page": null,
"prev_page": null
}
}
Error Responses
HTTP Status | Message | Description |
---|---|---|
400 | Invalid projectId | The projectId is not a valid MongoDB ObjectId. |
400 | Project not found | No project matching the given credentials (secretKey or projectApiKey ) was found. |
400 | Invalid request. Not subscribed to any turn server plan | The application is not subscribed to a TURN server plan. |
Code Examples
cURL
curl -X GET "https://<appname>.metered.live/api/v2/turn/project/63fdb9f998c1abec0bd3e16c/credentials?secretKey=<YOUR_SECRET_KEY>&page=1&label=special-client"
JavaScript (Fetch)
fetch(
`https://<appname>.metered.live/api/v2/turn/project/63fdb9f998c1abec0bd3e16c/credentials?projectApiKey=<PROJECT_API_KEY>&page=2`
)
.then((response) => response.json())
.then((data) => {
console.log("Credentials:", data.data);
console.log("Pagination:", data.pagination);
})
.catch((error) => console.error("Error:", error));