Send Push Transactional Messages Through Direct Send API
This Page
All Documentation
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.
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.
Field
Description
dataSpaceName
The developer name of a data space. If you omit it, the API uses the default data space.
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.
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.
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.