Skip to content

Send events to an agent

An assistant connected over MCP answers when you ask. To have an agent act when something happens (a bounce to clean up, a new contact to research, a campaign to report on), have Sendwing post the event to it with a webhook.

  1. You run an endpoint: a small HTTPS service, or a webhook trigger in an agent or automation platform.
  2. Sendwing posts each event you chose to it, signed.
  3. The endpoint checks the signature, then hands the event to your agent.
  4. The agent acts: through the MCP server or the REST API to change things in Sendwing, or anywhere else.
Event When
contact.created A contact was created
contact.updated A contact’s fields or custom properties changed
contact.deleted A contact was deleted
contact.subscribed A contact subscribed, to marketing email or to a mailing list
contact.unsubscribed A contact unsubscribed, or was unsubscribed
contact.tag_added, contact.tag_removed A tag was added to or removed from a contact
email.sent, email.delivered A campaign or workflow email was sent, or delivered
email.opened, email.clicked A contact first opened an email, or first clicked a link in it
email.bounced, email.complained, email.failed An email bounced, was marked as spam, or couldn’t be sent
campaign.sent, campaign.canceled A campaign started sending, or was canceled
domain.verified A sending domain was verified
contact_import.completed, contact_import.failed A CSV import finished, or stopped with an error

Each event’s full shape is in the API reference.

With an API key that can manage webhooks:

Terminal window
curl https://api.sendwing.app/api/organizations/$ORGANIZATION_ID/webhooks/endpoints \
-H "x-api-key: $SENDWING_API_KEY" \
-H "content-type: application/json" \
-d '{
"url": "https://agent.example.com/sendwing",
"description": "Bounce cleanup agent",
"eventTypes": ["email.bounced", "email.complained"]
}'

GET /me with the same key returns your organizationId. A workspace can have up to 25 endpoints.

Every delivery is a POST with the event as its JSON body, signed the Standard Webhooks way with the endpoint’s secret (whsec_…), so any Standard Webhooks library checks it. Check it before your agent trusts anything in the body.

import { Webhook } from 'standardwebhooks'
const webhook = new Webhook(process.env.SENDWING_WEBHOOK_SECRET!)
export async function handle(request: Request) {
const body = await request.text()
let event
try {
// Checks webhook-signature over webhook-id, webhook-timestamp and the body, and refuses old timestamps
event = webhook.verify(body, Object.fromEntries(request.headers))
} catch {
return new Response('Bad signature', { status: 401 })
}
await queue.push(event) // Hand it to your agent, then answer quickly
return new Response(null, { status: 204 })
}
  • Bounce cleanup. On email.bounced, have the agent look the contact up and tag them for review, or check whether the address has a typo.
  • New contact research. On contact.created, have the agent enrich the contact from your CRM and set its custom properties over the API.
  • Campaign report. On campaign.sent, wait a day, then have the agent read get_campaign_report and post a summary to your team chat.
  • DNS follow-up. On domain.verified, tell whoever asked for the domain that it’s ready to send.

If your endpoint was down, GET /organizations/{organizationId}/webhooks/events lists the last 30 days of events, newest first, as they were delivered. Sendwing keeps events only for types an enabled endpoint listens for.