# message.created.cleaned

Source: https://developer.nylas.com/docs/reference/notifications/messages/message-created-cleaned/

Sent when a new message is synced and the [Clean Conversations](/docs/v3/email/parse-messages/) feature is enabled for the application. The message `body` contains cleaned markdown content instead of the original HTML.

**Recommended action:** Process the cleaned message data. Subscribing to `message.created.cleaned` does not suppress `message.created` — if you subscribe to both, you'll receive two separate notifications per new message.

> Cleaned notifications can also have `.transformed` and `.truncated` suffixes (for example, `message.created.cleaned.transformed` or `message.created.cleaned.truncated`). When `cleaning_status` is `failed`, the `body` contains the original uncleaned HTML.

## data.object fields

- `id` (string) **(required)** - The Nylas message ID.
- `grant_id` (string) **(required)** - The grant ID that owns this message.
- `object` (string) **(required)** (message) - Always `message`.
- `thread_id` (string) - The thread this message belongs to.
- `subject` (string) - The message subject line.
- `from` (array) - Sender information.
  - `name` (string) - Display name of the sender.
  - `email` (string) - Email address of the sender.
- `to` (array) - Primary recipients.
  - `name` (string)
  - `email` (string)
- `cc` (array) - CC recipients.
  - `name` (string)
  - `email` (string)
- `bcc` (array) - BCC recipients.
  - `name` (string)
  - `email` (string)
- `reply_to` (array) - Reply-to addresses.
  - `name` (string)
  - `email` (string)
- `date` (integer) - Unix timestamp when the message was sent.
- `body` (string) - Cleaned markdown content of the message. Contains the original HTML when `cleaning_status` is `failed`.
- `snippet` (string) - A short plaintext preview of the message body.
- `starred` (boolean) - Whether the message is starred/flagged.
- `unread` (boolean) - Whether the message is unread.
- `folders` (array) - Folder names the message belongs to (e.g. `INBOX`, `SENT`).
- `attachments` (array) - Attachment metadata. Does not include file content.
  - `id` (string) - Attachment ID. Use with the [Attachments API](/docs/reference/api/attachments/) to download.
  - `filename` (string) - Original filename.
  - `content_type` (string) - MIME type.
  - `size` (integer) - Size in bytes.
  - `is_inline` (boolean) - Whether the attachment is an inline image.
  - `content_id` (string) - Content ID for inline attachments (used in HTML img tags). Only present for inline attachments.
  - `content_disposition` (string) - Content-Disposition header value.
- `metadata` (object) - Custom key-value metadata you attached when sending the message.
- `cleaning_status` (string) **(required)** (success, failed) - Whether cleaning succeeded. `failed` indicates cleaning failed after retries and `body` contains the original HTML.
- `cleaning_error` (string) - Description of the cleaning error. Only present when `cleaning_status` is `failed`.

## Example payload

```json
{
  "specversion": "1.0",
  "type": "message.created.cleaned",
  "source": "/google/emails/realtime",
  "id": "<WEBHOOK_ID>",
  "time": 1723821985,
  "webhook_delivery_attempt": 1,
  "data": {
    "application_id": "<NYLAS_APPLICATION_ID>",
    "object": {
      "attachments": [
        {
          "content_disposition": "attachment; filename=\"image.jpg\"",
          "content_id": "<CID>",
          "content_type": "image/jpeg; name=\"image.jpg\"",
          "filename": "image.jpg",
          "grant_id": "<NYLAS_GRANT_ID>",
          "id": "<ATTACHMENT_ID>",
          "is_inline": false,
          "size": 4860136
        }
      ],
      "bcc": [
        {
          "email": "leyah@example.com"
        }
      ],
      "body": "# Team Update\n\nHi everyone,\n\nHere are the key updates from this week:\n\n* Project Alpha launched successfully\n* New API endpoints are live in staging\n* Next sprint planning is on Monday\n\nLet me know if you have questions.",
      "cc": [
        {
          "email": "kaveh@example.com"
        }
      ],
      "cleaning_status": "success",
      "date": 1723821981,
      "folders": [
        "INBOX"
      ],
      "from": [
        {
          "email": "swag@example.com",
          "name": "Nylas Swag"
        }
      ],
      "grant_id": "<NYLAS_GRANT_ID>",
      "id": "<MESSAGE_ID>",
      "metadata": {
        "key1": "all-meetings",
        "key2": "on-site"
      },
      "object": "message",
      "reply_to": [],
      "snippet": "Hi everyone, Here are the key updates from this week.",
      "starred": false,
      "subject": "Team Update - Week of Aug 12",
      "thread_id": "<THREAD_ID>",
      "to": [
        {
          "email": "nyla@example.com"
        }
      ],
      "unread": true
    }
  }
}
```
