# message.created

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

Sent when a new message arrives or is synced for a user.

**Recommended action:** Process the message data. If your webhook has [field customization](/docs/v3/notifications/#specify-fields-for-webhook-notifications) enabled, the type will be `message.created.transformed`.

> Payloads exceeding 1 MB are truncated: the type becomes `message.created.truncated` and the `body` field is removed. Re-query the [Messages API](/docs/reference/api/messages/get-messages-id/) to get the full message. If you have [field customization](/docs/v3/notifications/#specify-fields-for-webhook-notifications) enabled, the type will be `message.created.transformed`.

## 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) - The HTML body of the message. Omitted in truncated notifications.
- `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.

## Example payload

```json
{
  "specversion": "1.0",
  "type": "message.created",
  "source": "/google/emails/realtime",
  "id": "<WEBHOOK_ID>",
  "time": 1723821985,
  "webhook_delivery_attempt": 1,
  "data": {
    "application_id": "<NYLAS_APPLICATION_ID>",
    "object": {
      "id": "<MESSAGE_ID>",
      "grant_id": "<NYLAS_GRANT_ID>",
      "object": "message",
      "thread_id": "<THREAD_ID>",
      "subject": "Let's send an attachment",
      "from": [
        {
          "email": "swag@example.com",
          "name": "Nylas Swag"
        }
      ],
      "to": [
        {
          "email": "nyla@example.com"
        }
      ],
      "cc": [
        {
          "email": "kaveh@example.com"
        }
      ],
      "bcc": [
        {
          "email": "leyah@example.com"
        }
      ],
      "reply_to": [],
      "date": 1723821981,
      "body": "<div dir=\"ltr\">Test with attachments</div>\r\n",
      "snippet": "This message has an attachment.",
      "starred": false,
      "unread": false,
      "folders": [
        "SENT"
      ],
      "attachments": [
        {
          "id": "<ATTACHMENT_ID>",
          "filename": "image.jpg",
          "content_type": "image/jpeg; name=\"image.jpg\"",
          "size": 4860136,
          "is_inline": false,
          "content_id": "<CID>",
          "content_disposition": "attachment; filename=\"image.jpg\"",
          "grant_id": "<NYLAS_GRANT_ID>"
        }
      ],
      "metadata": {
        "key1": "all-meetings",
        "key2": "on-site"
      }
    }
  }
}
```
