Skip to main content

Get Current Project Usage

Use this endpoint to retrieve the current billing-cycle usage (in bytes) for a specific TURN Server 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/current_usage

<appname> - Replace with the name of your app.
:projectId - The unique ID of the project whose usage you want to retrieve.


Request

GET /api/v2/turn/project/:projectId/current_usage

Path Parameter

ParameterDescriptionData Type
projectIdThe unique ID of the project (must be a valid ObjectId)String

Query Parameters (Authentication)

ParameterDescriptionData Type
secretKeyYour application's secret key, found in Dashboard → Developers → Secret Key. Only one of secretKey or projectApiKey is required.String
projectApiKeyThe API key for the specific project. Only one of secretKey or projectApiKey is required.String

Responses

Success Response

A JSON object with the following fields:

FieldDescriptionData Type
quotaInBytesThe configured quota for this project in bytes (0 if no quota is enforced).Number
usageInBytesThe usage so far in the current billing cycle (in bytes).Number
overageInBytesThe amount by which usage exceeds the quota (in bytes). 0 if usage is below quota.Number

HTTP Status: 200 OK

Example Success Response
{
"quotaInBytes": 1073741824,
"usageInBytes": 4527712,
"overageInBytes": 0
}

Error Responses

HTTP StatusMessageDescription
400Invalid request. Not subscribed to any turn server planThe application is not subscribed to a TURN server plan.
400Project not foundThe specified project does not exist or does not match the provided secretKey or projectApiKey.
500Internal error occurred, contact support and provide the event id: <eventId>An unexpected server error occurred.

Code Examples

cURL

curl -X GET "https://<appname>.metered.live/api/v2/turn/project/63fdb9f998c1abec0bd3e16c/current_usage?secretKey=<YOUR_SECRET_KEY>"

JavaScript (Fetch)

fetch(`https://<appname>.metered.live/api/v2/turn/project/63fdb9f998c1abec0bd3e16c/current_usage?projectApiKey=<PROJECT_API_KEY>`)
.then(response => response.json())
.then(data => {
console.log("Quota in Bytes:", data.quotaInBytes);
console.log("Usage in Bytes:", data.usageInBytes);
console.log("Overage in Bytes:", data.overageInBytes);
})
.catch(error => console.error("Error:", error));