SendMessagesCommand

Creates and sends a direct message.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { PinpointClient, SendMessagesCommand } from "@aws-sdk/client-pinpoint"; // ES Modules import
// const { PinpointClient, SendMessagesCommand } = require("@aws-sdk/client-pinpoint"); // CommonJS import
const client = new PinpointClient(config);
const input = { // SendMessagesRequest
  ApplicationId: "STRING_VALUE", // required
  MessageRequest: { // MessageRequest
    Addresses: { // MapOfAddressConfiguration
      "<keys>": { // AddressConfiguration
        BodyOverride: "STRING_VALUE",
        ChannelType: "PUSH" || "GCM" || "APNS" || "APNS_SANDBOX" || "APNS_VOIP" || "APNS_VOIP_SANDBOX" || "ADM" || "SMS" || "VOICE" || "EMAIL" || "BAIDU" || "CUSTOM" || "IN_APP",
        Context: { // MapOf__string
          "<keys>": "STRING_VALUE",
        },
        RawContent: "STRING_VALUE",
        Substitutions: { // MapOfListOf__string
          "<keys>": [ // ListOf__string
            "STRING_VALUE",
          ],
        },
        TitleOverride: "STRING_VALUE",
      },
    },
    Context: {
      "<keys>": "STRING_VALUE",
    },
    Endpoints: { // MapOfEndpointSendConfiguration
      "<keys>": { // EndpointSendConfiguration
        BodyOverride: "STRING_VALUE",
        Context: {
          "<keys>": "STRING_VALUE",
        },
        RawContent: "STRING_VALUE",
        Substitutions: {
          "<keys>": [
            "STRING_VALUE",
          ],
        },
        TitleOverride: "STRING_VALUE",
      },
    },
    MessageConfiguration: { // DirectMessageConfiguration
      ADMMessage: { // ADMMessage
        Action: "OPEN_APP" || "DEEP_LINK" || "URL",
        Body: "STRING_VALUE",
        ConsolidationKey: "STRING_VALUE",
        Data: {
          "<keys>": "STRING_VALUE",
        },
        ExpiresAfter: "STRING_VALUE",
        IconReference: "STRING_VALUE",
        ImageIconUrl: "STRING_VALUE",
        ImageUrl: "STRING_VALUE",
        MD5: "STRING_VALUE",
        RawContent: "STRING_VALUE",
        SilentPush: true || false,
        SmallImageIconUrl: "STRING_VALUE",
        Sound: "STRING_VALUE",
        Substitutions: {
          "<keys>": [
            "STRING_VALUE",
          ],
        },
        Title: "STRING_VALUE",
        Url: "STRING_VALUE",
      },
      APNSMessage: { // APNSMessage
        APNSPushType: "STRING_VALUE",
        Action: "OPEN_APP" || "DEEP_LINK" || "URL",
        Badge: Number("int"),
        Body: "STRING_VALUE",
        Category: "STRING_VALUE",
        CollapseId: "STRING_VALUE",
        Data: {
          "<keys>": "STRING_VALUE",
        },
        MediaUrl: "STRING_VALUE",
        PreferredAuthenticationMethod: "STRING_VALUE",
        Priority: "STRING_VALUE",
        RawContent: "STRING_VALUE",
        SilentPush: true || false,
        Sound: "STRING_VALUE",
        Substitutions: {
          "<keys>": [
            "STRING_VALUE",
          ],
        },
        ThreadId: "STRING_VALUE",
        TimeToLive: Number("int"),
        Title: "STRING_VALUE",
        Url: "STRING_VALUE",
      },
      BaiduMessage: { // BaiduMessage
        Action: "OPEN_APP" || "DEEP_LINK" || "URL",
        Body: "STRING_VALUE",
        Data: "<MapOf__string>",
        IconReference: "STRING_VALUE",
        ImageIconUrl: "STRING_VALUE",
        ImageUrl: "STRING_VALUE",
        RawContent: "STRING_VALUE",
        SilentPush: true || false,
        SmallImageIconUrl: "STRING_VALUE",
        Sound: "STRING_VALUE",
        Substitutions: {
          "<keys>": [
            "STRING_VALUE",
          ],
        },
        TimeToLive: Number("int"),
        Title: "STRING_VALUE",
        Url: "STRING_VALUE",
      },
      DefaultMessage: { // DefaultMessage
        Body: "STRING_VALUE",
        Substitutions: "<MapOfListOf__string>",
      },
      DefaultPushNotificationMessage: { // DefaultPushNotificationMessage
        Action: "OPEN_APP" || "DEEP_LINK" || "URL",
        Body: "STRING_VALUE",
        Data: "<MapOf__string>",
        SilentPush: true || false,
        Substitutions: "<MapOfListOf__string>",
        Title: "STRING_VALUE",
        Url: "STRING_VALUE",
      },
      EmailMessage: { // EmailMessage
        Body: "STRING_VALUE",
        FeedbackForwardingAddress: "STRING_VALUE",
        FromAddress: "STRING_VALUE",
        RawEmail: { // RawEmail
          Data: new Uint8Array(), // e.g. Buffer.from("") or new TextEncoder().encode("")
        },
        ReplyToAddresses: "<ListOf__string>",
        SimpleEmail: { // SimpleEmail
          HtmlPart: { // SimpleEmailPart
            Charset: "STRING_VALUE",
            Data: "STRING_VALUE",
          },
          Subject: {
            Charset: "STRING_VALUE",
            Data: "STRING_VALUE",
          },
          TextPart: {
            Charset: "STRING_VALUE",
            Data: "STRING_VALUE",
          },
          Headers: [ // ListOfMessageHeader
            { // MessageHeader
              Name: "STRING_VALUE",
              Value: "STRING_VALUE",
            },
          ],
        },
        Substitutions: "<MapOfListOf__string>",
      },
      GCMMessage: { // GCMMessage
        Action: "OPEN_APP" || "DEEP_LINK" || "URL",
        Body: "STRING_VALUE",
        CollapseKey: "STRING_VALUE",
        Data: "<MapOf__string>",
        IconReference: "STRING_VALUE",
        ImageIconUrl: "STRING_VALUE",
        ImageUrl: "STRING_VALUE",
        PreferredAuthenticationMethod: "STRING_VALUE",
        Priority: "STRING_VALUE",
        RawContent: "STRING_VALUE",
        RestrictedPackageName: "STRING_VALUE",
        SilentPush: true || false,
        SmallImageIconUrl: "STRING_VALUE",
        Sound: "STRING_VALUE",
        Substitutions: "<MapOfListOf__string>",
        TimeToLive: Number("int"),
        Title: "STRING_VALUE",
        Url: "STRING_VALUE",
      },
      SMSMessage: { // SMSMessage
        Body: "STRING_VALUE",
        Keyword: "STRING_VALUE",
        MediaUrl: "STRING_VALUE",
        MessageType: "TRANSACTIONAL" || "PROMOTIONAL",
        OriginationNumber: "STRING_VALUE",
        SenderId: "STRING_VALUE",
        Substitutions: "<MapOfListOf__string>",
        EntityId: "STRING_VALUE",
        TemplateId: "STRING_VALUE",
      },
      VoiceMessage: { // VoiceMessage
        Body: "STRING_VALUE",
        LanguageCode: "STRING_VALUE",
        OriginationNumber: "STRING_VALUE",
        Substitutions: "<MapOfListOf__string>",
        VoiceId: "STRING_VALUE",
      },
    },
    TemplateConfiguration: { // TemplateConfiguration
      EmailTemplate: { // Template
        Name: "STRING_VALUE",
        Version: "STRING_VALUE",
      },
      PushTemplate: {
        Name: "STRING_VALUE",
        Version: "STRING_VALUE",
      },
      SMSTemplate: {
        Name: "STRING_VALUE",
        Version: "STRING_VALUE",
      },
      VoiceTemplate: {
        Name: "STRING_VALUE",
        Version: "STRING_VALUE",
      },
      InAppTemplate: {
        Name: "STRING_VALUE",
        Version: "STRING_VALUE",
      },
    },
    TraceId: "STRING_VALUE",
  },
};
const command = new SendMessagesCommand(input);
const response = await client.send(command);
// { // SendMessagesResponse
//   MessageResponse: { // MessageResponse
//     ApplicationId: "STRING_VALUE", // required
//     EndpointResult: { // MapOfEndpointMessageResult
//       "<keys>": { // EndpointMessageResult
//         Address: "STRING_VALUE",
//         DeliveryStatus: "SUCCESSFUL" || "THROTTLED" || "TEMPORARY_FAILURE" || "PERMANENT_FAILURE" || "UNKNOWN_FAILURE" || "OPT_OUT" || "DUPLICATE", // required
//         MessageId: "STRING_VALUE",
//         StatusCode: Number("int"), // required
//         StatusMessage: "STRING_VALUE",
//         UpdatedToken: "STRING_VALUE",
//       },
//     },
//     RequestId: "STRING_VALUE",
//     Result: { // MapOfMessageResult
//       "<keys>": { // MessageResult
//         DeliveryStatus: "SUCCESSFUL" || "THROTTLED" || "TEMPORARY_FAILURE" || "PERMANENT_FAILURE" || "UNKNOWN_FAILURE" || "OPT_OUT" || "DUPLICATE", // required
//         MessageId: "STRING_VALUE",
//         StatusCode: Number("int"), // required
//         StatusMessage: "STRING_VALUE",
//         UpdatedToken: "STRING_VALUE",
//       },
//     },
//   },
// };

SendMessagesCommand Input

See SendMessagesCommandInput for more details

Parameter
Type
Description
ApplicationId
Required
string | undefined

The unique identifier for the application. This identifier is displayed as the Project ID on the Amazon Pinpoint console.

MessageRequest
Required
MessageRequest | undefined

Specifies the configuration and other settings for a message.

SendMessagesCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
MessageResponse
Required
MessageResponse | undefined

Provides information about the results of a request to send a message to an endpoint address.

Throws

Name
Fault
Details
BadRequestException
client

Provides information about an API request or response.

ForbiddenException
client

Provides information about an API request or response.

InternalServerErrorException
server

Provides information about an API request or response.

MethodNotAllowedException
client

Provides information about an API request or response.

NotFoundException
client

Provides information about an API request or response.

PayloadTooLargeException
client

Provides information about an API request or response.

TooManyRequestsException
client

Provides information about an API request or response.

PinpointServiceException
Base exception class for all service exceptions from Pinpoint service.