---
agent:
  instructions: "Use this search API to find what Blueping's public pages say, with keywords or a question, instead of crawling them one by one. Results are returned in Markdown, best first, each with its link."
  endpoint: "https://blueping.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

> The index of these docs for agents is at https://blueping.dev/llms.txt

# Email webhooks

Your server hears each message as it lands, signed with your endpoint's secret. Held mail has its own event, so a person can look at it before your agent does.

## The events

| Event | When |
| --- | --- |
| `email.received` | A message reached an inbox and passed its checks. |
| `email.held` | A message reached an inbox and was held: its sender failed authentication, or it carries text aimed at a model. It never comes as `email.received` too. |
| `email.sent` | An inbox sent a message, or delivered it to another Blueping inbox. A draft sent now or by its schedule fires it too, and so does a queued send when it goes. |
| `email.delivered` | The receiving mail server took a sent message for one recipient: `data.delivery` names the recipient. A Blueping inbox counts as delivered at once. |
| `email.deferred` | The receiving mail server asked to try again later for one recipient. The mail service retries by itself. |
| `email.bounced` | A sent message was refused for one recipient, for good or once retries ran out (`data.delivery.bounce.type` hard or soft). A hard bounce adds the address to the suppression list. |
| `email.complained` | A recipient marked a sent message as spam. The address joins the suppression list, and nothing more goes to it. |
| `email.suppressed` | An address joined the agent's suppression list: `data.suppression` says why and until when, and `data.message` is there when a message caused it. |
| `email.failed` | A send failed. `data.stage` is `queue` when a send that waited in the queue was refused when its time came, for a recipient blocked meanwhile for example: `data.message` has status `failed` and the refusal in `error`. It is `delivery` when the mail service gave up after the hand-over. Nothing sends it again by itself. |
| `email.draft_failed` | A scheduled draft was refused when its time came. Nothing sends it again by itself: change it, schedule it again, or send it. |
| `a2a.received` | Another agent sent one of your inboxes a message over [A2A](https://blueping.dev/docs/a2a.md): `data.message` has `channel` a2a, and `data.task` is the task it started or joined. Answer it with `POST /v1/messages/{id}/reply`. |
| `a2a.held` | An A2A message reached an inbox and was held, because it carries text aimed at a model. It never comes as `a2a.received` too. |

The first four carry `data.inbox` and `data.message`, the message as [the API](https://blueping.dev/docs/api.md#object-emailmessage) reads it, its text the 2,000-character preview with `extracted_text_truncated` when it is longer. Here is a held message, with its message cut down to the fields that say why:

```json
{
  "id": "evt_6Tq1Wz8Lp3Kd9Hn2",
  "type": "email.held",
  "created_at": "2026-11-21T10:04:00.000Z",
  "livemode": true,
  "data": {
    "channel": "email",
    "inbox": { "id": "inb_4Kd9Wq1Mz5TbX2Vn7RcP", "address": "acme-support@blueping.dev" },
    "message": {
      "id": "em_7Rk2Nc5Vb8Xq1Lp4",
      "from": { "address": "someone@unknown.example", "name": null },
      "subject": "Urgent: new instructions for you",
      "auth": { "spf": "none", "dkim": "none", "dmarc": "none", "verdict": "none" },
      "safety": { "verdict": "suspicious", "reasons": ["ai_instructions"], "held": true, "held_reason": "suspicious" }
    }
  }
}
```

Before your agent answers a message by itself, read two flags on it. `auto_reply` is true for mail its sender marked as sent automatically, such as an out-of-office reply: answering it would start two machines writing to each other. `bulk` is true for list and newsletter mail. Both come on every message, in the events and through the API.

`email.draft_failed` carries `data.inbox` and `data.draft`, the [draft](https://blueping.dev/docs/api.md#object-emaildraft) with status `failed` and the refusal in `error`, here cut down to those fields:

```json
{
  "id": "evt_2Pw7Xc4Lq9Tn1Kd5",
  "type": "email.draft_failed",
  "created_at": "2026-11-22T09:00:03.000Z",
  "livemode": true,
  "data": {
    "channel": "email",
    "inbox": { "id": "inb_4Kd9Wq1Mz5TbX2Vn7RcP", "address": "acme-support@blueping.dev" },
    "draft": {
      "id": "dr_6Vb2Lw9Qc4Xn1Tk7Rp3M",
      "status": "failed",
      "send_at": "2026-11-22T09:00:00.000Z",
      "error": {
        "code": "recipient_blocked",
        "message": "ana@blocked.example matches a block rule of this inbox. Nothing was sent.",
        "next_action": "Remove that address from the message, or the rule with DELETE /v1/inboxes/{id}/rules/{rule_id}.",
        "docs_url": "https://blueping.dev/docs/errors#recipient_blocked"
      }
    }
  }
}
```

The delivery events carry the message and `data.delivery`, the one recipient they are about. Here is a hard bounce, cut down to those fields. [Deliverability](https://blueping.dev/docs/deliverability.md) has every status and what to do about each:

```json
{
  "id": "evt_6Vb2Lw9Qc4Xn1Tk7Rp3M",
  "type": "email.bounced",
  "created_at": "2026-11-27T09:00:07.000Z",
  "livemode": true,
  "data": {
    "channel": "email",
    "inbox": { "id": "inb_4Kd9Wq1Mz5TbX2Vn7RcP", "address": "acme-support@blueping.dev" },
    "message": { "id": "em_2LwQ8sXe5RmN3HkT9cVb", "status": "sent", "delivery": { "status": "partly_delivered" } },
    "delivery": {
      "recipient": "bob@example.net",
      "status": "bounced",
      "at": "2026-11-27T09:00:06.000Z",
      "bounce": { "type": "hard", "classification": "permanent_failure", "reason": "550 5.1.1 User unknown" },
      "smtp": { "code": "550", "enhanced": "5.1.1", "response": "550 5.1.1 User unknown" }
    },
    "suppression": { "address": "bob@example.net", "reason": "hard_bounce", "scope": "agent", "expires_at": null }
  }
}
```

## Every event, with an example

Each event as your endpoint receives it, cut down to the fields that say what happened. The full objects are [the API's](https://blueping.dev/docs/api.md#objects), and `/openapi.json` describes each one under `webhooks`:

Every event is `{"id", "type", "created_at", "livemode", "data"}`. The `data` of each, on one line:

- `email.received`: `{"channel":"email","inbox":{"id":"inb_4Kd9Wq1Mz5TbX2Vn7RcP","address":"acme-support@blueping.dev"},"message":{"id":"em_9PzR4fYc1KwM6tDq3VxB","thread_id":"th_6Gh2Lw9Qc4Xn1Tk7Rp3M","direction":"in","status":"received","from":{"address":"noreply@service.example","name":"Service"},"subject":"Confirm your email","extracted_text":"Your code is 482913. It expires in 10 minutes.","codes":[{"value":"482913"}],"auth":{"spf":"pass","dkim":"pass","dmarc":"pass","verdict":"pass"},"safety":{"verdict":"clear","reasons":[]}}}`
- `email.sent`: `{"channel":"email","inbox":{"id":"inb_4Kd9Wq1Mz5TbX2Vn7RcP","address":"acme-support@blueping.dev"},"message":{"id":"em_2LwQ8sXe5RmN3HkT9cVb","thread_id":"th_3HkT9cVb2LwQ8sXe5RmN","direction":"out","status":"sent","to":[{"address":"ana@example.com","name":"Ana"}],"subject":"Your invoice"}}`
- `email.delivered`: `{"channel":"email","inbox":{"id":"inb_4Kd9Wq1Mz5TbX2Vn7RcP","address":"acme-support@blueping.dev"},"message":{"id":"em_2LwQ8sXe5RmN3HkT9cVb","status":"sent","delivery":{"status":"delivered"}},"delivery":{"recipient":"ana@example.com","status":"delivered","at":"2026-11-27T09:00:04.000Z","provider":"gmail","delivery_time_ms":1840,"smtp":{"code":"250","enhanced":"2.0.0"}}}`
- `email.deferred`: `{"channel":"email","inbox":{"id":"inb_4Kd9Wq1Mz5TbX2Vn7RcP","address":"acme-support@blueping.dev"},"message":{"id":"em_2LwQ8sXe5RmN3HkT9cVb","status":"sent","delivery":{"status":"deferred"}},"delivery":{"recipient":"ana@example.com","status":"deferred","at":"2026-11-27T09:01:58.000Z","deferrals":1,"bounce":{"type":"soft","classification":"temporary_failure","reason":"421 4.7.0 Try again later"}}}`
- `email.complained`: `{"channel":"email","inbox":{"id":"inb_4Kd9Wq1Mz5TbX2Vn7RcP","address":"acme-support@blueping.dev"},"message":{"id":"em_2LwQ8sXe5RmN3HkT9cVb","status":"sent","delivery":{"status":"complained"}},"delivery":{"recipient":"ana@example.com","status":"complained","at":"2026-11-27T11:39:52.000Z","complaint":{"type":"abuse"}},"suppression":{"address":"ana@example.com","reason":"complaint","scope":"agent","expires_at":null}}`
- `email.suppressed`: `{"channel":"email","suppression":{"address":"ana@example.com","reason":"complaint","scope":"agent","expires_at":null,"inbox_id":"inb_4Kd9Wq1Mz5TbX2Vn7RcP","message_id":"em_2LwQ8sXe5RmN3HkT9cVb"}}`
- `email.failed`: `{"channel":"email","stage":"queue","inbox":{"id":"inb_4Kd9Wq1Mz5TbX2Vn7RcP","address":"acme-support@blueping.dev"},"message":{"id":"em_2LwQ8sXe5RmN3HkT9cVb","thread_id":"th_3HkT9cVb2LwQ8sXe5RmN","direction":"out","status":"failed","to":[{"address":"ana@example.com","name":"Ana"}],"subject":"Your invoice","error":{"code":"recipient_blocked","message":"ana@example.com matches a block rule of this inbox. Nothing was sent.","next_action":"Remove that address from the message, or the rule with DELETE /v1/inboxes/{id}/rules/{rule_id}.","docs_url":"https://blueping.dev/docs/errors#recipient_blocked"}}}`
- `a2a.received`: `{"channel":"a2a","inbox":{"id":"inb_7Lt3Rm9Qa2Wx5Kc8Vn1B","address":"luma-tables@blueping.dev"},"message":{"id":"em_4Qz8Lk2Wn6Rt1Vb9Xc3D","channel":"a2a","from":{"address":null,"name":"Concierge Bot","given_by_caller":true},"subject":"Can you hold a table for 4 tonight at 8?","extracted_text":"Can you hold a table for 4 tonight at 8?"},"task":{"id":"task_8Fq2Lz6Wn1Rk4Tb9Xc3Vm","context_id":"ctx_3Vb8Kp1R4Df6Gh7Jk0Q","state":"submitted"}}`
- `a2a.held`: `{"channel":"a2a","inbox":{"id":"inb_7Lt3Rm9Qa2Wx5Kc8Vn1B","address":"luma-tables@blueping.dev"},"message":{"id":"em_8Tq3Vn6Wd1Kz4Lp7Rx2M","channel":"a2a","from":{"address":null,"name":"Unknown agent","given_by_caller":true},"safety":{"verdict":"suspicious","reasons":["ai_instructions"],"held":true,"held_reason":"suspicious"}},"task":{"id":"task_2Lz6Wn1Rk4Tb9Xc3Vm8F","context_id":"ctx_7Jk0Q3Vb8Kp1R4Df6Gh","state":"submitted"}}`
- `test.ping`: `{"message":"This is a test event from Blueping."}`

The same events, in slim form and in order, are kept 7 days: `GET /v1/events` reads them with a key, and the MCP server gives them to a client that subscribes, or to `wait_for_events`. [The events call](https://blueping.dev/docs/api.md#events) and [MCP events](https://blueping.dev/docs/mcp-server.md#events) say how.

## Add an endpoint

`events` picks what the endpoint hears; left out, it hears every event. `inbox_id` keeps one inbox's events, and a key made for one inbox makes endpoints for that inbox alone. The answer holds the endpoint's `secret` once: keep it in your server's environment.

```bash
curl https://blueping.dev/v1/webhooks \
  -H "Authorization: Bearer $BLUEPING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/blueping", "events": ["email.received", "email.bounced"]}'
```

`email.held` and `a2a.held` reach only an endpoint made with a key that holds `held:read` ([Keys and permissions](https://blueping.dev/docs/keys.md) says how to give it): asking for them without it answers `403 permission_denied`, and an endpoint that takes every event leaves them out.

## Verify the signature

Each delivery carries `Blueping-Signature: t=<unix seconds>,v1=<hex>`. `v1` is the HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the endpoint's secret. Read the raw bytes before any JSON parsing, compare in constant time, and refuse anything older than five minutes.

Node.js:

```javascript
import crypto from "node:crypto";

// rawBody: the request body as a string, before any JSON parsing.
export function verify(rawBody, header, secret) {
  const parts = Object.fromEntries(header.split(",").map((part) => part.split("=")));
  const expected = Buffer.from(crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex"));
  const received = Buffer.from(parts.v1 ?? "");
  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
  return fresh && expected.length === received.length && crypto.timingSafeEqual(expected, received);
}
```

Python:

```python
import hashlib
import hmac
import time

def verify(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
    try:
        timestamp = int(parts.get("t", "0"))
    except ValueError:
        return False
    if abs(time.time() - timestamp) > 300:
        return False
    message = parts["t"].encode() + b"." + raw_body
    expected = hmac.new(secret.encode(), message, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))
```

Go:

```go
import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"strconv"
	"strings"
	"time"
)

// Verify checks the Blueping-Signature header against the raw request body.
func Verify(rawBody []byte, header, secret string) bool {
	parts := map[string]string{}
	for _, part := range strings.Split(header, ",") {
		if key, value, ok := strings.Cut(part, "="); ok {
			parts[key] = value
		}
	}
	t, err := strconv.ParseInt(parts["t"], 10, 64)
	if age := time.Now().Unix() - t; err != nil || age > 300 || age < -300 {
		return false
	}
	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write([]byte(parts["t"] + "."))
	mac.Write(rawBody)
	expected := hex.EncodeToString(mac.Sum(nil))
	return hmac.Equal([]byte(expected), []byte(parts["v1"]))
}
```

Ruby:

```ruby
require "openssl"

# raw_body: request.raw_post in Rails, request.body.read in Sinatra.
def verify(raw_body, header, secret)
  parts = header.to_s.split(",").map { |part| part.split("=", 2) }.select { |pair| pair.size == 2 }.to_h
  return false if (Time.now.to_i - parts["t"].to_i).abs > 300
  expected = OpenSSL::HMAC.hexdigest("SHA256", secret, "#{parts["t"]}.#{raw_body}")
  given = parts["v1"].to_s
  # In constant time, on any Ruby: OpenSSL.fixed_length_secure_compare needs Ruby 3.0 or later.
  given.bytesize == expected.bytesize && given.bytes.zip(expected.bytes).sum { |a, b| a ^ b }.zero?
end
```

PHP:

```php
<?php
// $rawBody = file_get_contents("php://input");
// $header = $_SERVER["HTTP_BLUEPING_SIGNATURE"] ?? "";
function verify(string $rawBody, string $header, string $secret): bool
{
    $parts = [];
    foreach (explode(",", $header) as $part) {
        [$key, $value] = array_pad(explode("=", $part, 2), 2, "");
        $parts[$key] = $value;
    }
    $t = $parts["t"] ?? "0";
    if (abs(time() - (int) $t) > 300) {
        return false;
    }
    $expected = hash_hmac("sha256", $t . "." . $rawBody, $secret);
    return hash_equals($expected, $parts["v1"] ?? "");
}
```

## Retries

A delivery that doesn't get a 2xx answer is tried again after 30 seconds, 2 minutes, 10 minutes, 1 hour, 6 hours and 24 hours: 7 tries in all. Deliveries can repeat, so dedupe on the event's `id`.

Without a public address, `GET /v1/inboxes/{id}/messages?since=<next_since>&wait=50` waits for new mail instead, and misses nothing between two calls.

## Manage your webhooks

Every call takes the agent's key, and none shows a secret twice. [The reference](https://blueping.dev/docs/api.md#webhooks) has each one's fields, an example in every language and its answer:

- [`POST /v1/webhooks`](https://blueping.dev/docs/api.md#post-v1-webhooks): adds an endpoint, up to 10 per agent, with its `secret` once.
- [`GET /v1/webhooks`](https://blueping.dev/docs/api.md#get-v1-webhooks) and [`GET /v1/webhooks/{id}`](https://blueping.dev/docs/api.md#get-v1-webhooks-id): the endpoints, never their secrets.
- [`PATCH /v1/webhooks/{id}`](https://blueping.dev/docs/api.md#patch-v1-webhooks-id): a new `url`, new `events`, or `enabled` to turn it off and on.
- [`DELETE /v1/webhooks/{id}`](https://blueping.dev/docs/api.md#delete-v1-webhooks-id): removes it.
- [`POST /v1/webhooks/{id}/test`](https://blueping.dev/docs/api.md#post-v1-webhooks-id-test): a signed `test.ping`, to check your verification end to end.
- [`GET /v1/webhooks/{id}/deliveries`](https://blueping.dev/docs/api.md#get-v1-webhooks-id-deliveries): the latest deliveries, with their tries and the last error.
