import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.metrics.get();
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.get_metrics()
print(result)curl 'https://api.mails.ai/v1/metrics' \
-H "Authorization: Bearer $MAILS_API_KEY"mails metrics --from 2026-10-01 --to 2026-10-08 \
--interval day{ "name": "mails_metrics_get", "arguments": {} }{
"interval": "day",
"from": "2026-10-04T12:00:00.000Z",
"to": "2026-10-04T12:00:00.000Z",
"agent_id": "agt_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"test_mode": false,
"data": [
{
"start": "2026-10-04T12:00:00.000Z",
"sent": 0,
"delivered": 0,
"bounced": 0,
"complained": 0,
"received": 0,
"replies": 0
}
],
"totals": {
"sent": 0,
"delivered": 0,
"bounced": 0,
"complained": 0,
"received": 0,
"replies": 0
}
}200 Buckets for the range, oldest first.
400 Invalid request — malformed JSON or a field failed
validation. Also feature_not_enabled when this
server has a feature switched off (custom domains
before they are available).
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
404 Resource not found in this workspace, or the agent
a send names is archived (agent_archived).
409 Conflict — duplicate resource, an in-progress
idempotent request, a draft or scheduled message
that started sending while it was being changed, or
a thread deleted for good while one of its messages
is being sent (duplicate_resource); or an agent
name more than one agent has (agent_name_conflict:
use the agent's id); or a status change on an
archived agent, since archiving cannot be undone
(agent_archived).
500 Internal server error.Mail metrics
import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.metrics.get();
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.get_metrics()
print(result)curl 'https://api.mails.ai/v1/metrics' \
-H "Authorization: Bearer $MAILS_API_KEY"mails metrics --from 2026-10-01 --to 2026-10-08 \
--interval day{ "name": "mails_metrics_get", "arguments": {} }{
"interval": "day",
"from": "2026-10-04T12:00:00.000Z",
"to": "2026-10-04T12:00:00.000Z",
"agent_id": "agt_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"test_mode": false,
"data": [
{
"start": "2026-10-04T12:00:00.000Z",
"sent": 0,
"delivered": 0,
"bounced": 0,
"complained": 0,
"received": 0,
"replies": 0
}
],
"totals": {
"sent": 0,
"delivered": 0,
"bounced": 0,
"complained": 0,
"received": 0,
"replies": 0
}
}200 Buckets for the range, oldest first.
400 Invalid request — malformed JSON or a field failed
validation. Also feature_not_enabled when this
server has a feature switched off (custom domains
before they are available).
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
404 Resource not found in this workspace, or the agent
a send names is archived (agent_archived).
409 Conflict — duplicate resource, an in-progress
idempotent request, a draft or scheduled message
that started sending while it was being changed, or
a thread deleted for good while one of its messages
is being sent (duplicate_resource); or an agent
name more than one agent has (agent_name_conflict:
use the agent's id); or a status change on an
archived agent, since archiving cannot be undone
(agent_archived).
500 Internal server error.Query Parameters
Start of the range (ISO 8601, or YYYY-MM-DD).
End of the range, exclusive (ISO 8601, or YYYY-MM-DD).
Filter by agent id or name. A key tied to one agent always reads that agent's mail, and naming another agent is a 403.
Bucket size.
Defaults to the last 30 days by day, or the last 48 hours by hour; at most 366 days or 744 hours per call. A test key counts test mail only and a live key live mail only.
Response
Bucket size, in UTC: day or hour, as requested; day when the request names none.
Start of the range, inclusive: the requested from moved back to the start of its UTC day or hour. Left out, 30 days before to by day or 48 hours by hour, rounded the same way.
End of the range, exclusive, as requested and not rounded, so the last bucket can be partial. Left out, the time of the request.
The agent the counts are limited to, as its id even when the request gave its name. Absent when they cover every agent; a key tied to one agent always gets its own.
A test key counts test mail only; a live key, live mail only.
Every bucket in the range, oldest first, zeros included.
Each count summed over every bucket in the range.
Was this page helpful?