AgentPost
Webhooks

Webhook Events

Complete reference for all AgentPost webhook event types and their payload structures

Webhook Events

AgentPost emits webhook events for key actions across your organization. Each event follows the common envelope format and contains event-specific data in the data field.

Event Types

Event TypeTrigger
message.receivedAn inbound email is received by an inbox
message.sentAn outbound email is accepted by the mail provider
message.deliveredAn outbound email is confirmed delivered to the recipient
message.bouncedAn outbound email bounces (hard or soft)
message.complainedA recipient marks an email as spam
message.rejectedAn outbound email is rejected before sending
domain.verifiedA custom domain passes DNS verification

message.received

Triggered when an inbound email arrives at one of your inboxes. This is the most commonly used event for AI agent workflows -- it signals that new work is available for processing.

Trigger: An email addressed to an inbox email address passes spam checks and is stored.

{
  "id": "evt_01JQ8X5K2M3N4P5R6S7T8V9W",
  "type": "message.received",
  "timestamp": "2026-03-08T14:30:00.000Z",
  "org_id": "org_01JQ8X5K2M3N4P5R6S7T8V9W",
  "env_id": "env_01JQ8X5K2M3N4P5R6S7T8V9W",
  "data": {
    "message_id": "msg_01JQ8X5K2M3N4P5R6S7T8V9W",
    "thread_id": "thr_01JQ8X5K2M3N4P5R6S7T8V9W",
    "inbox_id": "inb_01JQ8X5K2M3N4P5R6S7T8V9W",
    "from_address": "[email protected]",
    "to_addresses": ["[email protected]"],
    "subject": "Need help with billing integration",
    "extracted_text": "Hi, I'm having trouble setting up the billing webhook. Can you help?",
    "has_attachments": false,
    "received_at": "2026-03-08T14:30:00.000Z"
  }
}
FieldTypeDescription
message_idstringUnique message identifier
thread_idstringThread this message belongs to
inbox_idstringInbox that received the message
from_addressstringSender's email address
to_addressesstring[]Recipient email addresses
subjectstringEmail subject line
extracted_textstringClean reply text with quotes stripped
has_attachmentsbooleanWhether the message has file attachments
received_atstringISO 8601 timestamp of receipt

message.sent

Triggered when an outbound email is successfully accepted by the mail provider (AWS SES). This confirms the email entered the delivery pipeline -- it does not mean the email has reached the recipient's inbox yet.

Trigger: AWS SES accepts the email for delivery.

{
  "id": "evt_01JQ9A2B3C4D5E6F7G8H9J0K",
  "type": "message.sent",
  "timestamp": "2026-03-08T14:31:00.000Z",
  "org_id": "org_01JQ8X5K2M3N4P5R6S7T8V9W",
  "env_id": "env_01JQ8X5K2M3N4P5R6S7T8V9W",
  "data": {
    "message_id": "msg_01JQ9A2B3C4D5E6F7G8H9J0K",
    "thread_id": "thr_01JQ8X5K2M3N4P5R6S7T8V9W",
    "inbox_id": "inb_01JQ8X5K2M3N4P5R6S7T8V9W",
    "from_address": "[email protected]",
    "to_addresses": ["[email protected]"],
    "subject": "Re: Need help with billing integration",
    "ses_message_id": "01000192-1234-5678-9abc-def012345678",
    "sent_at": "2026-03-08T14:31:00.000Z"
  }
}
FieldTypeDescription
message_idstringUnique message identifier
thread_idstringThread this message belongs to
inbox_idstringInbox the message was sent from
from_addressstringSender address
to_addressesstring[]Recipient addresses
subjectstringEmail subject line
ses_message_idstringAWS SES message identifier for tracking
sent_atstringISO 8601 timestamp of send

message.delivered

Triggered when an outbound email is confirmed delivered to the recipient's mail server. This is the strongest positive signal -- it means the email arrived.

Trigger: AWS SES receives a delivery notification from the recipient's mail server.

{
  "id": "evt_01JQ9B3C4D5E6F7G8H9J0K1L",
  "type": "message.delivered",
  "timestamp": "2026-03-08T14:32:00.000Z",
  "org_id": "org_01JQ8X5K2M3N4P5R6S7T8V9W",
  "env_id": "env_01JQ8X5K2M3N4P5R6S7T8V9W",
  "data": {
    "message_id": "msg_01JQ9A2B3C4D5E6F7G8H9J0K",
    "thread_id": "thr_01JQ8X5K2M3N4P5R6S7T8V9W",
    "inbox_id": "inb_01JQ8X5K2M3N4P5R6S7T8V9W",
    "to_addresses": ["[email protected]"],
    "delivered_at": "2026-03-08T14:32:00.000Z",
    "processing_time_ms": 1250
  }
}
FieldTypeDescription
message_idstringOriginal message identifier
thread_idstringThread identifier
inbox_idstringInbox the message was sent from
to_addressesstring[]Recipients that received the email
delivered_atstringISO 8601 timestamp of confirmed delivery
processing_time_msnumberTime from send to delivery confirmation in ms

message.bounced

Triggered when an outbound email bounces. Bounces can be hard (permanent failure) or soft (temporary issue). Monitoring bounces is critical for maintaining your sending reputation.

Trigger: AWS SES receives a bounce notification from the recipient's mail server.

{
  "id": "evt_01JQ9C4D5E6F7G8H9J0K1L2M",
  "type": "message.bounced",
  "timestamp": "2026-03-08T14:33:00.000Z",
  "org_id": "org_01JQ8X5K2M3N4P5R6S7T8V9W",
  "env_id": "env_01JQ8X5K2M3N4P5R6S7T8V9W",
  "data": {
    "message_id": "msg_01JQ9A2B3C4D5E6F7G8H9J0K",
    "thread_id": "thr_01JQ8X5K2M3N4P5R6S7T8V9W",
    "inbox_id": "inb_01JQ8X5K2M3N4P5R6S7T8V9W",
    "bounce_type": "Permanent",
    "bounce_sub_type": "General",
    "bounced_recipients": [
      {
        "email_address": "[email protected]",
        "status": "5.1.1",
        "diagnostic_code": "smtp; 550 5.1.1 The email account does not exist"
      }
    ],
    "bounced_at": "2026-03-08T14:33:00.000Z"
  }
}
FieldTypeDescription
message_idstringOriginal message identifier
thread_idstringThread identifier
inbox_idstringInbox the message was sent from
bounce_typestringPermanent (hard) or Transient (soft)
bounce_sub_typestringSub-category: General, NoEmail, Suppressed
bounced_recipientsarrayList of recipients that bounced
bounced_atstringISO 8601 timestamp of bounce

Bounce Types:

  • Permanent (hard bounce): The address does not exist or is permanently unreachable. Remove it from your lists immediately.
  • Transient (soft bounce): Temporary issue (mailbox full, server unavailable). Can retry later, but repeated soft bounces may indicate a problem.

message.complained

Triggered when a recipient marks one of your emails as spam. Complaint rates above 0.1% can severely impact your sending reputation. Monitor this event closely.

Trigger: AWS SES receives a complaint feedback report from the recipient's email provider.

{
  "id": "evt_01JQ9D5E6F7G8H9J0K1L2M3N",
  "type": "message.complained",
  "timestamp": "2026-03-08T14:34:00.000Z",
  "org_id": "org_01JQ8X5K2M3N4P5R6S7T8V9W",
  "env_id": "env_01JQ8X5K2M3N4P5R6S7T8V9W",
  "data": {
    "message_id": "msg_01JQ9A2B3C4D5E6F7G8H9J0K",
    "inbox_id": "inb_01JQ8X5K2M3N4P5R6S7T8V9W",
    "complained_recipients": ["[email protected]"],
    "feedback_type": "abuse",
    "complained_at": "2026-03-08T14:34:00.000Z"
  }
}
FieldTypeDescription
message_idstringOriginal message identifier
inbox_idstringInbox the message was sent from
complained_recipientsstring[]Recipients who filed the complaint
feedback_typestringComplaint type (typically abuse)
complained_atstringISO 8601 timestamp of complaint

message.rejected

Triggered when an outbound email is rejected before it enters the delivery pipeline. This typically happens due to policy violations, block list matches, or rate limiting.

Trigger: AgentPost or AWS SES rejects the email before attempting delivery.

{
  "id": "evt_01JQ9E6F7G8H9J0K1L2M3N4P",
  "type": "message.rejected",
  "timestamp": "2026-03-08T14:35:00.000Z",
  "org_id": "org_01JQ8X5K2M3N4P5R6S7T8V9W",
  "env_id": "env_01JQ8X5K2M3N4P5R6S7T8V9W",
  "data": {
    "inbox_id": "inb_01JQ8X5K2M3N4P5R6S7T8V9W",
    "from_address": "[email protected]",
    "to_addresses": ["[email protected]"],
    "subject": "Your order has shipped",
    "rejection_reason": "blocked_recipient",
    "rejection_detail": "Recipient blocked by organization filter rules",
    "rejected_at": "2026-03-08T14:35:00.000Z"
  }
}
FieldTypeDescription
inbox_idstringInbox that attempted to send
from_addressstringSender address
to_addressesstring[]Intended recipients
subjectstringEmail subject line
rejection_reasonstringReason code: blocked_recipient, rate_limited, account_paused
rejection_detailstringHuman-readable rejection explanation
rejected_atstringISO 8601 timestamp of rejection

domain.verified

Triggered when a custom domain passes DNS verification (SPF, DKIM, and optionally DMARC). This signals that the domain is ready for sending and receiving email.

Trigger: AgentPost's domain verification job confirms all required DNS records are in place.

{
  "id": "evt_01JQ9F7G8H9J0K1L2M3N4P5R",
  "type": "domain.verified",
  "timestamp": "2026-03-08T14:36:00.000Z",
  "org_id": "org_01JQ8X5K2M3N4P5R6S7T8V9W",
  "env_id": "env_01JQ8X5K2M3N4P5R6S7T8V9W",
  "data": {
    "domain_id": "dom_01JQ9F7G8H9J0K1L2M3N4P5R",
    "domain_name": "mail.acmeco.com",
    "verification_status": "verified",
    "spf_status": "verified",
    "dkim_status": "verified",
    "dmarc_status": "verified",
    "verified_at": "2026-03-08T14:36:00.000Z"
  }
}
FieldTypeDescription
domain_idstringDomain identifier
domain_namestringThe verified domain name
verification_statusstringOverall status: verified
spf_statusstringSPF record verification status
dkim_statusstringDKIM record verification status
dmarc_statusstringDMARC record verification status
verified_atstringISO 8601 timestamp of verification

Subscribing to Events

When creating or updating a webhook endpoint, specify the event types you want to receive:

import AgentPost from '@agentpost/sdk';

const client = new AgentPost({ apiKey: 'ap_sk_live_your_key_here' });

// Subscribe to specific events
const endpoint = await client.webhookEndpoints.create({
  url: 'https://your-app.com/webhooks/agentpost',
  events: [
    'message.received',
    'message.bounced',
    'message.complained',
    'domain.verified',
  ],
});
from agentpost import AgentPost

client = AgentPost(api_key="ap_sk_live_your_key_here")

# Subscribe to specific events
endpoint = client.webhook_endpoints.create(
    url="https://your-app.com/webhooks/agentpost",
    events=[
        "message.received",
        "message.bounced",
        "message.complained",
        "domain.verified",
    ],
)
curl -X POST https://api.agent-post.dev/api/v1/webhooks/endpoints \
  -H "Authorization: Bearer ap_sk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-app.com/webhooks/agentpost",
    "events": [
      "message.received",
      "message.bounced",
      "message.complained",
      "domain.verified"
    ]
  }'

Next Steps

On this page