Skip to main content

Get API key statistics

GET /api/api-keys/{id}/stats

Retrieve usage statistics for a specific API key, based on audit logs, for a given timeframe

Authentication​

  • Option 1: x-api-key: YOUR_API_KEY (header). API key for authentication. Create one in your dashboard.
  • Option 2: Authorization: Bearer YOUR_ACCESS_TOKEN. Dashboard JWT in Authorization: Bearer <token>, only on operations that explicitly list this scheme. Prefer x-api-key for REST integrations. OAuth for hosted MCP is a separate connection at https://mcp.zvid.io/mcp.

Create API keys at app.zvid.io/api-keys. Keep credentials on your server.

Parameters​

ParameterLocationTypeRequiredDescription and constraints
idpathintegerYesAPI key ID
timeframequery"24h" / "7d" / "30d"NoTimeframe for statistics. Supported values: 24h, 7d, 30d (default: 30d). Default: "30d".

Request​

The shell examples read credentials from ZVID_API_KEY (or ZVID_ACCESS_TOKEN for Bearer authentication). Set that variable in your environment. Replace sample project, template, job, and asset identifiers with values from your own account.

This operation does not take a request body.

Request example​

curl --request GET 'https://api.zvid.io/api/api-keys/789/stats' \
--header "x-api-key: $ZVID_API_KEY"

Responses​

HTTP 200​

API key statistics retrieved successfully

Content type: application/json.

Unknown properties are rejected. Required properties: timeframe, summary.

FieldTypeRequiredDescription and constraints
response.timeframe"24h" / "7d" / "30d"Yes
response.summaryobjectYesAggregated statistics for the selected timeframe Unknown properties are rejected. Required properties: totalRequests, successfulRequests, failedRequests.
response.dailyStatsarray of objectNoDaily request breakdown over the last 30 days

Nested field: response.summary

Aggregated statistics for the selected timeframe

Unknown properties are rejected. Required properties: totalRequests, successfulRequests, failedRequests.

FieldTypeRequiredDescription and constraints
response.summary.totalRequestsintegerYes
response.summary.successfulRequestsintegerYes
response.summary.failedRequestsintegerYes
response.summary.avgResponseTimenumberNo

Nested field: response.dailyStats

Daily request breakdown over the last 30 days

Array item: response.dailyStats[]

Unknown properties are rejected. Required properties: date, requests, successful, failed.

FieldTypeRequiredDescription and constraints
response.dailyStats[].datestringYesFormat: date.
response.dailyStats[].requestsintegerYes
response.dailyStats[].successfulintegerYes
response.dailyStats[].failedintegerYes

Example response

{
"timeframe": "30d",
"summary": {
"totalRequests": 1500,
"successfulRequests": 1400,
"failedRequests": 100,
"avgResponseTime": 120.5
},
"dailyStats": [
{
"date": "2025-01-01",
"requests": 50,
"successful": 48,
"failed": 2
},
{
"date": "2025-01-02",
"requests": 75,
"successful": 70,
"failed": 5
}
]
}

HTTP 401​

Unauthorized

Content type: application/json.

Unknown properties are rejected. Required properties: error.

FieldTypeRequiredDescription and constraints
response.errorstringYesError type
response.messagestringNoHuman-readable error message

HTTP 500​

Internal server error

Content type: application/json.

Required properties: error.

FieldTypeRequiredDescription and constraints
response.errorstringYesError type
response.messagestringNoHuman-readable error message

Schema definitions​

The following definitions describe the fields referenced above. Expand a definition to inspect its complete contract.

ApiKeyStats

Unknown properties are rejected. Required properties: timeframe, summary.

FieldTypeRequiredDescription and constraints
ApiKeyStats.timeframe"24h" / "7d" / "30d"Yes
ApiKeyStats.summaryobjectYesAggregated statistics for the selected timeframe Unknown properties are rejected. Required properties: totalRequests, successfulRequests, failedRequests.
ApiKeyStats.dailyStatsarray of objectNoDaily request breakdown over the last 30 days

Nested field: ApiKeyStats.summary

Aggregated statistics for the selected timeframe

Unknown properties are rejected. Required properties: totalRequests, successfulRequests, failedRequests.

FieldTypeRequiredDescription and constraints
ApiKeyStats.summary.totalRequestsintegerYes
ApiKeyStats.summary.successfulRequestsintegerYes
ApiKeyStats.summary.failedRequestsintegerYes
ApiKeyStats.summary.avgResponseTimenumberNo

Nested field: ApiKeyStats.dailyStats

Daily request breakdown over the last 30 days

Array item: ApiKeyStats.dailyStats[]

Unknown properties are rejected. Required properties: date, requests, successful, failed.

FieldTypeRequiredDescription and constraints
ApiKeyStats.dailyStats[].datestringYesFormat: date.
ApiKeyStats.dailyStats[].requestsintegerYes
ApiKeyStats.dailyStats[].successfulintegerYes
ApiKeyStats.dailyStats[].failedintegerYes
AuthenticationError

Unknown properties are rejected. Required properties: error.

FieldTypeRequiredDescription and constraints
AuthenticationError.errorstringYesError type
AuthenticationError.messagestringNoHuman-readable error message
Error

Required properties: error.

FieldTypeRequiredDescription and constraints
Error.errorstringYesError type
Error.messagestringNoHuman-readable error message