> For the complete documentation index, see [llms.txt](https://crypto-chief.gitbook.io/chief-event-stream/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://crypto-chief.gitbook.io/chief-event-stream/sinks/email.md). Agents can also search and read this documentation through its [MCP server](https://crypto-chief.gitbook.io/chief-event-stream/~gitbook/mcp).

# Email

## Email

An `email` sink sends each matched event as an HTML email to one address. With `delivery_policy.notifications.mode: "digest"`, it sends digests of many events instead. The project's oldest active email sink also receives the project's [operational notifications](#operational-notification-emails).

### Before you start

1. Choose one mailbox per sink. EventStream sends no confirmation request to the address.
2. Allow `no-reply@crypto-chief.com` in the mailbox's spam filter.

#### **Create an Email sink**

<mark style="color:green;">`POST`</mark> `https://api-eventstream.crypto-chief.com/v1/sinks/create`

**Headers**

| Name            | Value                                                                                                                        |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Content-Type    | `application/json`                                                                                                           |
| Merchant        | Your Merchant ID                                                                                                             |
| X-CC-Timestamp  | Unix time in seconds                                                                                                         |
| X-CC-Nonce      | A new random value for every request                                                                                         |
| X-CC-Signature  | [Request signature](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/authentication.md)                    |
| Idempotency-Key | **Required.** [Format](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/authentication.md#idempotency-key) |

**Body**

Unknown fields return `400` `UNKNOWN_FIELD`.

| Name                     | Type    | Required | Description                                                                                                                                                                                                                                                                                                               |
| ------------------------ | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `kind`                   | string  | true     | `"email"`.                                                                                                                                                                                                                                                                                                                |
| `config`                 | object  | true     | Configuration.                                                                                                                                                                                                                                                                                                            |
| `config.to`              | string  | true     | One recipient address (`format: email`): up to `254` bytes, up to `64` before `@`, with the domain in ASCII (punycode for internationalized domains). The domain must contain a dot: an address such as `ops@localhost` passes `sinks/create` but is refused at delivery (see [Retries and errors](#retries-and-errors)). |
| `config.locale`          | string  | true     | `"en"` or `"ru"`: language of the email text, including stage names.                                                                                                                                                                                                                                                      |
| `config.label`           | string  | false    | Optional display label, `0`–`100` characters. No default stored.                                                                                                                                                                                                                                                          |
| `config.rate_per_second` | integer | false    | Events per second for this sink, `1`–`20`, default `20`. A project's notification sinks send one request at a time; see [Ordering, retries, and auto-pause](https://crypto-chief.gitbook.io/chief-event-stream/sinks/overview.md#ordering-retries-and-auto-pause).                                                        |
| `config.enabled`         | boolean | false    | Default `true`. With `false`, unsent deliveries stay `"queued"` and `status` stays `"active"`; see [`config.enabled`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/sinks.md#create-a-sink).                                                                                                           |
| `credentials`            | object  | false    | Not used: omit it or pass `{}`. `credentials_meta` in `sinks/get` is `{}`.                                                                                                                                                                                                                                                |

```json
{
  "kind": "email",
  "config": {
    "to": "alerts@merchant.example",
    "locale": "en",
    "label": "Treasury email",
    "rate_per_second": 5
  }
}
```

**Response**

{% tabs %}
{% tab title="201" %}

```json
{
  "ok": true,
  "data": {
    "sink_id": "019a0000-0000-7000-8000-000000000001",
    "kind": "email",
    "config": {
      "to": "alerts@merchant.example",
      "locale": "en",
      "label": "Treasury email",
      "rate_per_second": 5
    },
    "status": "active",
    "secret": null,
    "secret_version": 0
  },
  "request_id": "019a0000-0000-7000-8000-000000000099"
}
```

{% endtab %}

{% tab title="422" %}

```json
{
  "ok": false,
  "error": "VALIDATION_ERROR",
  "msg": "request does not match the contract",
  "request_id": "019a0000-0000-7000-8000-000000000099",
  "details": {
    "field": "config.to",
    "reason": "invalid format"
  }
}
```

{% endtab %}

{% tab title="429" %}

```json
{
  "ok": false,
  "error": "PROJECT_LIMIT_EXCEEDED",
  "msg": "sink limit reached",
  "request_id": "019a0000-0000-7000-8000-000000000099",
  "details": {}
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
`sinks/create` checks only the address format. Call `sinks/test` after creating the sink and look for the email in the mailbox. `"status": "succeeded"` in [`deliveries/info`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/deliveries.md#get-delivery-info) means the email was accepted for sending; it does not confirm delivery to the inbox.
{% endhint %}

### What arrives

EventStream sends one email per event from `no-reply@crypto-chief.com` to `config.to`. The body is HTML only, with no plain-text part.

* **Subject:** `Crypto Chief: event <type> (<network>, <stage>)`, for example `Crypto Chief: event transfer.token (ETH_MAINNET, confirmed)`. With `locale: "ru"`: `Crypto Chief: событие <type> (<network>, <stage>)`, with the stage as `обнаружено`, `подтверждено`, `финализировано` or `реорганизовано`. `type` and `network` are cut to `64` bytes.
* **Body:** the heading `New Blockchain Event`, the line `A blockchain event was recorded for project #<project ID>.`, a table with the columns Event ID, Type, Network, Stage, Time (UTC), Amount, From and To, and the footer `Generated automatically by Crypto Chief EventStream (delivery_id: <delivery_id>).` In the cases listed in the [message layout](https://crypto-chief.gitbook.io/chief-event-stream/sinks/overview.md#message-layout), the body adds `replay_run_id: <job_id>`. Event emails contain no link; fetch the full event with [`events/get`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/events.md) by `event_id`.
* **Values:** Time is `YYYY-MM-DD HH:MM:SS UTC`. Amount is `payload.amount.raw` scaled by `amount.decimals`, else `asset.decimals`, else `amount.scale`, followed by `asset.symbol` (or `asset.id`), for example `125.5 USDC`; with no decimals known, `<raw> raw units of <asset>`. From and To are `payload.from` and `payload.to`. Amount, asset, From and To come from the transform output only when `payload` lacks them. A missing value shows `—`.
* **Escaping and limits:** control characters are removed and values are HTML-escaped. Amount is cut to `128` bytes, the asset to `64`, From and To to `256`.

Example email for a confirmed `ETH_MAINNET` `USDC` `transfer.token` event, shown as text:

```
Subject: Crypto Chief: event transfer.token (ETH_MAINNET, confirmed)

New Blockchain Event
A blockchain event was recorded for project #123.

Event ID     019a0000-0000-7000-8000-000000000011
Type         transfer.token
Network      ETH_MAINNET
Stage        confirmed
Time (UTC)   2026-10-27 00:00:00 UTC
Amount       125.5 USDC
From         0x0000000000000000000000000000000000000002
To           0x0000000000000000000000000000000000000001

Generated automatically by Crypto Chief EventStream (delivery_id: 019a0000-0000-7000-8000-000000000021).
```

### Operational notification emails

[Notifications](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/notifications.md) of the project are also emailed to its oldest email sink with `status: "active"`, starting with notifications created after that sink. Per project, at most one email per notification `type` and at most `10` such emails are sent in any `60` minutes; the other notifications get no email and stay in `notifications/list`.

These emails are in English whatever `config.locale` is. The subject is `Crypto Chief: event system.<type> (EVENTSTREAM, final)`, for example `Crypto Chief: event system.sink_paused (EVENTSTREAM, final)`; Event ID is the `notification_id` and Time is `created_at`. The email does not include `data`: read it with `notifications/list`. A failed send is retried every `30` seconds, up to `12` attempts. Operational emails are free and do not count toward the project email limits.

### Notification policy

The subscription's `delivery_policy.notifications` applies to email sinks:

* `"immediate"`: one email per event.
* `"throttle"`: as on the other notification sinks; see [Sink Types](https://crypto-chief.gitbook.io/chief-event-stream/sinks/overview.md).
* `"digest"` (email sinks only): `interval_minutes` is `1`–`1440`. The first ordinary event opens a window of `interval_minutes` from that moment, and the window's events are sent in one email after it ends. The first event after the window opens the next one; a new subscription revision starts a new window. A window is split into parts, each sent as a separate email, when a part reaches `10,000` events or `100` occurrences whose event fee is not yet paid. An event with `stage: "reorged"` is sent at once as its own email, and the digest open at that moment is sent without waiting for the window to end. [`events/get`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/events.md) shows each digested event in `notification_decisions` with `action: "digest"` and the digest's `message_id`.

A digest email has the subject `Crypto Chief: event digest (<event_count>)`, from the second part `Crypto Chief: event digest (<event_count>, part #<part>)` (`Crypto Chief: дайджест событий (…)` and `часть #` with `locale: "ru"`). Its body has the heading `Blockchain Event Digest`, the window (`Window: <from> — <to>`), `Events: <event_count> (occurrences: <occurrence_count>, part #<part>)`, `Shown in email: <n> of <event_count>`, the link `Open event journal (<URL>)` with the URL `https://app-data.crypto-chief.com/project/<project_uuid>/event-stream?message_id=<message_id>`, and the table of the first `10` events of the part. The footer's `delivery_id` is the digest's `message_id`.

### Retries and errors

A delivery succeeds when the email is accepted for sending. Bounces and spam filtering after that are not reported.

* **Retried (`transient`, up to `12` attempts over `24` hours):** the email service is unavailable, answers HTTP `408`, `425`, `429` or `500`–`599`, or does not answer within `10` seconds. See [Retries and Ordering](https://crypto-chief.gitbook.io/chief-event-stream/webhooks/retries-and-ordering.md).
* **Project email limits:** once the project's accepted event and digest emails reach `100` in the current UTC clock hour or `1,000` in the UTC day, further event emails wait for the next hour or day without using attempts (an attempt already started ends with `result: "internal"` and `error_code: "email_quota_exceeded"`). Use `"throttle"` or `"digest"` for subscriptions that match many events.
* **Permanent failure (no retries; delivery moves to `dead`):** an address the email service refuses, such as one whose domain has no dot, returns HTTP `422` and pauses **only that `(subscription_id, sink_id)` lane** (`"destination_rejected"`).
* **How to resume:** set a valid `config.to` with [`sinks/update`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/sinks.md#update-a-sink), then call [`sinks/resume`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/sinks.md#resume-a-sink) with `mode: "drain"` (or `mode: "skip"` with `acknowledged_gap: true`).

### Duplicates

Every retry carries the delivery's `delivery_id`, and the email service queues one email per `delivery_id`. A retry after a lost response does not send a second email. A [`deliveries/resend`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/deliveries.md#resend-a-delivery) of a `succeeded` delivery creates a new `delivery_id` and a new email. To deduplicate emails in a mailbox parser, use the Event ID column.

### Test delivery

Calling [`sinks/test`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/sinks.md) with `{"sink_id": "<uuidv7>", "sample_type": "system.test"}` sends an email with the subject `Crypto Chief: event system.test (SYSTEM, confirmed)` (with `locale: "en"`). Event ID and the footer's `delivery_id` are the test `delivery_id`; Amount, From and To show `—`. A test email does not count toward the project email limits, but while the project is at a limit its attempt fails with `error_code: "email_quota_exceeded"` and is retried.

### What it costs

An email accepted for sending costs a channel fee of `10,000` credits (`$0.001`) on top of the base event fee. The fee is charged once per event email and once per digest email (each part), `reorged` emails and resends included. Failed attempts, throttled events, `sinks/test` and operational notification emails cost `0` credits; see [Billing](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/billing.md).

### Example

`request()` is defined in [Authentication](https://crypto-chief.gitbook.io/chief-event-stream/getting-started/authentication.md). Both `sinks/create` and `sinks/test` require an `Idempotency-Key`.

{% tabs %}
{% tab title="JavaScript" %}

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

const sink = await request(
  "sinks/create",
  {
    kind: "email",
    config: {
      to: "alerts@merchant.example",
      locale: "en",
      label: "Treasury email",
      rate_per_second: 5,
    },
  },
  crypto.randomUUID()
);

const test = await request(
  "sinks/test",
  {
    sink_id: sink.sink_id,
    sample_type: "system.test",
  },
  crypto.randomUUID()
);

console.log(sink.sink_id, test.delivery_id);
```

{% endtab %}

{% tab title="PHP" %}

```php
$sink = request(
    'sinks/create',
    [
        'kind' => 'email',
        'config' => [
            'to'              => 'alerts@merchant.example',
            'locale'          => 'en',
            'label'           => 'Treasury email',
            'rate_per_second' => 5,
        ],
    ],
    bin2hex(random_bytes(16))
);

$test = request(
    'sinks/test',
    [
        'sink_id'     => $sink['sink_id'],
        'sample_type' => 'system.test',
    ],
    bin2hex(random_bytes(16))
);

echo $sink['sink_id'] . ' ' . $test['delivery_id'] . "\n";
```

{% endtab %}

{% tab title="GO" %}

```go
sink, err := request("sinks/create", map[string]any{
	"kind": "email",
	"config": map[string]any{
		"to":              "alerts@merchant.example",
		"locale":          "en",
		"label":           "Treasury email",
		"rate_per_second": 5,
	},
}, rand.Text())
if err != nil {
	panic(err)
}

test, err := request("sinks/test", map[string]any{
	"sink_id":     sink["sink_id"],
	"sample_type": "system.test",
}, rand.Text())
if err != nil {
	panic(err)
}

fmt.Println(sink["sink_id"], test["delivery_id"])
```

{% endtab %}

{% tab title="Python" %}

```python
import secrets

sink = request(
    "sinks/create",
    {
        "kind": "email",
        "config": {
            "to": "alerts@merchant.example",
            "locale": "en",
            "label": "Treasury email",
            "rate_per_second": 5,
        },
    },
    secrets.token_hex(16),
)

test = request(
    "sinks/test",
    {
        "sink_id": sink["sink_id"],
        "sample_type": "system.test",
    },
    secrets.token_hex(16),
)

print(sink["sink_id"], test["delivery_id"])
```

{% endtab %}

{% tab title="curl" %}

```bash
sink=$(request sinks/create \
  '{"kind":"email","config":{"to":"alerts@merchant.example","locale":"en","label":"Treasury email","rate_per_second":5}}' \
  "$(openssl rand -hex 16)")

sink_id=$(jq -r '.sink_id' <<< "$sink")

request sinks/test \
  "{\"sink_id\":\"$sink_id\",\"sample_type\":\"system.test\"}" \
  "$(openssl rand -hex 16)"
```

{% endtab %}
{% endtabs %}
