# Chat SDK Attachments

> Handle inbound email attachments in a conversational-email integration built on MailBlastr webhooks and the SDK.

When someone sends an email with file attachments, the inbound message you fetch via [Receiving](https://www.mailblastr.com/docs/receiving/attachments) exposes them as a list. Each attachment includes the filename, MIME type, and a way to download the content. In a Chat SDK adapter (see [Chat SDK](https://www.mailblastr.com/docs/ai/chat-sdk)) you surface these on the message you hand to your handler.

## Attachment shape

The shape below is what a custom adapter typically exposes; it mirrors the attachment metadata returned by the [Receiving attachments API](https://www.mailblastr.com/docs/receiving/attachments).

```ts
interface InboundAttachment {
  filename: string;
  contentType: string;
  url?: string;
}
```

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `filename` | string | No | Original filename, e.g. `invoice.pdf`. |
| `contentType` | string | No | MIME type, e.g. `application/pdf`. |
| `url` | string | No | Optional download URL for the attachment content. |

## Detecting and processing attachments

Read the attachment list off the inbound message (fetched with `mb.emails.receiving.get` in your webhook handler) and reply with the SDK.

```ts
async function onInbound(email) {
  const attachments = email.attachments ?? [];

  if (attachments.length === 0) {
    await reply(email.from, `Re: ${email.subject}`, 'Got your email — no attachments found.');
    return;
  }

  const summary = attachments
    .map((a) => `${a.filename} (${a.contentType})`)
    .join(', ');

  await reply(email.from, `Re: ${email.subject}`, `Received ${attachments.length} attachment(s): ${summary}`);
}
```

> **Note:** For the full inbound-attachment API — fetching content, size limits, and MIME handling — see [Receiving attachments](https://www.mailblastr.com/docs/receiving/attachments).
