Skip to main content
GET
/
usage
Get usage data
curl --request GET \
  --url https://app.phonely.ai/api/usage \
  --header 'X-Authorization: <api-key>'
import requests

url = "https://app.phonely.ai/api/usage"

headers = {"X-Authorization": "<api-key>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {'X-Authorization': '<api-key>'}};

fetch('https://app.phonely.ai/api/usage', 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://app.phonely.ai/api/usage",
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-Authorization: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://app.phonely.ai/api/usage"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("X-Authorization", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://app.phonely.ai/api/usage")
.header("X-Authorization", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://app.phonely.ai/api/usage")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["X-Authorization"] = '<api-key>'

response = http.request(request)
puts response.read_body
{
  "summary": {
    "totalCallCount": 123,
    "totalCallMinutes": 123,
    "agentCount": 123,
    "orgCount": 123
  },
  "agents": [
    {
      "agentId": "<string>",
      "agentName": "<string>",
      "callCount": 123,
      "callMinutes": 123,
      "orgId": "<string>",
      "orgName": "<string>"
    }
  ],
  "dateRange": {
    "startDate": "2023-12-25",
    "endDate": "2023-12-25"
  },
  "requestedAgentId": "<string>"
}
{
"error": "<string>",
"message": "<string>"
}
{
"error": "<string>",
"message": "<string>"
}
{
"error": "<string>",
"message": "<string>"
}
{
"error": "<string>",
"message": "<string>"
}
Retrieves usage statistics for agents within a specified date range.

Request

Method: GET
Endpoint: /api/usage
Headers:
  • X-Authorization: Your API key (required)
Query Parameters:
  • uid (string, required): Your user ID
  • startDate (string, required): Start date in YYYY-MM-DD format
  • endDate (string, required): End date in YYYY-MM-DD format
  • agentId (string, optional): Specific agent ID to get usage for (if not provided, returns usage for all accessible agents)

Response

Success Response (200):
{
  "summary": {
    "totalCallCount": number,
    "totalCallMinutes": number,
    "agentCount": number,
    "orgCount": number
  },
  "agents": [
    {
      "agentId": "string",
      "agentName": "string",
      "callCount": number,
      "callMinutes": number,
      "orgId": "string",
      "orgName": "string"
    }
  ],
  "dateRange": {
    "startDate": "string",
    "endDate": "string"
  },
  "requestedAgentId": "string"
}
Error Responses:
  • 400 Bad Request: Missing required parameters, invalid date format, or invalid date range
  • 401 Unauthorized: Invalid or missing API key
  • 404 Not Found: User not found or agent not found/access denied
  • 500 Internal Server Error: Server error

Example

curl -X GET "https://app.phonely.ai/api/usage?uid=user123&startDate=2024-01-01&endDate=2024-01-31" \
  -H "X-Authorization: your-api-key"

Notes

  • Date range cannot exceed reasonable limits
  • If no agents are found for the user, returns empty arrays with zero counts
  • The requestedAgentId field is only included when filtering for a specific agent

Authorizations

X-Authorization
string
header
required

Query Parameters

uid
string
required

User ID

startDate
string<date>
required

Start date in YYYY-MM-DD format

Pattern: ^\d{4}-\d{2}-\d{2}$
endDate
string<date>
required

End date in YYYY-MM-DD format

Pattern: ^\d{4}-\d{2}-\d{2}$
agentId
string

Optional agent ID to filter data for specific agent

Response

Successful response

summary
object
required

Summary statistics for the usage data

agents
object[]
required

Usage data for each agent

dateRange
object
required

Date range for the usage data

requestedAgentId
string | null

Agent ID that was specifically requested (only present when agentId parameter was provided)

Last modified on July 11, 2026