Send Push Transactional Messages Through Direct Send API

Use Direct Send APIs to send transactional push notifications to one or more registered devices. The notification comes from the published Salesforce CMS content that’s linked to the send definition. Personalize it, or override its title and body for each recipient.

Push has no preview operation. Every request sends a real notification, so test with a device that you control.

Important

Prerequisites 

  • An access token that has the sfap_api scope. The token’s Run As user must have permission to create send definitions. See Connect to Direct Send APIs.
  • API version 68.0 or later for the send definition request.
  • A mobile app in your org and its Application Identifier.
  • Published push content in Salesforce CMS, of type sfdc_cms__pushNotification. If the content isn’t a Basic notification, such as a Carousel, you also need a button-set label that’s configured on the mobile app.
  • A registered device ID for each recipient. Direct Send doesn’t look up devices or device tokens for you.

If you already have a send definition ID, skip to step 2.

Step 1: Create a Push Send Definition 

Create the send definition on your org’s My Domain host. Push identifies the app with mobileAppId, which is the mobile app’s Application Identifier. It isn’t the app’s Salesforce record ID or a Messaging Channel ID.

1curl -X POST "https://YOUR_DOMAIN.my.salesforce.com/services/data/v68.0/connect/e360/push/sendDefinition" \
2  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "name": "order-update-push@1.0.0",
6    "mobileAppId": "YOUR_APPLICATION_IDENTIFIER",
7    "managedContentKey": "YOUR_PUSH_CONTENT_KEY",
8    "clickTrackingEnabled": false
9  }'

Replace the placeholders with your own values.

  • YOUR_DOMAIN: Your org’s My Domain name.
  • YOUR_ACCESS_TOKEN: Your access token.
  • YOUR_APPLICATION_IDENTIFIER: The mobile app’s Application Identifier.
  • YOUR_PUSH_CONTENT_KEY: The ContentKey of the published push content.

The response contains the sendDefinitionId. Save it for the next step.

The example uses Basic notification content, which doesn’t need categoryName. For other notification types, such as Carousel, pass categoryName with a button-set label that’s configured on the mobile app. If you omit it, the request returns categoryName is required when managed content is not a Basic notification.

Push send definitions don’t use a message purpose or a communication subscription. Don’t pass senderId, fromAddress, messagePurpose, communicationSubscription, messageTrigger, or messageSendTiming.

You can also pass these optional fields.

FieldDescription
dataSpaceNameThe developer name of a data space. If you omit it, the API uses the default data space.
campaignIdThe ID of a Salesforce campaign.
descriptionA description of up to 4,000 characters.

For every field, see Push - Send Definitions (Connect API). If the request fails, see Troubleshoot Send Definition Errors.

Step 2: Send to One Recipient 

Send the notification through the Salesforce API gateway. Pass the send definition ID in the sendDefinitionId query parameter. Push sends to a deviceId, not to a phone number or email address.

1curl -X POST "https://api.salesforce.com/automation/actions360/messaging/push/v1?sendDefinitionId=YOUR_SEND_DEFINITION_ID" \
2  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "deviceId": "YOUR_DEVICE_ID",
6    "individualId": "Individual__dlm/customer-001",
7    "attributes": { "$content": { "firstName": "Alice" } },
8    "messageId": "push-001"
9  }'

Replace these placeholders.

  • YOUR_SEND_DEFINITION_ID: The ID from step 1.
  • YOUR_DEVICE_ID: The registered device ID.

For a test org, use https://test.api.salesforce.com/automation/actions360 as the base URL.

FieldRequiredDescription
deviceIdYesThe registered device ID. The service resolves the device token and platform from the registration.
individualIdYesThe recipient’s identity, used for processing and correlation.
attributesYesThe personalization values. If the content has no variables, pass an empty object. See Personalize the Notification.
messageIdNoA unique ID for the message, used for idempotency and tracing. If you omit it, the service generates one.
titleNoOverrides the notification title for this recipient.
bodyNoOverrides the notification body for this recipient.

Don’t pass deviceToken or devicePlatform. The API doesn’t accept them.

The response has the same shape as the other channels. The to field contains the deviceId from the request. See Handle Responses, Errors, and Retries in Direct Send API.

Step 3: Send to Multiple Recipients 

To send to many devices, post to the /bulk endpoint. Pass a recipients array and an optional batch-level requestId. A bulk request can include up to 2,000 recipients. Split larger sends into batches of 2,000 or fewer. The maximum request size and the maximum attributes size aren’t final yet. Each recipient can render the linked content or have its own title and body. See Override the Title or Body.

1curl -X POST "https://api.salesforce.com/automation/actions360/messaging/push/v1/bulk?sendDefinitionId=YOUR_SEND_DEFINITION_ID" \
2  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "requestId": "push-batch-001",
6    "recipients": [
7      {
8        "deviceId": "DEVICE_ID_1",
9        "individualId": "Individual__dlm/customer-001",
10        "attributes": { "$content": { "firstName": "Alice" } },
11        "messageId": "push-101"
12      },
13      {
14        "deviceId": "DEVICE_ID_2",
15        "individualId": "Individual__dlm/customer-002",
16        "attributes": {},
17        "messageId": "push-102",
18        "title": "Your order shipped",
19        "body": "Order ORD-1234 is on the way."
20      }
21    ]
22  }'

Replace DEVICE_ID_1 and DEVICE_ID_2 with registered device IDs.

The response contains a result for each recipient. Some recipients can fail even when others succeed, so check every recipients[].status. See Handle Responses, Errors, and Retries in Direct Send API.

Personalize the Notification 

Put the values that your content reads under the $content key in attributes. The property names and types come from the published content’s schema, which is stored in contentBody["sfdc_cms:schema"]. For example, this push content reads $content.firstName, which the request in step 2 fills with Alice.

1{
2  "sfdc_cms:pushNotificationContentMessage": "Hello from {{$content.firstName}}",
3  "sfdc_cms:pushNotificationContentSubTitle": "Direct send"
4}

The property names and casing must match the schema. Values keep their JSON types. The API also accepts flat values, such as attributes.firstName, but a flat value doesn’t fill a $content variable. Use $content for new integrations.

Override the Title or Body 

Push supports per-recipient title and body overrides. Omit either field to render that value from the linked content.

1{
2  "deviceId": "YOUR_DEVICE_ID",
3  "individualId": "Individual__dlm/customer-002",
4  "attributes": {},
5  "messageId": "push-002",
6  "title": "Your order shipped",
7  "body": "Order ORD-1234 is on the way."
8}

Deduplication 

Push deduplicates notifications on the tenant, requestId, and messageId for 24 hours. Use new requestId and messageId values for each new notification, including when you rerun a test. Reuse the same values only when you retry the same send.

See Also