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
Parameter | Description | Data Type |
---|---|---|
projectId | The unique ID of the project (must be a valid ObjectId) | String |
Query Parameters (Authentication)
Parameter | Description | Data Type |
---|---|---|
secretKey | Your application's secret key, found in Dashboard → Developers → Secret Key. Only one of secretKey or projectApiKey is required. | String |
projectApiKey | The 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:
Field | Description | Data Type |
---|---|---|
quotaInBytes | The configured quota for this project in bytes (0 if no quota is enforced). | Number |
usageInBytes | The usage so far in the current billing cycle (in bytes). | Number |
overageInBytes | The 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 Status | Message | Description |
---|---|---|
400 | Invalid request. Not subscribed to any turn server plan | The application is not subscribed to a TURN server plan. |
400 | Project not found | The specified project does not exist or does not match the provided secretKey or projectApiKey . |
500 | Internal 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));