Usage Analytics
The Usage API provides analytics for credit consumption, users, assets, and phone activity.
Run Count Semantics
Where a response includes run_count, it represents distinct customer requests, not the number of underlying model or tool operations. One chat turn, workflow run, app run, agent run, or supported API request counts as one run even when several operations are needed to complete it.
Run count measures request volume. Credit totals measure the AI and tool work used to complete those requests, so requests with the same run_count can have different credit totals. Rows from older periods may report run_count: 0 when the source events did not include a run identifier.
Base Endpoint Group
All usage endpoints live under:
/v1/usage/*
Common Query Parameters
Many endpoints share these optional filters:
tenant_ids: one or more tenant IDs. Repeat the parameter for each tenant:tenant_ids=tenant_abc123&tenant_ids=tenant_def456. A comma-separated list is rejected with400.preset:7d,30d,90d,billing_period, orcustomstart,end: a custom datetime range. Send both instead ofpreset;preset=customis optional. Sending a preset other thancustomtogether withstartorendreturns400.
Endpoints
Daily Usage
GET /v1/usage/daily
Returns daily usage buckets.
Hourly Usage
GET /v1/usage/hourly
Returns hourly usage buckets.
Usage by Source
GET /v1/usage/source
Returns usage grouped by source.
High-Level Summary
GET /v1/usage/high-level
Returns high-level usage summary metrics.
Heatmap
GET /v1/usage/heatmap
Returns average usage in a day/hour heatmap.
Additional query parameter:
timezone(optional, defaultUTC)
Users Summary
GET /v1/usage/users/summary
Returns user-level usage summary rows.
Additional query parameters:
limit,offsetsort_dir:ascordesc
Users List
GET /v1/usage/users
Returns one row per user who used credits in the window, ranked by credits. Each row includes the user's role, share of credits, activity count, top model, main use (mostly_used_for) and busiest day. See Per-User Usage for access, IDs and time zones.
Additional query parameters:
limit: 1–100 (default15)offset: rows to skip (default0). An offset past the end returns an emptyrowsarray.sort:credits(default),name,client,role,status,share,activity_count,top_model,mostly_used_for,busiest_day, orlast_activesort_dir:ascordesc(defaultdesc)search: case-insensitive match on the user's name or email, or the tenant name (up to 200 characters)day: a local date (YYYY-MM-DD). Credits, share and activity count cover only that day;top_model,mostly_used_for,busiest_dayandlast_activestill cover the whole window.kinds:personorunattributed. Repeat to send both.unattributedrows hold usage that is not tied to a person and haveuser_id: null.
total_count is the number of rows after search and kinds and before paging. total_credits and max_credits are the sum and the largest per-user total in the window, before search and kinds are applied. With day, they cover only that day.
User Usage Detail
GET /v1/usage/users/{user_id}
Returns one user's usage for the window:
tiles: totals, share, active days and busiest dayseries: one entry per daymodelsandsources: credits by model and by sourcetop_assets: the apps, workflows and agents they used most
client_total is the credits of everyone in this user's tenant (identity.entity_id), so tiles.share is this user's share of their own tenant's usage, even when you select several tenants or none.
Accepts tenant_ids, preset, start and end.
User Usage for a Day
GET /v1/usage/users/{user_id}/day
Returns every usage row for one user on one local date, plus the previous and next days in the window on which they were active.
Required query parameter:
date: the local date,YYYY-MM-DD
At most the newest 5,000 rows are returned. rows_truncated is true when the day has more; total_rows and total_credits always cover the whole day. via_api_key marks rows that came from an API key. preset, start and end set the range searched for prev_active_day and next_active_day.
Usage Insights
GET /v1/usage/users/insights
Returns up to three plain-language observations, each with an optional link to the day it refers to. Sentences come from fixed rules (source: "rules"), not a language model.
Required query parameter:
surface:list(the users list),user(needsuser_id), orday(needsuser_idanddate)
Also accepts tenant_ids, preset, start and end.
Users Creations
GET /v1/usage/users/creations
Returns user creation counts for apps/workflows.
Additional query parameters:
app_type:apporworkflowlimit,offsetsort_dir:ascordesc
Models Summary
GET /v1/usage/models
Returns usage grouped by model.
Additional query parameters:
limit,offsetsort_dir:ascordesc
Top Assets
GET /v1/usage/assets
Returns most-used assets.
Additional query parameters:
asset_type:app,workflow,agent, oralllimit,offsetsort_dir:ascordesc
Phone Metrics
GET /v1/usage/phone/metrics
Returns aggregate phone usage metrics.
Phone Series
GET /v1/usage/phone/series
Returns phone call series rows.
Earliest Usage Timestamp
GET /v1/usage/earliest
Returns earliest usage timestamp for selected tenants.
Credit Limit / Usage
GET /v1/usage/limit
Returns total credit limit and total credits used.
Per-Entity Usage State
GET /v1/usage/state
Returns per-entity credit position for the current billing month: credits used, aggregate credit limit, percent used, period bounds, and over-limit flag.
Usage Breakdown
GET /v1/usage/breakdown
Returns usage rows grouped by a single dimension.
Required query parameters:
entity_id: a single tenant IDfrom,to: ISO-8601 datetimesgroup_by:user,feature,model, orday
Optional query parameters:
limit,offset(apply touserandmodelgroup_by)sort_dir:ascordesc
MSP Admin: Tenants
GET /v1/admin/usage/tenants
MSP-admin only. Returns per-tenant credit position for every child of the caller's own MSP.
Query parameters (all optional):
sort_by:pct_used(default),credits_used, ornamesort_dir:ascordesclimit,offset(cap 100)
MSP Admin: At-Risk Tenants
GET /v1/admin/usage/at-risk
MSP-admin only. Returns the subset of the caller's own MSP's tenants whose percent_used >= threshold_pct, sorted descending by percent_used, paginated.
Query parameters (all optional):
threshold_pct: 0.0–1.0 (default0.8)limit: 0–100 (default20)offset: ≥ 0 (default0)
The response includes total_count (the size of the at-risk set before paging), limit, and offset.
Per-User Usage
These rules apply to Users List, User Usage Detail, User Usage for a Day and Usage Insights.
Who can call them. The API key's user must be able to view usage:
| Caller | Result |
|---|---|
| MSP user who can view user roles (for example Admin or Helpdesk) | Usage for the tenants your MSP manages. If your MSP restricts users to their account teams, only the tenants assigned to them: the default results cover only those tenants, and naming another tenant returns 403. |
| Tenant admin | Usage for their own company only |
| Other users | 403 |
- Naming a tenant you can't see in
tenant_idsreturns403. - On User Usage Detail, User Usage for a Day and Usage Insights, a user outside the tenants you can see, or an unknown user, returns
404with"User not found". - So does a user in those tenants who has never used credits there: these three endpoints treat a user with no usage at any time in the tenants the request covers as not found. Users List never returns this
404; a user with no matching usage is simply absent fromrows.
IDs. user_id is the user's UUID, as returned in rows[].user_id by Users List. User HashIDs (user_..., as returned by the admin endpoints) are not accepted: the path endpoints return a plain 404 Not Found, and Usage Insights returns 422. entity_id in these responses is the tenant's UUID. tenant_ids accepts tenant HashIDs or UUIDs.
Time window. Use preset, or start and end together, at most 400 days apart.
- Always include a timezone offset in
startandend, for example2026-11-01T00:00:00Z. Users List rejects a value without one; the other endpoints read it in server time. - Sending only one of them, or a window longer than 400 days, returns
422. - Without either, the current billing period is used.
window_startandwindow_endin the Users List response, when present, show the window that was applied.
Time zone. Days and dates follow the time zone in the caller's Hatz profile, returned as timezone. The default is America/New_York.
Freshness. Results for a window that includes today are cached for about 15 minutes. Results for a window that ended before today are cached for up to 24 hours.
Example Request
curl 'https://ai.hatz.ai/v1/usage/high-level?tenant_ids=tenant_abc123&preset=30d' \
-H 'X-API-Key: $HATZ_API_KEY'
Example Responses
High-Level Summary Response
{
"active_users": 42,
"total_apps_built": 18,
"total_workflows_built": 33,
"total_workflows_ran": 945,
"total_apps_ran": 512,
"total_agent_chats": 1402,
"chat_engagements": 1276,
"total_api_calls": 9834
}
Daily Usage Response
{
"days": [
{
"day": "2026-02-14",
"input_credits": 212.34,
"output_credits": 189.78,
"total_credits": 402.12
},
{
"day": "2026-02-15",
"input_credits": 230.45,
"output_credits": 208.32,
"total_credits": 438.77
}
]
}
Users Summary Response
{
"users": [
{
"user_id": "9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc",
"email": "owner@acme.com",
"first_name": "Alex",
"last_name": "Owner",
"input_credits": 421.09,
"output_credits": 421.10,
"total_credits": 842.19,
"run_count": 127
}
],
"count": 1,
"limit": 5,
"offset": 0
}
Users List Response
GET /v1/usage/users?tenant_ids=tenant_abc123&preset=7d&limit=1
{
"rows": [
{
"rank": 1,
"user_id": "9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc",
"kind": "person",
"name": "Alex Owner",
"email": "owner@acme.com",
"entity_id": "dd000001-0001-4001-a001-000000000001",
"entity_name": "Acme",
"role": "General User",
"input_credits": 40.0,
"output_credits": 95.0,
"total_credits": 135.0,
"share": 0.944,
"activity_count": 3,
"top_model_id": "028a0bc8-a160-466e-ab5f-e1541ea04f90",
"top_model": "Amazon Nova 2 Lite",
"mostly_used_for": "chat",
"busiest_day": "2026-11-04",
"busiest_day_credits": 70.0,
"last_active": "2026-11-05T01:10:30.289683Z"
}
],
"total_count": 2,
"max_credits": 135.0,
"total_credits": 143.0,
"busiest_day": {
"date": "2026-11-04",
"credits": 70.0
},
"window_start": "2026-10-30T01:00:00Z",
"window_end": "2026-11-06T01:00:00Z",
"limit": 1,
"offset": 0,
"timezone": "America/New_York"
}
User Usage Detail Response
series is shortened here; it has one entry per day in the window.
{
"identity": {
"user_id": "9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc",
"kind": "person",
"name": "Alex Owner",
"email": "owner@acme.com",
"role": "General User",
"entity_id": "dd000001-0001-4001-a001-000000000001",
"entity_name": "Acme",
"last_active": "2026-11-05T01:10:30.289683Z"
},
"range": {
"first_day": "2026-10-29",
"last_day": "2026-11-05"
},
"client_total": 143.0,
"tiles": {
"total_credits": 135.0,
"input_credits": 40.0,
"output_credits": 95.0,
"activity_count": 3,
"share": 0.944,
"active_days": 2,
"days_in_range": 8,
"most_active_isodow": 3,
"top_model": {
"model_id": "028a0bc8-a160-466e-ab5f-e1541ea04f90",
"name": "Amazon Nova 2 Lite",
"credits": 135.0,
"share": 1.0
},
"busiest_day": {
"date": "2026-11-04",
"credits": 70.0,
"share": 0.519
}
},
"series": [
{ "date": "2026-11-02", "credits": 65.0, "activity_count": 1 },
{ "date": "2026-11-03", "credits": 0.0, "activity_count": 0 },
{ "date": "2026-11-04", "credits": 70.0, "activity_count": 2 }
],
"models": [
{
"model_id": "028a0bc8-a160-466e-ab5f-e1541ea04f90",
"name": "Amazon Nova 2 Lite",
"credits": 135.0,
"share": 1.0,
"activity_count": 3
}
],
"sources": [
{ "key": "chat", "credits": 70.0, "share": 0.519, "activity_count": 2 },
{ "key": "api", "credits": 65.0, "share": 0.481, "activity_count": 1 }
],
"top_assets": [],
"timezone": "America/New_York"
}
most_active_isodow is the ISO weekday (1 = Monday, 7 = Sunday).
User Usage for a Day Response
GET /v1/usage/users/9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc/day?date=2026-11-04&preset=7d
{
"identity": {
"user_id": "9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc",
"kind": "person",
"name": "Alex Owner",
"email": "owner@acme.com",
"role": "General User",
"entity_id": "dd000001-0001-4001-a001-000000000001",
"entity_name": "Acme",
"last_active": "2026-11-05T01:10:30.289683Z"
},
"date": "2026-11-04",
"day_start": "2026-11-04T05:00:00Z",
"day_end": "2026-11-05T05:00:00Z",
"range": {
"first_day": "2026-10-29",
"last_day": "2026-11-05"
},
"prev_active_day": "2026-11-02",
"next_active_day": null,
"total_credits": 70.0,
"total_rows": 2,
"rows_truncated": false,
"rows": [
{
"id": "d412b134-1460-4eb4-9f18-eb197dac6a35",
"created_at": "2026-11-05T01:10:30.289683Z",
"source": "chat",
"source_group": "chat",
"model_id": "028a0bc8-a160-466e-ab5f-e1541ea04f90",
"model_name": "Amazon Nova 2 Lite",
"chat_id": null,
"agent_id": null,
"agent_name": null,
"app_id": null,
"app_name": null,
"app_type": null,
"via_api_key": false,
"input_credits": 12.0,
"output_credits": 30.0,
"credits": 42.0
},
{
"id": "6bac6465-d0c8-4917-bc1a-aad517cbaccb",
"created_at": "2026-11-04T23:10:30.289683Z",
"source": "chat",
"source_group": "chat",
"model_id": "028a0bc8-a160-466e-ab5f-e1541ea04f90",
"model_name": "Amazon Nova 2 Lite",
"chat_id": null,
"agent_id": null,
"agent_name": null,
"app_id": null,
"app_name": null,
"app_type": null,
"via_api_key": false,
"input_credits": 8.0,
"output_credits": 20.0,
"credits": 28.0
}
],
"timezone": "America/New_York"
}
source_group is one of chat, agent, workflow, app, api, phone, or other.
Usage Insights Response
GET /v1/usage/users/insights?surface=user&user_id=9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc&preset=7d
{
"surface": "user",
"sentences": [
{
"text": "52% of Acme's credits went to Chat.",
"link": null
},
{
"text": "Nov 4 was the busiest day, with 52% of their credits.",
"link": {
"kind": "day",
"user_id": "9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc",
"date": "2026-11-04",
"entity_id": "dd000001-0001-4001-a001-000000000001"
}
}
],
"source": "rules",
"generated_at": "2026-11-06T01:11:03.695066Z",
"insight_hash": "0687d3a9560aa639"
}
Phone Metrics Response
{
"total_calls": 268,
"total_minutes": 824.6,
"avg_minutes": 3.08
}
Credit Limit / Usage Response
{
"total_credit_limit": 50000,
"total_credits_used": 13254.22
}
Per-Entity Usage State Response
{
"entities": [
{
"entity_id": "tenant_abc123",
"credits_used": 13254.22,
"credit_limit": 50000,
"percent_used": 0.265,
"period_start": "2026-05-01T00:00:00+00:00",
"period_end": "2026-06-01T00:00:00+00:00",
"is_over_limit": false,
"free_pool_remaining": null
}
]
}
Usage Breakdown Response
{
"entity_id": "tenant_abc123",
"from": "2026-05-01T00:00:00+00:00",
"to": "2026-05-15T00:00:00+00:00",
"group_by": "user",
"rows": [
{
"key": "9ff1b8ff-7f6d-42b4-a8f7-5f3eb459e8dc",
"display_name": "Alex Owner",
"input": 421.09,
"output": 421.10,
"total": 842.19,
"run_count": 127
}
]
}
MSP Admin Tenants Response
{
"tenants": [
{
"entity_id": "tenant_abc123",
"name": "Acme",
"credits_used": 12876.5,
"credit_limit": 15000,
"percent_used": 0.858,
"period_start": "2026-05-01T00:00:00+00:00",
"period_end": "2026-06-01T00:00:00+00:00",
"is_over_limit": false
}
],
"total_count": 14,
"limit": 20,
"offset": 0
}
MSP Admin At-Risk Tenants Response
{
"threshold_pct": 0.8,
"entities": [
{
"entity_id": "tenant_xyz789",
"name": "Beta Corp",
"credits_used": 9200.0,
"credit_limit": 10000,
"percent_used": 0.92,
"period_start": "2026-05-01T00:00:00+00:00",
"period_end": "2026-06-01T00:00:00+00:00",
"is_over_limit": false
},
{
"entity_id": "tenant_abc123",
"name": "Acme",
"credits_used": 12876.5,
"credit_limit": 15000,
"percent_used": 0.858,
"period_start": "2026-05-01T00:00:00+00:00",
"period_end": "2026-06-01T00:00:00+00:00",
"is_over_limit": false
}
],
"total_count": 2,
"limit": 20,
"offset": 0
}