# message.send_failed

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

Sent when a scheduled message fails to deliver. Requires the `send_at` parameter.

> The `error` object contains detailed failure information including provider-specific error codes.

## data.object fields

- `grant_id` (string) **(required)** - The grant ID that attempted to send this message.
- `reason` (string) **(required)** - Human-readable reason for the send failure.
- `error` (object) **(required)** - Detailed error information about the failure.
  - `type` (string) **(required)** - The Nylas error type (e.g. `api.provider_error`).
  - `message` (string) **(required)** - Human-readable error message.
  - `status_code` (integer) - HTTP status code from the provider.
  - `provider_error` (object) - Raw error response from the email provider.
- `object` (object, nullable) **(required)** - The scheduled message that failed to send. May be `null` if the message could not be constructed.
  - `object` (string) (message) - Always `message`.
  - `grant_id` (string) - The grant ID that attempted to send this message.
  - `id` (string) - The Nylas message ID.
  - `subject` (string) - The message subject line.
  - `body` (string) - The message body.
  - `from` (array) - Sender information.
    - `name` (string)
    - `email` (string)
  - `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)
  - `attachments` (array) - Attachment metadata.
    - `id` (string) - Attachment ID.
    - `filename` (string) - Original filename.
    - `content_type` (string) - MIME type.
    - `size` (integer) - Size in bytes.
    - `content` (string) - Base64-encoded attachment content.
  - `schedule_id` (string) - The scheduled send job ID.
  - `send_at` (integer) - Unix timestamp when the message was scheduled to send.
  - `use_draft` (boolean) - Whether the message was sent from a draft.

## Example payload

```json
{
  "specversion": "1.0",
  "type": "message.send_failed",
  "source": "/nylas/send",
  "id": "<WEBHOOK_ID>",
  "time": 1723821985,
  "data": {
    "application_id": "<NYLAS_APPLICATION_ID>",
    "grant_id": "<NYLAS_GRANT_ID>",
    "object": {
      "object": "message",
      "grant_id": "<NYLAS_GRANT_ID>",
      "attachments": [
        {
          "content": "HASKDJhiuahsdjlkhKJAsd=",
          "content_type": "text/plain",
          "filename": "quarterly-report.txt",
          "id": "<ATTACHMENT_ID>",
          "size": 16
        }
      ],
      "bcc": [
        {
          "email": "alex.johnson@example.com",
          "name": "Alex Johnson"
        }
      ],
      "body": "<p>Please review the attached report.</p>",
      "cc": [
        {
          "email": "sam.lee@example.com",
          "name": "Sam Lee"
        }
      ],
      "from": [
        {
          "email": "dana.chen@example.com",
          "name": "Dana Chen"
        }
      ],
      "id": "<MESSAGE_ID>",
      "reply_to": [
        {
          "email": "dana.chen@example.com",
          "name": "Dana Chen"
        }
      ],
      "schedule_id": "<SCHEDULE_ID>",
      "send_at": 1723825200,
      "subject": "Q3 planning meeting agenda",
      "to": [
        {
          "email": "jordan.taylor@example.com",
          "name": "Jordan Taylor"
        }
      ]
    },
    "reason": "Could not authenticate",
    "error": {
      "type": "api.provider_error",
      "message": "Could not authenticate",
      "status_code": 401,
      "provider_error": {
        "error": {
          "code": 401,
          "message": "Invalid credentials"
        }
      }
    }
  },
  "webhook_delivery_attempt": 1
}
```
