Skip to main content

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

ParameterDescriptionData Type
projectIdThe unique ID of the projectString

Query Parameters (Authentication)

ParameterDescriptionData Type
secretKeyThe secret key for your application. Found in Dashboard → Developers → Secret Key.String
projectApiKeyThe API key for an individual project (retrieved when the project was created).String

Note: You only need to provide one of secretKey or projectApiKey.

Other Query Parameters

ParameterDescriptionData Type
pagePage number for pagination (default 1). There are 50 records per page.Number
allIf set, retrieves all credentials (including expired). If not set, only returns credentials that are not expired.Any (presence check)
labelFilter 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:

FieldDescriptionData Type
dataAn array of credential objects.Array
paginationMetadata about pagination (total records, current page, total pages, next/prev pages).Object

Each credential object in data has:

FieldDescriptionData Type
_idUnique identifier for the credential.String
projectThe project ID to which this credential belongs.String
usernameThe TURN username.String
passwordThe TURN password.String
apiKeyThe API Key used when creating this credential.String
manuallyDisabledIndicates if the credential was explicitly disabled by the user.Boolean
disabledByProjectRuleIndicates 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 StatusMessageDescription
400Invalid projectIdThe projectId is not a valid MongoDB ObjectId.
400Project not foundNo project matching the given credentials (secretKey or projectApiKey) was found.
400Invalid request. Not subscribed to any turn server planThe 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));