Appearance
Events & Metrics
Fresh 🌱AgentMail REST API reference for Events & Metrics. Base URL
https://api.agentmail.to/v0. Authenticate withAuthorization: Bearer <API_KEY>.
List Events
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/events
List label change events for an inbox. Returns events in reverse chronological order by default. Use for IMAP UID projection or audit logging.
CLI:
bash
agentmail inboxes:events list --inbox-id <inbox_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/events:
get:
operationId: list
summary: List Inbox Events
description: >-
List label change events for an inbox. Returns events in reverse
chronological order by default. Use for IMAP UID projection or audit
logging.
**CLI:**
```bash
agentmail inboxes:events list --inbox-id <inbox_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/events
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: limit
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Limit'
- name: page_token
in: query
required: false
schema:
$ref: '#/components/schemas/type_:PageToken'
- name: ascending
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Ascending'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_inbox-events:ListInboxEventsResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_:Limit:
type: integer
description: Limit of number of items returned.
title: Limit
type_:PageToken:
type: string
description: Page token for pagination.
title: PageToken
type_:Ascending:
type: boolean
description: Sort in ascending temporal order.
title: Ascending
type_:Count:
type: integer
description: Number of items returned.
title: Count
type_:OrganizationId:
type: string
description: ID of organization.
title: OrganizationId
type_inbox-events:InboxEventId:
type: string
description: ID of event.
title: InboxEventId
type_inbox-events:InboxEventType:
type: string
enum:
- label.added
- label.removed
description: |-
Type of inbox event. Wire format is dot.case to match the
convention used by webhook events (`message.received`,
`domain.verified`, etc. in events.yml). Pre-2026-04 these were
`label_added`/`label_removed` (snake_case). The Fern enum's `name`
field stays uppercase-snake (Fern convention); only the wire
`value` changed.
title: InboxEventType
type_inbox-events:InboxEvent:
type: object
properties:
organization_id:
$ref: '#/components/schemas/type_:OrganizationId'
pod_id:
type: string
description: ID of pod.
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
event_id:
$ref: '#/components/schemas/type_inbox-events:InboxEventId'
event_type:
$ref: '#/components/schemas/type_inbox-events:InboxEventType'
message_id:
type: string
description: ID of message.
label:
type: string
description: Label added or removed.
event_at:
type: string
format: date-time
description: Time at which the event occurred.
created_at:
type: string
format: date-time
description: Time at which the event was recorded.
required:
- organization_id
- pod_id
- inbox_id
- event_id
- event_type
- message_id
- label
- event_at
- created_at
title: InboxEvent
type_inbox-events:ListInboxEventsResponse:
type: object
properties:
count:
$ref: '#/components/schemas/type_:Count'
limit:
$ref: '#/components/schemas/type_:Limit'
next_page_token:
$ref: '#/components/schemas/type_:PageToken'
events:
type: array
items:
$ref: '#/components/schemas/type_inbox-events:InboxEvent'
description: Ordered by `event_id` descending.
required:
- count
- events
title: ListInboxEventsResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"count": 1,
"events": [
{
"organization_id": "organization_id",
"pod_id": "pod_id",
"inbox_id": "inbox_id",
"event_id": "event_id",
"event_type": "label.added",
"message_id": "message_id",
"label": "label",
"event_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z"
},
{
"organization_id": "organization_id",
"pod_id": "pod_id",
"inbox_id": "inbox_id",
"event_id": "event_id",
"event_type": "label.added",
"message_id": "message_id",
"label": "label",
"event_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z"
}
],
"limit": 1,
"next_page_token": "next_page_token"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.events.list("inbox_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.events.list(
inbox_id="inbox_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/events"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/events")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/events', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/events");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/events")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Query Metrics (Inbox)
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/metrics
CLI:
bash
agentmail inboxes:metrics query --inbox-id <inbox_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/metrics:
get:
operationId: query
summary: Query Metrics
description: |-
**CLI:**
```bash
agentmail inboxes:metrics query --inbox-id <inbox_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/metrics
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: event_types
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:MetricEventTypes'
- name: start
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:Start'
- name: end
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:End'
- name: period
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:Period'
- name: limit
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:MetricLimit'
- name: descending
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:Descending'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_metrics:QueryMetricsResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_metrics:MetricEventType:
type: string
enum:
- message.sent
- message.delivered
- message.bounced
- message.delayed
- message.rejected
- message.complained
- message.received
description: Type of metric event.
title: MetricEventType
type_metrics:MetricEventTypes:
type: array
items:
$ref: '#/components/schemas/type_metrics:MetricEventType'
description: List of metric event types to query.
title: MetricEventTypes
type_metrics:Start:
type: string
format: date-time
description: Start timestamp for the query.
title: Start
type_metrics:End:
type: string
format: date-time
description: End timestamp for the query.
title: End
type_metrics:Period:
type: string
description: Period in number of seconds for the query.
title: Period
type_metrics:MetricLimit:
type: integer
description: Limit on number of buckets to return.
title: MetricLimit
type_metrics:Descending:
type: boolean
description: Sort in descending order.
title: Descending
type_metrics:MetricBucket:
type: object
properties:
timestamp:
type: string
format: date-time
description: Timestamp of the bucket.
count:
type: integer
description: Count of events in the bucket.
required:
- timestamp
- count
title: MetricBucket
type_metrics:QueryMetricsResponse:
type: object
additionalProperties:
type: array
items:
$ref: '#/components/schemas/type_metrics:MetricBucket'
description: Metrics grouped by event type.
title: QueryMetricsResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"message.sent": [
{
"timestamp": "2024-01-15T09:30:00Z",
"count": 1
},
{
"timestamp": "2024-01-15T09:30:00Z",
"count": 1
}
]
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.metrics.query("inbox_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.metrics.query(
inbox_id="inbox_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/metrics"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/metrics")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/metrics', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/metrics");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/metrics")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Query Metrics (Org)
GET https://api.agentmail.to/v0/metrics
CLI:
bash
agentmail metrics listOpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/metrics:
get:
operationId: query
summary: Query Metrics
description: |-
**CLI:**
```bash
agentmail metrics list
```
tags:
- subpackage_metrics
parameters:
- name: event_types
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:MetricEventTypes'
- name: start
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:Start'
- name: end
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:End'
- name: period
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:Period'
- name: limit
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:MetricLimit'
- name: descending
in: query
required: false
schema:
$ref: '#/components/schemas/type_metrics:Descending'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_metrics:QueryMetricsResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_metrics:MetricEventType:
type: string
enum:
- message.sent
- message.delivered
- message.bounced
- message.delayed
- message.rejected
- message.complained
- message.received
description: Type of metric event.
title: MetricEventType
type_metrics:MetricEventTypes:
type: array
items:
$ref: '#/components/schemas/type_metrics:MetricEventType'
description: List of metric event types to query.
title: MetricEventTypes
type_metrics:Start:
type: string
format: date-time
description: Start timestamp for the query.
title: Start
type_metrics:End:
type: string
format: date-time
description: End timestamp for the query.
title: End
type_metrics:Period:
type: string
description: Period in number of seconds for the query.
title: Period
type_metrics:MetricLimit:
type: integer
description: Limit on number of buckets to return.
title: MetricLimit
type_metrics:Descending:
type: boolean
description: Sort in descending order.
title: Descending
type_metrics:MetricBucket:
type: object
properties:
timestamp:
type: string
format: date-time
description: Timestamp of the bucket.
count:
type: integer
description: Count of events in the bucket.
required:
- timestamp
- count
title: MetricBucket
type_metrics:QueryMetricsResponse:
type: object
additionalProperties:
type: array
items:
$ref: '#/components/schemas/type_metrics:MetricBucket'
description: Metrics grouped by event type.
title: QueryMetricsResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"message.sent": [
{
"timestamp": "2024-01-15T09:30:00Z",
"count": 1
},
{
"timestamp": "2024-01-15T09:30:00Z",
"count": 1
}
]
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.metrics.query({});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.metrics.query()go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/metrics"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/metrics")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/metrics', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/metrics");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/metrics")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()