# Message Delivery Failed Interaction

Notifies Salesforce when an inbound message interaction request fails.

Whenever an inbound message interaction request fails, the response payload returns a `“success” : “false”` value. If the event is a [Message](/docs/service/interaction-service-api/references/interaction-service-reference/interaction-type-message.md) or [FileAttachment](/docs/service/interaction-service-api/references/interaction-service-reference/interaction-type-file-attachment.md) interaction, the response payload also includes an error code and message. If the event is a [TypingStartedIndicator](/docs/service/interaction-service-api/references/interaction-service-reference/interaction-type-message-typing-started.md) or [TypingStoppedIndicator](/docs/service/interaction-service-api/references/interaction-service-reference/interaction-type-message-typing-stopped.md) interaction, the response payload includes an ID.

This API doesn’t process the failures. Instead, Salesforce tracks the failures, which you can ignore or use to send your own delivery failed notifications.

This API applies to the following products:

- Bring Your Own Channel for CCaaS
- Bring Your Own Channel for Messaging

This API is available in version 61.0 and later.

## URI

`v1/interactions`

## HTTP Method

POST

## Headers

### Authorization (User-Level Authentication)

**Format:** `Bearer <Salesforce Access Token>`\
String. Standard header. Used to authenticate the user, where `<Salesforce Access Token>` is the Salesforce access token used as the bearer token to make requests to the Interaction Service APIs. Required.

### Content-Type

**Format:** `multipart/form-data`\
String. Standard header. Format of the request payload. Required for any request that includes a body.

### OrgId

**Format:** `<Salesforce Org ID>`\
String. Custom header. The Salesforce org. `<Salesforce Org ID>` is the 15-character Org ID of the Salesforce org. Required.

### RequestId

**Format:** `<UUID>`\
String. Custom header. Universally Unique Identifier (`<UUID>`) that references and tracks this request. Required.

### AuthorizationContext

**Format:** `<AuthorizationContext>`\
String. Custom header. Additional information for the request authorization used to authenticate and validate requests against the connected app scopes.

- For Bring Your Own Channel for CCaaS, set `<AuthorizationContext>` to the developer name of the ConversationChannelDefinition record. For example, Partner1\_ChannelDefinition1. Required.
- For Bring Your Own Channel for Messaging, set `<AuthorizationContext>` to the developer name of the ConversationChannelDefinition record. For example, Partner1\_ChannelDefinition1. Required.

### Sample Header

```
-H $'Authorization: Bearer 00DSG000009SWby!...LN8XxeRIxGe' \
-H "content-type: multipart/form-data" \
-H "OrgId: 00DSG000009SWby" \
-H "AuthorizationContext: Partner1_ChannelDefinition1" \
-H "RequestId: a1b23c45-c06a-4784-c96c-cb95d3321bda" \
```

## Parameters

| Property Name                                         | Type    | Description                                                                                                                                                                                                                                                                                                                 | Required |
| :---------------------------------------------------- | :------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
| to                                                    | string  | The channel address identifier. This is the globally unique ID for the conversation channel (`MessagingChannel.ChannelAddressIdentifier`).                                                                                                                                                                                  | Yes      |
| from                                                  | string  | The end user client identifier. This value comes from the partner system and can be up to 240 characters long.                                                                                                                                                                                                              | Yes      |
| interactions                                          | array   | A list of interactions that are initiated by a messaging or voice rep or end user.                                                                                                                                                                                                                                          | Yes      |
| interactions.timestamp                                | boolean | The date and time when the interaction was received by the Salesforce server.                                                                                                                                                                                                                                               | Yes      |
| interactions.interactionType                          | string  | The type of interaction. Possible values include: <br>- **EntryInteraction** to represent the type of interaction, such as an inbound message, a message sent failure, or a typing start or stop indicator. <br>- **AttachmentInteraction** to represent a file attachment that comes within the inbound messaging request. | Yes      |
| interactions.payload                                  | array   | The interaction payload.                                                                                                                                                                                                                                                                                                    | Yes      |
| interactions.payload.id                               | string  | The unique ID for the interaction.                                                                                                                                                                                                                                                                                          | Yes      |
| interaction.payload.entryType                         | string  | The conversation entry type. Set this value to **MessageDeliveryFailed**.                                                                                                                                                                                                                                                   | Yes      |
| interaction.payload.failedConversationEntryIdentifier | string  | The unique ID for the conversation entry that’s associated with the failed delivery.                                                                                                                                                                                                                                        | Yes      |
| interaction.payload.recipient                         | object  | A description of the recipient in the conversation. The `subject` represents the end user client identifier. The `role` represents the participant type and must be set to **EndUser**. The `appType` represents the type of app used by the conversation and must be set to **custom**.                                    | Yes      |
| interaction.payload.errorCode                         | string  | The Salesforce error code for the pre-defined error message that appears in the UI if the inbound message fails. If a custom error message (`errorMessage`) is specified, this error code is ignored.                                                                                                                       | Yes      |
| interaction.payload.errorMessage                      | string  | The custom error message that appears in the UI if the inbound message fails. If a custom error message is specified, the Salesforce error code (`errorCode`) is ignored.                                                                                                                                                   | No       |

## Example

### Request

```sfdocs-code {"lang":"json", "title": "Notifies Salesforce that a message interaction event failed and returns the error message for Salesforce error code 10001"}
{
  "to": "a12bc345-1303-44c2-866c-f30d546b58de",
  "from": "end-user-0001",
  "interactions": [{
    "timestamp": 2542004100250,
    "interactionType": "EntryInteraction",
    "payload": {
      "id": "8432240c-81c7-492c-baf4-2e4cf0995610",
      "entryType": "MessageDeliveryFailed",
      "failedConversationEntryIdentifier": "8432240c-81c7-492c-baf4-2e4cf0995610",
      "recipient": {
          "subject": "end-user-0001",
          "role": "EndUser",
          "appType": "custom"
      },
      "errorCode": "10001"
    }
  }]
}
```

```sfdocs-code {"lang":"json", "title": "Notifies Salesforce that a message interaction event failed and returns a custom error message"}
{
  "to": "z12bc345-1303-44c2-866c-f30d546b58da",
  "from": "end-user-0001",
  "interactions": [{
    "timestamp": 2542004100500,
    "interactionType": "EntryInteraction",
    "payload": {
      "id": "6752240c-81c7-492c-baf4-2e4cf0995659",
      "entryType": "MessageDeliveryFailed",
      "failedConversationEntryIdentifier": "6752240c-81c7-492c-baf4-2e4cf0995659",
      "recipient": {
          "subject": "end-user-0001",
          "role": "EndUser",
          "appType": "custom"
      },
      "errorCode": "10001",
      "errorMessage": "Something went wrong on our side. Contact the IT department for help."
    }
  }]
}
```

## See Also

- *GitHub*: [Interaction Service APIs](https://github.com/salesforce-misc/interaction-service-apis)
- *GitHub:* [Interaction Service API Error Codes](https://github.com/salesforce-misc/interaction-service-apis/blob/main/ERRORCODES.md)
