# Notifications

> Source: https://truto.one/docs/guides/observability/notifications/

Add a notification destination and Truto posts to a Slack channel or sends email when your API traffic starts failing, an API token expires or goes stale, integrated accounts are paused for needing reauthentication, a webhook is deactivated, or the monthly usage report is ready.

:::skip-reading{cli="truto notification-destinations list" skill="truto"}
:::

## Before you start

- **One environment per destination.** A destination belongs to one environment and is notified about that environment only. With an API token, the destination is created in the token's environment.
- **Slack.** Create a Slack [incoming webhook](https://slack.com/marketplace/A0F7XDUAZ-incoming-webhooks) for the channel you want alerts in and copy its URL.

## 1. Add a destination

### From the dashboard

1. Open **Settings → Notifications** (`app.truto.one/settings/notifications`) and pick the environment.
2. Click **Add Destination**.
3. Fill in the modal:
   - **Label** — a name for the destination, for example `Engineering alerts`.
   - **Type** — **Slack** or **Email**. The type can't be changed after the destination is created.
   - For Slack: **Webhook URL**, and optionally **Ignored Status Codes** (see [API errors](#event-types)).
   - For email: **To**, and optionally **CC**, **BCC**, and **Subject Prefix**. Separate addresses with commas.
   - **Active** — whether the destination receives notifications.
   - **Event Types** — which events to receive. **All events** is checked by default.
4. Click **Create**.

### From the API

`POST /notification-destination` creates a destination.

| Field | Type | Meaning |
| --- | --- | --- |
| `type` | string | `slack` or `email`. Required. |
| `config` | object | The type's settings. Required. See below. |
| `label` | string | Name for the destination. |
| `event_types` | string[] | Events to receive. Omitted or empty means `["all"]`. See [Event types](#event-types). |
| `is_active` | boolean | Whether the destination receives notifications. Defaults to `true`. |

**Slack `config`**

| Field | Required | Meaning |
| --- | --- | --- |
| `webhook_url` | Yes | The Slack incoming webhook URL. Write-only: reads return `********`. |
| `ignored_status_codes` | No | HTTP status codes (`400`–`599`) to leave out of [API errors](#event-types) digests, for example `[401, 404]`. |

**Email `config`**

| Field | Required | Meaning |
| --- | --- | --- |
| `to` | Yes | Recipient addresses. |
| `cc` | No | CC addresses. |
| `bcc` | No | BCC addresses. |
| `subject_prefix` | No | Put in front of every subject line. Defaults to `[Truto]`. |

:::code-tabs

```bash label="cURL"
curl -X POST https://api.truto.one/notification-destination \
  -H "Authorization: Bearer <API token>" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "slack",
    "label": "Engineering alerts",
    "config": {
      "webhook_url": "https://hooks.slack.com/services/T000/B000/XXXX",
      "ignored_status_codes": [401, 404]
    },
    "event_types": ["api_errors", "api_token_events"]
  }'
```

```bash label="CLI"
truto notification-destinations create --body '{
  "type": "slack",
  "label": "Engineering alerts",
  "config": {
    "webhook_url": "https://hooks.slack.com/services/T000/B000/XXXX",
    "ignored_status_codes": [401, 404]
  },
  "event_types": ["api_errors", "api_token_events"]
}'
```

```typescript label="TypeScript"
const response = await fetch('https://api.truto.one/notification-destination', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.TRUTO_API_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'slack',
    label: 'Engineering alerts',
    config: {
      webhook_url: 'https://hooks.slack.com/services/T000/B000/XXXX',
      ignored_status_codes: [401, 404],
    },
    event_types: ['api_errors', 'api_token_events'],
  }),
})
const destination = await response.json()
console.log(destination.id)
```

```python label="Python"
import os
import requests

response = requests.post(
    "https://api.truto.one/notification-destination",
    headers={"Authorization": f"Bearer {os.environ['TRUTO_API_TOKEN']}"},
    json={
        "type": "slack",
        "label": "Engineering alerts",
        "config": {
            "webhook_url": "https://hooks.slack.com/services/T000/B000/XXXX",
            "ignored_status_codes": [401, 404],
        },
        "event_types": ["api_errors", "api_token_events"],
    },
)
print(response.json()["id"])
```

:::

```json
{
  "id": "3b7e2c1a-9f4d-4e8b-a2c6-1d5f7e9a0b34",
  "type": "slack",
  "label": "Engineering alerts",
  "config": {
    "webhook_url": "********",
    "ignored_status_codes": [401, 404]
  },
  "is_active": true,
  "environment_id": "ac15abdc-b38e-47d0-97a2-69194017c199",
  "event_types": ["api_errors", "api_token_events"],
  "created_at": "2026-11-02T10:20:11.000Z",
  "updated_at": "2026-11-02T10:20:11.000Z"
}
```

An email destination looks like this:

```json
{
  "type": "email",
  "label": "On-call inbox",
  "config": {
    "to": ["oncall@example.com"],
    "cc": ["platform@example.com"],
    "subject_prefix": "[Truto prod]"
  },
  "event_types": ["all"]
}
```

## 2. Send a test notification

`POST /notification-destination/test` sends a test message to one destination, whatever event types it subscribes to. In the dashboard, open the destination's menu and click **Send test notification**.

:::code-tabs

```bash label="cURL"
curl -X POST https://api.truto.one/notification-destination/test \
  -H "Authorization: Bearer <API token>" \
  -H "Content-Type: application/json" \
  -d '{ "id": "<destination_id>" }'
```

```bash label="CLI"
truto notification-destinations test --id <destination_id>
```

```typescript label="TypeScript"
const response = await fetch('https://api.truto.one/notification-destination/test', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.TRUTO_API_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ id: '<destination_id>' }),
})
console.log(response.status, await response.json())
```

```python label="Python"
import os
import requests

response = requests.post(
    "https://api.truto.one/notification-destination/test",
    headers={"Authorization": f"Bearer {os.environ['TRUTO_API_TOKEN']}"},
    json={"id": "<destination_id>"},
)
print(response.status_code, response.json())
```

:::

Truto sends the test right away and waits for the answer. The endpoint returns `{"success": true}` when Slack or the mail service accepted the message, and `502` when it refused it. For Slack the error carries Slack's status and reply, for example `Slack API returned 404: no_service`. For email it reads `The test email could not be delivered. Check the recipient addresses and try again.` The test is sent even if the destination is inactive. In Slack the message reads `Event: test` with the environment ID and time. By email the subject is `[Truto] Test Notification`, or your prefix in place of `[Truto]`.

## Event types

| Value | Dashboard label | When it's sent |
| --- | --- | --- |
| `all` | All events | Every event below. |
| `api_errors` | API errors | A digest of the environment's failed requests from the past 24 hours: Truto API responses with a `4xx` or `5xx` status (except `429`) and sync job run errors, grouped by integrated account, integration and status code, up to 200 rows. A pair of account and status code that was already reported in the last 48 hours is left out, and if that leaves nothing, no digest is sent. When there were no errors at all, the digest says so. |
| `api_token_events` | API token events | An API token in the environment expired and was deleted; the message names the token, the environment and who created it. Also, once a day at 09:00 UTC, a digest of up to 100 active tokens not used in the last 30 days, including tokens older than 30 days that were never used. Each token is listed at most once a week. The digest links to **Settings → API Tokens** to review them. |
| `api_usage` | API usage report | Monthly, on the 1st: the environment's API calls for the previous calendar month, with the top integrated accounts, integrations and tenants. Not sent for a month with no calls. |
| `integrated_account_events` | Integrated account events | Integrated accounts in the environment became [stale](/docs/guides/integrated-accounts/stale-accounts): they stayed `needs_reauth`, with no change, for 7 days, so Truto paused them. At most one message a day per environment, listing up to 100 of the accounts, with a link to the environment's account list filtered to stale accounts. Once deletion of stale accounts is on, also the reminders 15 and 7 days before an account is deleted. |
| `webhook_deactivated` | Webhook deactivated | Truto deactivated one of your webhooks. The message names the webhook ID, target URL, environment and event types. |

`ignored_status_codes` applies to the `api_errors` digest. The codes from every Slack destination subscribed to API errors in the environment are combined, so ignoring a code on one destination removes it from the environment's digest for all of them.

:::callout{type="info"}
When someone joins your team as an admin, or is made an admin, Truto subscribes them to `api_token_events` by email in every environment whose name contains `production`. It creates one email destination per admin and environment, labelled `auto:api-token-alerts:<user id>`. Edit or delete it like any other destination.

Truto creates them only for the production environments that exist at that moment. It doesn't remove them when the person leaves the team or stops being an admin: delete that person's `auto:api-token-alerts:<user id>` destinations yourself.
:::

## Changing a destination

`PATCH /notification-destination/:id` updates a destination. `DELETE /notification-destination/:id` deletes it. `GET /notification-destination` lists the environment's destinations and `GET /notification-destination/:id` reads one.

- `config` replaces the stored config, except the secret fields: a Slack `webhook_url`, or email `to`, `cc` and `bcc`. A secret you leave out, or send back as `********`, is kept. Send `null` to clear one.
- `event_types` replaces the subscribed list when it has at least one entry. An empty list leaves the subscriptions unchanged; send `["all"]` to receive everything again.
- `is_active: false` pauses the destination without deleting it.

:::code-tabs

```bash label="cURL"
curl -X PATCH https://api.truto.one/notification-destination/<destination_id> \
  -H "Authorization: Bearer <API token>" \
  -H "Content-Type: application/json" \
  -d '{ "event_types": ["all"], "config": { "ignored_status_codes": [] } }'
```

```bash label="CLI"
truto notification-destinations update <destination_id> \
  --body '{"event_types":["all"],"config":{"ignored_status_codes":[]}}'
```

```typescript label="TypeScript"
await fetch('https://api.truto.one/notification-destination/<destination_id>', {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.TRUTO_API_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ event_types: ['all'], config: { ignored_status_codes: [] } }),
})
```

```python label="Python"
import os
import requests

requests.patch(
    "https://api.truto.one/notification-destination/<destination_id>",
    headers={"Authorization": f"Bearer {os.environ['TRUTO_API_TOKEN']}"},
    json={"event_types": ["all"], "config": {"ignored_status_codes": []}},
)
```

:::

## Next

Notifications summarise; for every individual request and sync job event, stream the raw logs to Datadog, Splunk or another tool with [Log forwarding](/docs/guides/observability/log-forwarding). To be told about events in your own app rather than in Slack, use [webhooks](/docs/guides/webhooks/creating-a-webhook-through-api).
