Send Transactional Messages Through Direct Send API

Use Direct Send APIs to send personalized messages to one or more recipients in response to activities in your application. Messages are sent immediately. For example, use Direct Send APIs for order confirmations, password resets, appointment reminders, shipping updates, and account notifications.

Direct Send APIs support these channels. Each channel name links to the steps for that channel.

ChannelSenderRecipient AddressPreview Available
EmailAn email address on an authorized domainEmail addressYes
SMSAn active SMS Messaging ChannelPhone number in E.164 formatNo
WhatsAppAn active WhatsApp Messaging ChannelPhone number in E.164 formatNo
RCSAn active RCS Messaging ChannelPhone number in E.164 formatNo
PushA mobile app’s Application IdentifierRegistered device IDNo

Every channel works the same way.

  1. Authenticate. Request an access token from an external client app that has the sfap_api scope. Every channel uses the same token. See Connect to Direct Send APIs.
  2. Create a send definition. A send definition stores the settings that stay the same from one send to the next, such as the sender and the published content. Create it once with a Connect API request, and save the ID that the request returns. See Send Definitions.
  3. Send. Call the channel’s send endpoint, and pass the send definition ID in the sendDefinitionId query parameter. Each channel has an endpoint for one recipient and an endpoint for multiple recipients.

After you create a send definition, every later send needs only steps 1 and 3.

Before you send messages with Direct Send APIs, you need:

  • An external client app that’s configured for the client credentials flow and the sfap_api scope. See Connect to Direct Send APIs.
  • A Run As user for the external client app who has permission to create send definitions. Every request made with the token runs with this user’s permissions.
  • A configured sender for each channel that you use. For Email, the configured sender is an authorized sending domain. For SMS, WhatsApp, and RCS, it’s an active Messaging Channel. For Push, it’s a mobile app in your org.
  • Published Salesforce CMS content for each message, if you link content to the send definition.
  • API version 68.0 or later for send definition requests.

Direct Send doesn’t require a separate enablement step. Each channel can be turned off separately, and every send checks that the Run As user has access to the send action.

Direct Send uses two hosts. Use the same access token on both.

TaskHostPath
Request a tokenYour org’s My Domain, such as {yourDomain}.my.salesforce.com/services/oauth2/token
Create a send definitionYour org’s My Domain/services/data/{apiVersion}/connect/e360/{channel}/sendDefinition
Send or preview a messageThe Salesforce API gateway for your environment/messaging/{channel}/v1 and /messaging/{channel}/v1/bulk

The gateway has a base URL for each environment. Use the one that your org and token belong to:

  • Production: https://api.salesforce.com/automation/actions360
  • Test: https://test.api.salesforce.com/automation/actions360

If you call a send path on your My Domain host, the request fails with a 404 response.

A send definition connects published content to the sender and settings that a message uses when you send it. Direct Send APIs require a send definition for every send. Each channel topic shows how to create a send definition for that channel. The rules in this section apply to every channel.

A send definition stores these settings, which stay the same from one send to the next:

  • The sender, such as an email address, a messaging channel, or a mobile app
  • The published Salesforce CMS content that the message uses
  • The message purpose and the communication subscription, for channels that use them
  • The data space that holds the recipients’ consent records
  • Tracking and send timing settings

You create a send definition once, and then pass its ID on every send. Creating a send definition doesn’t send a message.

A send request supplies only what changes for each recipient: the address, the recipient’s identity, and personalization values. A send request can’t change the message purpose or the communication subscription. Email supports overrides for each recipient, including the from address. See Override Parts of the Email.

If you don’t have access to the channel setup, ask your Salesforce admin for the sender and content key. If someone in your org already created the send definition that you need, ask them for its ID and skip the create request.

To create a send definition, send a POST request with a JSON body to the channel’s endpoint on your My Domain host. The path segment selects the channel.

ChannelPath SegmentSender FieldRequired FieldsCMS Content Type
EmailemailfromAddressname, fromAddresssfdc_cms__email
SMSsmssenderIdname, senderIdsfdc_cms__sms
WhatsAppwhatsappsenderIdname, senderIdsfdc_cms__whatsappTemplate (recommended) or sfdc_cms__whatsappSession
RCSrcssenderIdname, senderIdsfdc_cms__rcs
PushpushmobileAppIdname, mobileAppIdsfdc_cms__pushNotification

A successful request returns only the ID of the new send definition. Pass it in the sendDefinitionId query parameter when you send.

SMS, WhatsApp, RCS, and Push send definitions are BulkMessage records, and their IDs start with 539. Email send definitions use a different record type.

The endpoint rejects any field that the channel doesn’t accept with Unrecognized field "{fieldName}". For errors that apply to every channel, see Handle Responses, Errors, and Retries in Direct Send API.

A message purpose classifies a message as PROMOTIONAL or TRANSACTIONAL. Email, SMS, WhatsApp, and RCS send definitions have a message purpose. Push send definitions don’t.

Transactional email is operational, such as order confirmations, password resets, account notifications, shipping updates, and account-activation welcome emails. Promotional email is marketing, such as newsletters, product promotions, event invitations, and surveys. For promotional email, meet the consent and unsubscribe requirements that apply to your use case.

For Email, SMS, and RCS, choose a message purpose when you author the content. The send definition uses that purpose.

  • If the content has no purpose, or if you don’t link content, pass messagePurpose in the create request.
  • If the content and the request both have a purpose, they must match. Otherwise, the request returns messagePurpose conflicts with managed content.
  • The API rejects a request that has neither a content purpose nor a request purpose.

For a WhatsApp template, pass the template’s content key. You don’t need to pass messagePurpose. The send definition gets its purpose in one of two ways.

  1. From the content. If the published content sets a message purpose, the API uses it. A messagePurpose value in the request must match it.
  2. From the template category. If the content has no message purpose, the API maps the template category to a purpose. A messagePurpose value in the request can’t override this mapping.
Template CategoryMessage Purpose
MARKETINGPROMOTIONAL
UTILITYTRANSACTIONAL
AUTHENTICATIONTRANSACTIONAL

Keep any purpose that’s stored on the content consistent with its template category. If you don’t link content, pass messagePurpose in the request. For WhatsApp session content, omit messagePurpose.

A communication subscription is a named messaging preference. It identifies what a recipient agreed to receive. Email, SMS, WhatsApp, and RCS send definitions accept a communicationSubscription. Push send definitions don’t.

  • Pass the subscription’s name, not its record ID.
  • RCS requires a subscription.
  • For WhatsApp, the requirement depends on the content. Session content doesn’t need a subscription. A marketing template uses the Marketing subscription if you omit it. A utility or authentication template needs one. See Send WhatsApp Transactional Messages Through Direct Send API.
  • For Email and SMS, whether a subscription is required depends on your org’s consent settings.
  • When a promotional subscription is required and you omit the name, the API uses the Marketing subscription. That subscription must be configured in your org. Otherwise, the request returns The Marketing Communication Subscription is unavailable.
  • When a transactional subscription is required, pass the name. If you omit it, the request returns communicationSubscription is required for transactional content.

A subscription can be global or associated with a business unit. Either way, a subscription doesn’t select a data space. A global subscription doesn’t make consent available in every data space.

A data space is a Data 360 concept, and an org can have multiple data spaces. A business unit is a Marketing Cloud concept. Each business unit maps to one data space, but a data space doesn’t need a business unit. Business units are optional.

  • To use the default data space, omit dataSpaceName.
  • To use another data space, pass its developer name. Don’t pass its display name or its record ID.
  • If your org uses business units, pass the data space that’s mapped to the relevant business unit. The create request doesn’t accept a business unit identifier.

Choose the data space that holds the recipients’ consent records, and the subscription that matches what they opted in to. For example, when you import consent for promotional email, the consent records are stored in the data space that you choose. Create the promotional email send definition with that same data space. Omit communicationSubscription only if the default Marketing subscription is configured and is the one that the recipient opted in to.

Several fields take a key, label, or name rather than a Salesforce record ID.

FieldPassDon’t Pass
managedContentKeyThe published content’s ContentKeyThe ManagedContent ID
senderIdThe Messaging Channel record IDThe sending number, configured WhatsApp number, RCS agent identifier, or developer name
mobileAppIdThe mobile app’s Application IdentifierThe app’s Salesforce record ID or a Messaging Channel ID
categoryNameA button-set label on the selected appA Salesforce record ID
communicationSubscriptionThe subscription nameThe subscription’s record ID
dataSpaceNameThe data space developer nameThe data space display name or record ID

Match the content key to the channel. The API rejects a key for another channel’s content type with managedContentKey must identify {cmsType} content.

Name send definitions with the package-name@version convention, such as welcome-email@1.0.0 or order-update-sms@1.0.0. This convention makes send definitions easier to identify and version. Email send definition names must be unique.

Create one send definition per template version. Updating published CMS content doesn’t create a new content key, so you don’t need a new send definition for every content edit. If you publish a new version as separate content with its own key, create a send definition for that key.

Click tracking is available on every channel. Open tracking is available only for Email.

  • Open tracking inserts an invisible 1x1 pixel and records an open when the recipient’s email client loads images. Mail privacy features and clients that block images prevent open tracking.
  • Click tracking rewrites links through a tracking server and records the click before it redirects the recipient.

These settings are suggested starting points for Email.

Use CaseopenTrackingEnabledclickTrackingEnabled
Marketing campaigntruetrue
Newslettertruetrue
Transactional notificationfalsetrue
Password resetfalsefalse

Turn off click tracking where link integrity is critical, such as in legal notices.

SMS, WhatsApp, and RCS send definitions accept messageSendTiming, which controls when messages are sent relative to an active or open messaging session with the recipient. The allowed values are Anytime, NotDuringActiveSession, and NotDuringOpenSession.

  • Direct Send API requests to api.salesforce.com don’t consume your org’s core API request limits.
  • The SMS, WhatsApp, RCS, and Push send endpoints don’t have a preview operation. Every request sends a real message, so test with a phone number or device that you control.
  • SMS, WhatsApp, RCS, and Push don’t support asynchronous or scheduled sends.
  • The API doesn’t look up a recipient’s phone number or device token, so pass the address in every request.
  • A 200 response doesn’t mean that every message was accepted for delivery. Check the status of each recipient. See Handle Responses, Errors, and Retries in Direct Send API.