# Email

Each VM has an email address; a message wakes the VM and lands in an inbox on its disk, with an optional webhook and Telegram bot.

Source: https://slashinfra.com/docs/platform/email
Last modified: 2026-11-30T16:36:19.000Z

Each VM has its own email address. A message to an enabled inbox wakes the VM and is saved on its disk; the inbox can also post each message to a webhook or take messages from a Telegram bot.

The inbox is off by default. The samples use a VM named `support`; [VMs](https://slashinfra.com/docs/platform/vms) shows how to create it.

## Enable the inbox

Enabling accepts mail at the VM’s address. Turning it on needs a plan with `inbox_allowed`, and mail to a disabled inbox is rejected at SMTP and wakes nothing.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Select Enable inbox. The badge changes to `enabled`.

### CLI

```bash
si svm inbox enable support
```

Output

```text
inbox enabled: 6f1c0f0e8a@slashinfra.dev
```

### curl

```bash
curl -sS -X PUT "https://api.slashinfra.com/svms/support/inbox" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"enabled":true}'
```

Output

```text
{"enabled":true,"address":"6f1c0f0e8a@slashinfra.dev","allowed_senders":null,"webhook_url":null,"telegram":{"connected":false,"bot_username":null,"allowed_users":[],"pair_code":null,"pair_expires_ms":null}}
```

### Python

```python
import os, requests

res = requests.put(
"https://api.slashinfra.com/svms/support/inbox",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"enabled": True},
)
res.raise_for_status()
print(res.json()["address"])
```

Output

```text
6f1c0f0e8a@slashinfra.dev
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/support/inbox', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ enabled: true }),
})
if (!res.ok) throw new Error(await res.text())
const inbox = (await res.json()) as { address: string }
console.log(inbox.address)
```

Output

```text
6f1c0f0e8a@slashinfra.dev
```

## Show the inbox

The answer holds the state of the inbox: whether it accepts mail, its address, the sender rule, the webhook and the Telegram bot. `webhook_secret` appears only in the answer that sets or rotates the webhook.

Send mail to the address from any mail account, subject to the sender rule. The address uses the VM id, so renaming the VM does not change it. A `+tag` after the id is accepted and stored with the message.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Read the address in Address. 
- Select Copy to copy it.

### CLI

```bash
si svm inbox support
```

Output

```text
address:  6f1c0f0e8a@slashinfra.dev
enabled:  yes
senders:  any
webhook:  -
```

### curl

```bash
curl -sS "https://api.slashinfra.com/svms/support/inbox" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
{"enabled":true,"address":"6f1c0f0e8a@slashinfra.dev","allowed_senders":null,"webhook_url":null,"telegram":{"connected":false,"bot_username":null,"allowed_users":[],"pair_code":null,"pair_expires_ms":null}}
```

### Python

```python
import os, requests

res = requests.get(
"https://api.slashinfra.com/svms/support/inbox",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
inbox = res.json()
print(inbox["address"], inbox["enabled"])
```

Output

```text
6f1c0f0e8a@slashinfra.dev True
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/support/inbox', {
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
const inbox = (await res.json()) as { address: string; enabled: boolean }
console.log(inbox.address, inbox.enabled)
```

Output

```text
6f1c0f0e8a@slashinfra.dev true
```

## Read a message on the VM

Delivery wakes a sleeping VM and writes the message into `~/inbox` (`/home/user/inbox`). Each message is one row of `~/inbox/inbox.db`, a SQLite database. The raw object is `~/inbox/raw/<id>.eml` for mail and `~/inbox/raw/<id>.json` for Telegram; attachments are in `~/inbox/files/<id>/`, named `<n>-<name>`.

`inbox ls` lists messages newest first. An unread row has `*` in `NEW`; add `--unread` to keep only unread ones. `inbox read <id>` prints one message, and `inbox mark-read <id>` marks it read. `inbox search <words>` matches every word in the sender, sender name, subject, tag and text. An id may be any unique start, in any case.

`inbox ls --json` prints an array with `id`, `channel`, `received_at`, `sender`, `sender_name`, `subject`, `tag`, `recipients`, `attachments` and `read_at`. A program can parse that or open the SQLite database. Each attachment has `name`, `type`, `size` and `path`. Only a Telegram message can be answered: `inbox reply <id> --text` or `--file` sends to its chat, and there is no way to send new mail.

Messages stay on the disk until you delete the VM. From your laptop, `si exec support -- inbox ls` runs the same command in `support`.

## Choose who can write

`allowed_senders` is the sender rule for new mail. The default is `null`, so any sender can mail an enabled inbox. An empty list accepts none, and a list accepts exactly those SMTP envelope addresses. The rule matches the envelope sender, not the display name, and has no domain wildcards. `--none` refuses every sender, and `--allow` names one address and can repeat. A change applies to new mail only.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Choose Only these addresses under Who can write. 
- Enter `ada@example.com` in Addresses. 
- Select Save.

### CLI

```bash
si svm inbox senders --allow ada@example.com support
```

Output

```text
senders:  ada@example.com
```

### curl

```bash
curl -sS -X PUT "https://api.slashinfra.com/svms/support/inbox" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"enabled":true,"allowed_senders":["ada@example.com"]}'
```

Output

```text
{"enabled":true,"address":"6f1c0f0e8a@slashinfra.dev","allowed_senders":["ada@example.com"],"webhook_url":null,"telegram":{"connected":false,"bot_username":null,"allowed_users":[],"pair_code":null,"pair_expires_ms":null}}
```

### Python

```python
import os, requests

res = requests.put(
"https://api.slashinfra.com/svms/support/inbox",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"enabled": True, "allowed_senders": ["ada@example.com"]},
)
res.raise_for_status()
print(res.json()["allowed_senders"])
```

Output

```text
['ada@example.com']
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/support/inbox', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ enabled: true, allowed_senders: ['ada@example.com'] }),
})
if (!res.ok) throw new Error(await res.text())
const inbox = (await res.json()) as { allowed_senders: string[] | null }
console.log(inbox.allowed_senders)
```

Output

```text
[ "ada@example.com" ]
```

## Set a webhook

A webhook receives one signed POST per message. The URL must use `https`. A new or changed URL returns `webhook_secret` once; the old secret stops verifying signatures. Removing the webhook with `si svm inbox webhook --remove` stops the POSTs and deletes the secret.

Your endpoint must answer a 2xx status. Any other answer, or no answer, is retried up to 10 times: first after 10 seconds, then with the wait doubling to at most 5 minutes, about 30 minutes in all. After the last attempt the POST is dropped; the message stays in the VM’s inbox.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Enter `https://example.com/hook` in Webhook URL. 
- Select Save. 
- Select Copy under Webhook secret and store it.

### CLI

```bash
si svm inbox webhook support https://example.com/hook
```

Output

```text
webhook: https://example.com/hook
secret:  whsec_... (shown once; store it now)
```

### curl

```bash
curl -sS -X PUT "https://api.slashinfra.com/svms/support/inbox" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"enabled":true,"webhook_url":"https://example.com/hook"}'
```

Output

```text
{"enabled":true,"address":"6f1c0f0e8a@slashinfra.dev","allowed_senders":["ada@example.com"],"webhook_url":"https://example.com/hook","telegram":{"connected":false,"bot_username":null,"allowed_users":[],"pair_code":null,"pair_expires_ms":null},"webhook_secret":"whsec_..."}
```

### Python

```python
import os, requests

res = requests.put(
"https://api.slashinfra.com/svms/support/inbox",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"enabled": True, "webhook_url": "https://example.com/hook"},
)
res.raise_for_status()
print(res.json()["webhook_secret"])
```

Output

```text
whsec_...
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/support/inbox', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ enabled: true, webhook_url: 'https://example.com/hook' }),
})
if (!res.ok) throw new Error(await res.text())
const inbox = (await res.json()) as { webhook_secret: string }
console.log(inbox.webhook_secret)
```

Output

```text
whsec_...
```

## Verify a webhook delivery

Each POST carries an `X-Slashinfra-Signature` header of the form `t=<unix seconds>,v1=<hex>`. `v1` is the hex HMAC-SHA256 of the timestamp, a dot and the raw request body, keyed with the webhook secret. Compute it over the raw request body before you parse the JSON, and compare the two values.

Reject a delivery whose timestamp is more than five minutes old, so a captured request cannot be sent again later. Compare in constant time.

### Python

```python
import hashlib, hmac, time

def verify(secret: str, header: str, body: bytes) -> bool:
parts = dict(part.split("=", 1) for part in header.split(","))
timestamp, signature = parts["t"], parts["v1"]
if abs(time.time() - int(timestamp)) > 300:
return False
expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
```

### TypeScript

```ts
import { createHmac, timingSafeEqual } from 'node:crypto'

export function verify(secret: string, header: string, body: string): boolean {
const parts = Object.fromEntries(header.split(',').map((part) => part.split('=', 2) as [string, string]))
const timestamp = parts.t ?? ''
const signature = parts.v1 ?? ''
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false
const expected = createHmac('sha256', secret).update(`${timestamp}.${body}`).digest('hex')
return expected.length === signature.length && timingSafeEqual(Buffer.from(expected), Buffer.from(signature))
}
```

Pass the body exactly as it arrived: in a web framework, read the raw bytes, not the parsed JSON.

The body is JSON. `event` is `message.received`, `machine` is the VM id, `message` is the envelope and `raw_url` serves the raw message for one hour. The envelope holds its `channel`, sender, recipients, subject, text, HTML, attachments and the SPF, DKIM and DMARC results, among other fields.

## Rotate the webhook secret

Rotate makes a new secret for the current webhook and returns it once. The old secret stops verifying `X-Slashinfra-Signature` on every later POST. A webhook must be set first, or the call answers 409 `no_webhook`.

### curl

```bash
curl -sS -X POST "https://api.slashinfra.com/svms/support/inbox/webhook/rotate" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
{"enabled":true,"address":"6f1c0f0e8a@slashinfra.dev","allowed_senders":["ada@example.com"],"webhook_url":"https://example.com/hook","telegram":{"connected":false,"bot_username":null,"allowed_users":[],"pair_code":null,"pair_expires_ms":null},"webhook_secret":"whsec_..."}
```

### Python

```python
import os, requests

res = requests.post(
"https://api.slashinfra.com/svms/support/inbox/webhook/rotate",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
print(res.json()["webhook_secret"])
```

Output

```text
whsec_...
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/support/inbox/webhook/rotate', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
const inbox = (await res.json()) as { webhook_secret: string }
console.log(inbox.webhook_secret)
```

Output

```text
whsec_...
```

## Connect a Telegram bot

A Telegram bot sends its chats to the same inbox. Connecting checks the token with Telegram, stores it in the vault and registers the bot’s webhook; no answer returns the token. The inbox must be on and the plan must allow inboxes. The answer holds `bot_username` and a `pair_code`.

Run `si svm inbox telegram support connect`; it reads the token from standard input or `--token-file`, never from an argument. The control call is [`PUT /svms/{ref}/inbox/telegram`](https://slashinfra.com/docs/api-reference/control/inbox#putSvmsByRefInboxTelegram) with `bot_token`.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Enter the token from BotFather in Bot token. 
- Select Save. The bot username and a pairing code appear.

## Pair a Telegram user

A pairing code is single-use and valid for ten minutes. The user sends `/start <code>` to the bot; that Telegram user joins `allowed_users`, and the bot answers `paired`.

Run `si svm inbox telegram support pair` or [`POST /svms/{ref}/inbox/telegram/pair`](https://slashinfra.com/docs/api-reference/control/inbox#postSvmsByRefInboxTelegramPair) for a new code; it replaces the live one. Without a bot the call answers 409 `not_connected`.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Select New pair code. 
- Send `/start` and the code to the bot from the Telegram account.

## Set the Telegram users

`allowed_users` holds the numeric Telegram user ids whose messages reach the inbox. It replaces the stored list whole and drops duplicates. An empty list accepts none, and a paired user is added automatically.

`si svm inbox telegram support users <id>...` takes the ids as arguments; [`PUT /svms/{ref}/inbox/telegram/users`](https://slashinfra.com/docs/api-reference/control/inbox#putSvmsByRefInboxTelegramUsers) takes `allowed_users`. Without a bot the call answers 409 `not_connected`.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Enter the ids in Allowed user ids, one per line. 
- Select Save.

## Disconnect the bot

Disconnect removes the bot, its webhook, its token and its injection rule, and stops Telegram messages. It keeps the other inbox settings and the messages already on the disk.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Select Disconnect. The bot stays for 5 seconds, and Undo keeps it.

### CLI

```bash
si svm inbox telegram support disconnect
```

Output

```text
telegram disconnected
```

### curl

```bash
curl -sS -i -X DELETE "https://api.slashinfra.com/svms/support/inbox/telegram" \
-H "Authorization: Bearer $SI_API_KEY"
```

Output

```text
HTTP/2 204
...
```

### Python

```python
import os, requests

res = requests.delete(
"https://api.slashinfra.com/svms/support/inbox/telegram",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
)
res.raise_for_status()
print(res.status_code)
```

Output

```text
204
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/support/inbox/telegram', {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.SI_API_KEY!}` },
})
if (!res.ok) throw new Error(await res.text())
console.log(res.status)
```

Output

```text
204
```

## Disable the inbox

Disabling rejects new mail at SMTP and wakes nothing. It keeps the sender rule, the webhook and every message already on the disk, so enabling again restores them.

### Dashboard

- Open [SVMs](https://app.slashinfra.com/svms) and select `support`. 
- Select the Inbox tab. 
- Select Disable inbox. The badge changes to `disabled`.

### CLI

```bash
si svm inbox disable support
```

Output

```text
inbox disabled; mail to 6f1c0f0e8a@slashinfra.dev is rejected
```

### curl

```bash
curl -sS -X PUT "https://api.slashinfra.com/svms/support/inbox" \
-H "Authorization: Bearer $SI_API_KEY" -H "Content-Type: application/json" \
-d '{"enabled":false}'
```

Output

```text
{"enabled":false,"address":"6f1c0f0e8a@slashinfra.dev","allowed_senders":["ada@example.com"],"webhook_url":"https://example.com/hook","telegram":{"connected":false,"bot_username":null,"allowed_users":[],"pair_code":null,"pair_expires_ms":null}}
```

### Python

```python
import os, requests

res = requests.put(
"https://api.slashinfra.com/svms/support/inbox",
headers={"Authorization": f"Bearer {os.environ['SI_API_KEY']}"},
json={"enabled": False},
)
res.raise_for_status()
print(res.json()["enabled"])
```

Output

```text
False
```

### TypeScript

```ts
const res = await fetch('https://api.slashinfra.com/svms/support/inbox', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.SI_API_KEY!}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ enabled: false }),
})
if (!res.ok) throw new Error(await res.text())
const inbox = (await res.json()) as { enabled: boolean }
console.log(inbox.enabled)
```

Output

```text
false
```

## Options

`enabled` is required on the inbox call, and `bot_token` and `allowed_users` are required on their calls. The other fields keep their value when you omit them.

| Field | Type | Default | Allowed values | What it changes |
| --- | --- | --- | --- | --- |   
| `enabled` | boolean | Required | `true` or `false` | Whether the inbox accepts mail. The CLI turns it on with `si svm inbox enable` and off with `si svm inbox disable`. | 
| `allowed_senders` (`--allow`, `--none`) | array of strings or null | `null` | `null` for any sender, `[]` for none, or exact addresses such as `ada@example.com`; each at most 254 characters | The rule for new mail. Omit it to keep the current rule. Stored entries are trimmed, lowercased and deduplicated, and match the SMTP envelope sender. | 
| `webhook_url` (`[URL]`, `--remove`) | string or null | `null` | An `https://` URL; `null` removes it | Each message is POSTed to it. Omit it to keep the current webhook; a new or changed URL returns a new `webhook_secret` once. | 
| `bot_token` (`--token-file`) | string | Required for connect | The token from BotFather | Checks the bot with Telegram, stores the token in the vault and registers its webhook. The token is never returned. | 
| `allowed_users` (`[ID]...`) | array of strings | Required for users | Numeric Telegram user ids; `[]` accepts none | Replaces the stored list whole and drops duplicates. It is empty until the first pair, and a paired user is added automatically. | 
| `project` (`--project`) | string | `default` | A project name, or its `proj_` id | The project that holds the VM. | 
| `ref` (`<SVM>`) | string | Required | A VM name, or its 10-symbol id | The VM whose inbox the operation acts on. |

## States

| State | What it means for you | What you can do |
| --- | --- | --- |   
| `enabled` | Mail from an allowed sender is accepted, wakes the VM and is saved. A webhook, if set, receives each message. | Change the rule or webhook, connect Telegram, disable the inbox. | 
| `disabled` | Mail is rejected at SMTP and wakes nothing. Messages already saved stay on the disk, and the rule and webhook stay. | Enable the inbox. The API and CLI can change the rule and webhook while it is off. |

## Errors

| Code | When | Fix |
| --- | --- | --- |   
| [`invalid_webhook`](https://slashinfra.com/docs/reference/errors#invalid_webhook) | Set a webhook sends a URL that is not `https`. | Use an `https://` URL that is publicly reachable. | 
| [`invalid_sender`](https://slashinfra.com/docs/reference/errors#invalid_sender) | Set the sender rule sends a value that is not one exact address. | Use full email addresses, one exact address per entry. | 
| [`inbox_not_allowed`](https://slashinfra.com/docs/reference/errors#inbox_not_allowed) | Enable the inbox or connect Telegram on a plan without inboxes. | Ask your administrator about the plan. | 
| [`inbox_disabled`](https://slashinfra.com/docs/reference/errors#inbox_disabled) | Connect Telegram while the inbox is off. | Enable the inbox first. | 
| [`invalid_bot_token`](https://slashinfra.com/docs/reference/errors#invalid_bot_token) | Connect sends a token that Telegram refuses. | Use the token from BotFather. | 
| [`not_connected`](https://slashinfra.com/docs/reference/errors#not_connected) | Pair a user or set the users with no bot connected. | Connect a bot first. | 
| [`invalid_user`](https://slashinfra.com/docs/reference/errors#invalid_user) | Set the Telegram users sends a value that is not numeric. | Use numeric Telegram user ids. | 
| [`no_webhook`](https://slashinfra.com/docs/reference/errors#no_webhook) | Rotate runs before a webhook is set. | Set a webhook first. | 
| [`telegram_unavailable`](https://slashinfra.com/docs/reference/errors#telegram_unavailable) | Telegram does not answer the connect call. | Try again. |

Errors that any request can return are in the [error catalog](https://slashinfra.com/docs/reference/errors).

## Permissions

| Operation | Who can | Key action |
| --- | --- | --- |   
| Show the inbox | Any member | `svm:read` | 
| Enable or disable the inbox | Any member | `svm:write` | 
| Change the sender rule | Any member | `svm:write` | 
| Set or remove the webhook | Any member | `svm:write` | 
| Rotate the webhook secret | Any member | `svm:write` | 
| Connect a Telegram bot | Any member | `svm:write` | 
| Pair a Telegram user | Any member | `svm:write` | 
| Set the Telegram users | Any member | `svm:write` | 
| Disconnect the bot | Any member | `svm:write` |

## Limits

- Both plans include inboxes (`inbox_allowed`). A plan without it answers 403 `inbox_not_allowed` when you enable. 
- An email has a maximum of 25 MiB, attachments included. A larger message is rejected at SMTP. 
- For mail, the inbox stores three authentication results, SPF, DKIM and DMARC, but does not filter on them. The sender rule is the only mail sender filter. 
- One webhook per inbox. Its `raw_url` serves the raw message for one hour. 
- One Telegram bot per inbox. A pairing code is single-use and expires after ten minutes. 
- One sender rule entry is one exact SMTP envelope address, lowercased and deduplicated; there are no domain wildcards. 
- Each VM has one address, `<id>@slashinfra.dev`, and it does not change when you rename the VM. Messages stay on the disk until you delete the VM.

The full list is in [Limits](https://slashinfra.com/docs/reference/limits).

## Next

- [Wake an agent with a message](https://slashinfra.com/docs/agents/triggers): an email starts an agent that was asleep. 
- [Schedules](https://slashinfra.com/docs/platform/schedules): deliver a message to this inbox at a set time. 
- [Sleep and wake](https://slashinfra.com/docs/how/sleep-and-wake): what wakes a VM and what it keeps.
