Send RCS Transactional Messages Through Direct Send API

Use Direct Send APIs to send transactional RCS messages to one or more phone numbers. Rich content, such as cards, media, and suggestions, comes from the published Salesforce CMS content that’s linked to the send definition. You personalize the message with values that you pass in the request.

RCS has no preview operation. Every request sends a real message, so test with a phone number that you control. To add a test number to your RCS agent, see Set Up RCS Agent in Salesforce Help.

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.
  • An active RCS Messaging Channel and its record ID. To set up an RCS agent, see Salesforce Help.
  • Published RCS content in Salesforce CMS, of type sfdc_cms__rcs, and its ContentKey.
  • An opt-in for each recipient’s phone number. See Consent.

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

Step 1: Create an RCS Send Definition 

Create the send definition on your org’s My Domain host. The sender is the record ID of an active RCS Messaging Channel. Don’t pass the external RCS agent identifier or the channel’s developer name.

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

Replace the placeholders with your own values.

  • YOUR_DOMAIN: Your org’s My Domain name.
  • YOUR_ACCESS_TOKEN: Your access token.
  • YOUR_RCS_MESSAGING_CHANNEL_ID: The record ID of the RCS Messaging Channel.
  • YOUR_RCS_CONTENT_KEY: The ContentKey of the published RCS content.
  • YOUR_SUBSCRIPTION_NAME: The name of the communication subscription. RCS requires one.

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

You can also pass these optional fields.

FieldDescription
messagePurposePROMOTIONAL or TRANSACTIONAL. Required if you don’t pass managedContentKey, or if the content has no purpose. If the content has a purpose, this value must match it. See Message Purpose.
messageSendTimingAnytime, NotDuringActiveSession, or NotDuringOpenSession. See Send Timing.
clickTrackingEnabledIndicates whether link clicks are tracked.
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 RCS - Send Definitions (Connect API). If the request fails, see Troubleshoot Send Definition Errors.

Step 2: Send to One Recipient 

Send the message through the Salesforce API gateway. Pass the send definition ID in the sendDefinitionId query parameter.

1curl -X POST "https://api.salesforce.com/automation/actions360/messaging/rcs/v1?sendDefinitionId=YOUR_SEND_DEFINITION_ID" \
2  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "to": "+14155550100",
6    "individualId": "Individual__dlm/customer-001",
7    "attributes": {
8      "$content": {
9        "firstName": "Alice",
10        "offerCode": "SUMMER26"
11      }
12    },
13    "messageId": "rcs-offer-001"
14  }'

Replace YOUR_SEND_DEFINITION_ID with the ID from step 1. For a test org, use https://test.api.salesforce.com/automation/actions360 as the base URL.

FieldRequiredDescription
toYesThe destination phone number in E.164 format, such as +14155550100.
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 Message.
messageIdNoA unique ID for the message, used for idempotency and tracing. If you omit it, the service generates one.

A 200 response means that the request was processed. Check the recipient’s status, SUCCESS or FAIL, to find out whether the message was accepted for delivery. Acceptance doesn’t confirm delivery. See Handle Responses, Errors, and Retries in Direct Send API.

Step 3: Send to Multiple Recipients 

To send one message to many phone numbers, 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.

1curl -X POST "https://api.salesforce.com/automation/actions360/messaging/rcs/v1/bulk?sendDefinitionId=YOUR_SEND_DEFINITION_ID" \
2  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "requestId": "rcs-batch-001",
6    "recipients": [
7      {
8        "to": "+14155550100",
9        "individualId": "Individual__dlm/customer-001",
10        "attributes": {"$content": {"firstName": "Alice"}},
11        "messageId": "rcs-001"
12      },
13      {
14        "to": "+14155550101",
15        "individualId": "Individual__dlm/customer-002",
16        "attributes": {"$content": {"firstName": "Bob"}},
17        "messageId": "rcs-002"
18      }
19    ]
20  }'

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 Message 

Put personalization values under the $content key in attributes. The property names and value types come from the linked content’s schema, which is stored in contentBody["sfdc_cms:schema"]. The property names and casing must match the schema. Values keep their JSON types, so send a number as a number, not as a string.

The API also accepts flat values, such as attributes.firstName. The content schema doesn’t describe or validate flat values, and a flat value doesn’t fill a $content variable. Use $content for new integrations.

All rich content, such as cards, media, and suggestions, comes from the linked CMS content. The send request doesn’t accept rich cards, media, suggestions, or other content overrides. To change how the message looks, change the content in Salesforce CMS.

Consent 

RCS checks consent when you send, for transactional and promotional messages. The send looks for an opt-in for the phone number under the send definition’s communication subscription and the RCS channel. A number that has no consent record counts as opted out, and the message is suppressed.

A suppressed message can still return "status": "SUCCESS", because SUCCESS means that the message was accepted for delivery. If a test message doesn’t arrive, check the recipient’s opt-in first.

An opt-out on the phone number overrides a subscription opt-in. The number stays suppressed until the opt-out is reversed.

See Also