# Receiving email

Mail sent to an address on one of your domains is kept, and your code can be told the moment it arrives.

## How mail arrives

Once the DNS records of a domain are published, mail to any address on it is taken by the sending platform and handed to the API. The API keeps it as a received email of the workspace that has the domain.

A received email has the sender, the address it was sent to, the subject, the text and the HTML, whether it was judged to be spam, and a list of its files.

> The files of a received email are listed by name, type and size. Their content is not kept.

## Read received mail

List what arrived, newest first, for every domain or for one.

cURL:

```bash
curl "$OPENSEND_API_URL/v1/inbound?domain=mail.example.com" \
  -H "Authorization: Bearer $OPENSEND_API_KEY"
```

TypeScript:

```ts
await opensend.inbound.list({
  domain: 'mail.example.com',
})
```

CLI:

```bash
opensend inbound list --domain mail.example.com
```

MCP:

```json
{
  "name": "inbound_list",
  "arguments": {
    "domain": "mail.example.com"
  }
}
```

Then read one in full.

cURL:

```bash
curl "$OPENSEND_API_URL/v1/inbound/in_01" \
  -H "Authorization: Bearer $OPENSEND_API_KEY"
```

TypeScript:

```ts
await opensend.inbound.get('in_01')
```

CLI:

```bash
opensend inbound get in_01
```

MCP:

```json
{
  "name": "inbound_get",
  "arguments": {
    "id": "in_01"
  }
}
```

inbound.get:

```json
{
  "object": "inbound_email",
  "id": "in_01",
  "from": "grace@customer.example",
  "fromName": "Grace Hopper",
  "to": "support@mail.example.com",
  "subject": "A question about my invoice",
  "domain": "mail.example.com",
  "spam": false,
  "size": 48920,
  "attachments": 1,
  "createdAt": "2026-11-27T09:30:00.000Z",
  "text": "Hello, could you send the invoice for November again? Thanks, Grace",
  "html": "<p>Hello, could you send the invoice for November again?</p><p>Thanks, Grace</p>",
  "truncated": false,
  "messageId": "<b7f1c2d4@mail.customer.example>",
  "files": [
    {
      "filename": "invoice-october.pdf",
      "mimeType": "application/pdf",
      "size": 41213
    }
  ]
}
```

Both need the scope `emails:read`. [The reference](https://opensend.sh/docs/api/inbound) lists every field.

## Be told when mail arrives

Add a [webhook](https://opensend.sh/docs/webhooks) for the event `email.received`. Its `data.id` is the id of the received email, so one request reads the rest.

```json
{
  "id": "evt_14",
  "type": "email.received",
  "createdAt": "2026-11-27T09:30:00.000Z",
  "data": {
    "id": "in_02",
    "from": "grace@customer.example",
    "to": "support@mail.example.com",
    "subject": "A question about my invoice"
  }
}
```
