Get Call Counter Metrics for a Project - Cognigy Documentation
Get Call Counter Metrics for a Project
Endpoint
GET /v2.0/projects/{projectId}/callcounter
Description
Retrieve call counter metrics for a specified project using the API.
Request Example
cURL
curl --request GET \
--url https://api-trial.cognigy.ai/new/v2.0/projects/{projectId}/callcounter \
--header 'X-API-Key: <api-key>'
Python
import requests
url = "https://api-trial.cognigy.ai/new/v2.0/projects/{projectId}/callcounter"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)
JavaScript Fetch
const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api-trial.cognigy.ai/new/v2.0/projects/{projectId}/callcounter', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-trial.cognigy.ai/new/v2.0/projects/{projectId}/callcounter",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Response Codes
- 200 - Call counter stats for the given time-frame.
- 400 - Bad Request
- 401 - Unauthorized
- 402 - Payment Required
- 403 - Forbidden
- 404 - Not Found
- 500 - Internal Server Error
Success Response
{
"items": [
{
"calls": 123,
"duration": 123,
"concurrentCalls": 123,
"day": 123,
"month": 123,
"year": 123
}
]
}
Error Response Structures
Bad Request
{
"type": "Bad Request",
"title": "Bad Request Error",
"status": 400,
"detail": "Validation failed. Missing payload.",
"instance": "/v2.0/flows/5ce7c2d833ea1e04d7e6c432",
"code": 1000
}
Unauthorized
{
"type": "Unauthorized",
"title": "Unauthorized Error",
"status": 401,
"detail": "<string>",
}
... (similar error responses for other statuses) ...
Authorizations
X-API-Key
- Type: Header
- Required: Yes
- Description: Supply the API Key in the HTTP-Header.
Headers
- Accept: Specifies the media type that the client expects in the response. Options:
application/json,application/xml, etc.
Path Parameters
- projectId
- Type: String
- Required: Yes
- Description: Unique identifier for the Project. Length: 24, Pattern:
^[a-z0-9]{24}$.
Query Parameters
- year: numerical value, required.
- month: numerical value.