Skip to main content
GET
/
usage
Get usage data
curl --request GET \
  --url https://app.phonely.ai/api/usage \
  --header 'X-Authorization: <api-key>'
{
  "summary": {
    "totalCallCount": 123,
    "totalCallMinutes": 123,
    "agentCount": 123,
    "orgCount": 123
  },
  "agents": [
    {
      "agentId": "<string>",
      "agentName": "<string>",
      "orgId": "<string>",
      "orgName": "<string>",
      "callCount": 123,
      "callMinutes": 123
    }
  ],
  "dateRange": {
    "startDate": "2023-12-25",
    "endDate": "2023-12-25"
  },
  "requestedAgentId": "<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

endDate
string<date>
required

End date in YYYY-MM-DD format

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)

I