Webhooks & Inbound APIs

Connect external triggers, ingest contacts, and capture real-time email delivery events.

Outbound Integration

1. Automation Trigger Webhook

Trigger custom automated sequences programmatically for a specific contact. If the contact does not yet exist, AutoMail AI will automatically register them.

POST/api/automations/:id/trigger

Parameters & Authentication

  • :id — UUID of the target automation.
  • ?key=YOUR_API_KEY or header Authorization: Bearer YOUR_API_KEY.

Payload Example

curl -X POST "https://automailai.vercel.app/api/automations/YOUR_AUTOMATION_ID/trigger" \
  -H "Authorization: Bearer sk_automail_..." \
  -H "Content-Type: application/json" \
  -d '{
    "email": "sarah.connor@example.com",
    "first_name": "Sarah",
    "plan": "enterprise_tier"
  }'
High-Throughput

2. Universal Contact & Event Ingest

Stream leads and application events directly from your SaaS or landing pages. Protected by sliding-window rate limiting (120 requests/minute per key).

POST/api/ingest

Rate Limit Headers

Every response includes standard RFC-compliant rate limit telemetry:

  • X-RateLimit-Limit: 120
  • X-RateLimit-Remaining: 118
  • X-RateLimit-Reset: 1725619200
  • Retry-After: 35 (on HTTP 429)

cURL Ingest Example

curl -X POST "https://automailai.vercel.app/api/ingest" \
  -H "Authorization: Bearer YOUR_WEBHOOK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "alex@company.com",
    "first_name": "Alex",
    "company": "Acme Corp",
    "event": "user.signup",
    "tags": ["saas-trial", "onboarding"]
  }'
Telemetry & Analytics

3. Resend Delivery & Engagement Webhook

Receive delivery confirmations, opens, clicks, bounces, and spam complaints from Resend. AutoMail AI updates campaign counters and cleans bad email addresses in real time.

POST/api/webhooks/resend

Setup in Resend Dashboard

  1. Navigate to Resend Dashboard > Webhooks.
  2. Click Add Webhook and set Endpoint URL to https://automailai.vercel.app/api/webhooks/resend.
  3. Select events: email.delivered, email.opened, email.clicked, email.bounced, and email.complained.
  4. Copy the Signing Secret (starts with whsec_...) and save it in your environment as RESEND_WEBHOOK_SECRET.

Automatic State Synchronization

email.delivered

Increments automation total_sent and sets contact last_contacted_at.

email.opened & email.clicked

Increments automation total_opened and total_clicked counters.

email.bounced

Increments total_bounced and marks contact status = 'bounced'.

email.complained

Automatically transitions contact to status = 'unsubscribed'.