> 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/slack.md). Agents can also search and read this documentation through its [MCP server](https://crypto-chief.gitbook.io/chief-event-stream/~gitbook/mcp).

# Slack

## Slack

A `slack` sink posts each matched event to a Slack channel through an Incoming Webhook (`https://hooks.slack.com/services/...`).

### Before you start

1. At `https://api.slack.com/apps`, create an app for your workspace (or open an existing one), turn on **Incoming Webhooks**, click **Add New Webhook to Workspace**, choose the channel, allow access, and copy the webhook URL (`https://hooks.slack.com/services/<T...>/<B...>/<secret>`).
2. Check the URL. EventStream accepts only `https://hooks.slack.com` on port `443` with three non-empty path segments after `/services/`, no percent-encoded path characters, no query string, and no `#` fragment (`422` `DESTINATION_FORBIDDEN` otherwise).

#### **Create a Slack 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     | Must be `"slack"`.                                                                                                                                                                                                                                                 |
| `config`                  | object  | true     | Configuration.                                                                                                                                                                                                                                                     |
| `config.format`           | string  | true     | Message layout; must be `"compact"`.                                                                                                                                                                                                                               |
| `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  | true     | Write-only; never returned. `credentials_meta.webhook_url.last4` in `sinks/get` is `null`.                                                                                                                                                                         |
| `credentials.webhook_url` | string  | true     | Slack Incoming Webhook URL (`^https://`, up to `2,048` characters, matching `https://hooks.slack.com/services/<part1>/<part2>/<part3>` without query or fragment).                                                                                                 |

```json
{
  "kind": "slack",
  "config": {
    "format": "compact",
    "label": "Treasury Slack channel",
    "rate_per_second": 5
  },
  "credentials": {
    "webhook_url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
  }
}
```

**Response**

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

```json
{
  "ok": true,
  "data": {
    "sink_id": "019a0000-0000-7000-8000-000000000001",
    "kind": "slack",
    "status": "active",
    "secret": null,
    "secret_version": 0,
    "config": {
      "format": "compact",
      "label": "Treasury Slack channel",
      "rate_per_second": 5
    }
  },
  "request_id": "019a0000-0000-7000-8000-000000000099"
}
```

{% endtab %}

{% tab title="422" %}

```json
{
  "ok": false,
  "error": "DESTINATION_FORBIDDEN",
  "msg": "destination is forbidden by egress policy",
  "request_id": "019a0000-0000-7000-8000-000000000099",
  "details": {
    "field": "credentials.webhook_url"
  }
}
```

{% 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 %}

### What arrives

EventStream sends `POST <credentials.webhook_url>` with `Content-Type: application/json; charset=utf-8` and `User-Agent: CryptoChief-EventStream/1`.

* **Payload structure:** the JSON body carries the message twice: in `text`, which Slack shows in desktop and mobile push notifications, and in one `section` block, `blocks[0]`, with `text.type: "mrkdwn"`. Lines follow the [message layout](https://crypto-chief.gitbook.io/chief-event-stream/sinks/overview.md#message-layout).
* **Escaping and broadcast neutralization:** control characters and Unicode bidirectional override characters are removed from field values; `\n` and `\t` inside values become spaces. `&`, `<`, and `>` are escaped as `&amp;`, `&lt;`, and `&gt;`, and backticks (`` ` ``) become `'`. In `@everyone`, `@here`, and `@channel` inside values, a zero-width space (`\u200b`) is inserted after `@`, so on-chain strings cannot trigger channel broadcasts.
* **Truncation:** if the text exceeds `3,000` characters, its end is replaced with `\n...\npayload_in_journal: true` and the `journal` line. Fetch the full event with [`events/get`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/events.md) by `event_id`.

Example Incoming Webhook request body for a confirmed `ETH_MAINNET` `USDC` `transfer.token` event:

```json
{
  "text": "[CryptoChief EventStream] transfer.token (confirmed)\nevent_id: 019a0000-0000-7000-8000-000000000011\nnetwork: ETH_MAINNET\nsubscription_id: 019a0000-0000-7000-8000-000000000003\nsequence: 42\noccurred_at: 2026-10-27T00:00:00.000Z\ntx_hash: 0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\ntransfer: 0x0000000000000000000000000000000000000002 -> 0x0000000000000000000000000000000000000001\namount: 125.5 USDC\ndata: amount={\"decimals\":6,\"raw\":\"125500000\",\"scale\":null}, asset={\"contract\":\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\"decimals\":6,\"id\":\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\"kind\":\"token\",\"standard\":\"erc20\",\"symbol\":\"USDC\",\"token_id\":null}, direction=in, from=0x0000000000000000000000000000000000000002, source={\"destination_tag\":null,\"kind\":\"log\",\"memo\":null,\"path\":\"log/7/erc20\",\"source_tag\":null,\"success\":true}, to=0x0000000000000000000000000000000000000001, utxo=null\njournal: https://app-data.crypto-chief.com/project/3f2a1b4c-5d6e-7f80-9a1b-2c3d4e5f6071/event-stream?event_id=019a0000-0000-7000-8000-000000000011",
  "blocks": [
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "[CryptoChief EventStream] transfer.token (confirmed)\nevent_id: 019a0000-0000-7000-8000-000000000011\nnetwork: ETH_MAINNET\nsubscription_id: 019a0000-0000-7000-8000-000000000003\nsequence: 42\noccurred_at: 2026-10-27T00:00:00.000Z\ntx_hash: 0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\ntransfer: 0x0000000000000000000000000000000000000002 -> 0x0000000000000000000000000000000000000001\namount: 125.5 USDC\ndata: amount={\"decimals\":6,\"raw\":\"125500000\",\"scale\":null}, asset={\"contract\":\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\"decimals\":6,\"id\":\"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\"kind\":\"token\",\"standard\":\"erc20\",\"symbol\":\"USDC\",\"token_id\":null}, direction=in, from=0x0000000000000000000000000000000000000002, source={\"destination_tag\":null,\"kind\":\"log\",\"memo\":null,\"path\":\"log/7/erc20\",\"source_tag\":null,\"success\":true}, to=0x0000000000000000000000000000000000000001, utxo=null\njournal: https://app-data.crypto-chief.com/project/3f2a1b4c-5d6e-7f80-9a1b-2c3d4e5f6071/event-stream?event_id=019a0000-0000-7000-8000-000000000011"
      }
    }
  ]
}
```

### Retries and errors

A delivery is acknowledged when Slack returns HTTP `200`–`299` and the response body is neither JSON `{"ok": false}` nor a Slack plain-text error starting with `invalid_`, `channel_`, or `no_`.

* **Retried (`transient`, up to `12` attempts over `24` hours):** network or timeout errors (`10`-second attempt limit) and HTTP `408`, `425`, `429`, `500`–`599`. See [Retries and Ordering](https://crypto-chief.gitbook.io/chief-event-stream/webhooks/retries-and-ordering.md).
* **`Retry-After`:** honored from the HTTP `Retry-After` header on `429` and `503` responses, clamped to `[1s, 21600s]`.
* **Permanent failures (no retries; delivery moves to `dead`):**
  * HTTP `401` or `403` (disabled or revoked webhook): pauses the **entire sink** with `pause_reason: "destination_auth"`.
  * HTTP `404` or `410` (deleted webhook or archived channel): pauses the **entire sink** with `pause_reason: "destination_gone"`.
  * HTTP `400` or `422`: pauses **only that `(subscription_id, sink_id)` lane** (`"destination_rejected"`), unless aggregate failures trigger whole-sink `"failures"`.
  * HTTP `300`–`399` or HTTP `200` with `{"ok": false}` or body prefix `invalid_`, `channel_`, or `no_`: pauses the **entire sink** with `pause_reason: "destination_rejected"`.
* **How to resume:** set a new `webhook_url` with [`sinks/update`](https://crypto-chief.gitbook.io/chief-event-stream/api-reference/sinks.md#update-a-sink) if needed, 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

Slack Incoming Webhooks have no idempotency header. If an attempt times out after Slack posts the message, the retry posts it again. A Slack app or workflow that reads the channel should deduplicate by the `event_id: <uuidv7>` line in `text`.

### 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"}` posts a `section` block (and `text`) with `network: SYSTEM`, `stage: confirmed`, `message: EventStream test`, and `event_id` set to the test `delivery_id`:

```
[CryptoChief EventStream] system.test (confirmed)
event_id: 019a0000-0000-7000-8000-000000000002
network: SYSTEM
occurred_at: 2026-10-27T00:00:00.000Z
message: EventStream test
data: generated_at=2026-10-27T00:00:00.000Z, message=EventStream test, sink_id=019a0000-0000-7000-8000-000000000001
journal: https://app-data.crypto-chief.com/project/3f2a1b4c-5d6e-7f80-9a1b-2c3d4e5f6071/event-stream?event_id=019a0000-0000-7000-8000-000000000002
```

### What it costs

An acknowledged Slack message costs a channel fee of `1,000` credits (`$0.0001`) on top of the base event fee. Failed attempts, throttled events and `sinks/test` 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: "slack",
    config: {
      format: "compact",
      label: "Treasury Slack channel",
      rate_per_second: 5,
    },
    credentials: {
      webhook_url:
        "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
    },
  },
  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' => 'slack',
        'config' => [
            'format'          => 'compact',
            'label'           => 'Treasury Slack channel',
            'rate_per_second' => 5,
        ],
        'credentials' => [
            'webhook_url' => 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
        ],
    ],
    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": "slack",
	"config": map[string]any{
		"format":          "compact",
		"label":           "Treasury Slack channel",
		"rate_per_second": 5,
	},
	"credentials": map[string]any{
		"webhook_url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
	},
}, 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": "slack",
        "config": {
            "format": "compact",
            "label": "Treasury Slack channel",
            "rate_per_second": 5,
        },
        "credentials": {
            "webhook_url": "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX",
        },
    },
    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":"slack","config":{"format":"compact","label":"Treasury Slack channel","rate_per_second":5},"credentials":{"webhook_url":"https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"}}' \
  "$(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 %}
