API Reference
Base URL: https://api.getpaygentic.org/v1. All requests use bearer token authentication and return JSON.
Authentication
Pass your API key as a bearer token in the Authorization header on every request:
Authorization: Bearer pyg_live_xxxxxxxxxxxxxxxxxxxxxx
Endpoints overview
| Method | Path | Description | Auth required | Rate limit |
|---|---|---|---|---|
POST |
/events |
Ingest one or more usage events | Yes | 1,000 events/s |
GET |
/events |
Query ingested events with filters | Yes | 60 req/min |
POST |
/customers |
Create or upsert a customer record | Yes | 120 req/min |
GET |
/customers/:id |
Retrieve a customer by ID | Yes | 120 req/min |
GET |
/customers/:id/usage |
Get aggregated usage for a customer | Yes | 60 req/min |
POST |
/meters |
Create a new meter definition | Yes | 30 req/min |
GET |
/meters |
List all meter definitions | Yes | 60 req/min |
GET |
/billing-periods |
List billing periods for a customer | Yes | 60 req/min |
POST /events
Ingests one or more events. Accepts up to 500 events per request. Events with duplicate idempotency keys are accepted but not double-counted.
Request body
{
"events": [
{
"idempotency_key": "string", // required, unique per event
"customer_id": "string", // required
"event_type": "string", // required, your event type name
"timestamp": "ISO 8601", // required, UTC
"trace_id": "string", // optional, for multi-agent attribution
"properties": {} // optional key-value pairs
}
]
}
Response
{
"ingested": 1,
"deduplicated": 0,
"failed": 0
}
Example
curl -X POST https://api.getpaygentic.org/v1/events \
-H "Authorization: Bearer pyg_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"idempotency_key": "agent-run-abc-001",
"customer_id": "cust_9f3k2m",
"event_type": "model_call",
"timestamp": "2026-10-15T14:22:00Z",
"properties": {
"model": "claude-3-5-sonnet",
"input_tokens": 1240,
"output_tokens": 320
}
}
]
}'
POST /customers
Creates a customer if no record exists with the given id, or updates the existing record if one does. This is an upsert operation.
Request body
{
"id": "string", // required, your internal customer ID
"name": "string", // optional
"email": "string", // optional
"metadata": {} // optional key-value pairs
}
GET /customers/:id/usage
Returns aggregated usage totals for each meter for the specified customer. By default returns the current billing period. Use the period_start and period_end query parameters to query a historical period.
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
period_start |
ISO 8601 | No | Start of the query window (UTC) |
period_end |
ISO 8601 | No | End of the query window (UTC) |
meter_id |
string | No | Filter to a single meter |
Response
{
"customer_id": "cust_9f3k2m",
"period_start": "2026-10-01T00:00:00Z",
"period_end": "2026-11-01T00:00:00Z",
"meters": [
{
"meter_id": "mtr_tokens",
"display_name": "Token usage",
"value": 4820000,
"unit": "tokens"
}
]
}
Error codes
| HTTP status | Code | Meaning | Action |
|---|---|---|---|
| 400 | invalid_event |
Event is missing a required field or has an invalid value | Fix the event payload |
| 401 | unauthorized |
API key is missing or invalid | Check key in dashboard |
| 429 | rate_limited |
Request exceeds the rate limit for this endpoint | Retry with exponential backoff |
| 500 | internal_error |
Unexpected server-side error | Retry; contact support if persistent |
Idempotency
The idempotency_key field on each event is how Paygentic prevents double-counting when agents retry on transient errors. A key is scoped to your account and retained for 72 hours. Sending the same key a second time within that window returns a success response but the event is not ingested again.
For keys that need a longer deduplication window (for example, reprocessing historical data), use the X-Idempotency-Window header to specify a window in seconds (maximum 604800, or seven days).