Handle Responses, Errors, and Retries in Direct Send API
This Page
All Documentation
Direct Send APIs return the same response shape and error behavior on every channel. Use this guidance to read send responses, retry failed sends safely, and troubleshoot common send and send definition errors.
On a single send, the messageId that you sent, or a generated value. On a bulk send, the batch requestId.
to
The recipient’s address. For Push, this field contains the deviceId from the request.
individualId
Bulk only. The recipient’s identity from the request.
messageId
Bulk only. The messageId from the request.
status
SUCCESS or FAIL.
reasonCode
The failure code. Returned only when status is FAIL.
reason
A description of the failure. Returned only when status is FAIL.
properties.deliveryId
The delivery tracking ID.
properties.channel
The delivery channel, such as email or sms.
Store the requestId, messageId, deliveryId, and status for each send so that you can trace the message later.
A 200 Response Can Include Failures
A 200 response means that the request was processed. It doesn’t mean that every message was accepted for delivery. Malformed requests and requests that are missing required recipient fields return 400 before anything is sent. When recipient results are returned, check each result’s status. A single send works like a bulk send with one recipient, so a recipient-level failure also returns 200, with "status": "FAIL". Always check status, and on a bulk send, check every recipients[].status.
A SUCCESS status means that the channel accepted the message for delivery. It doesn’t confirm that the carrier, the device, or the recipient received the message. To get the final delivery state, use channel delivery events or reporting.
Reason Codes
When a recipient fails, reasonCode contains a code such as INVALID_RECIPIENT, SEND_FAILED, or RETRYABLE_SEND_FAILED. These aren’t the only codes. A channel can return other, channel-specific codes, so handle codes that you don’t recognize.
This table describes the common codes. Read the reason text along with the code before you decide whether to retry a recipient.
Reason Code
What It Usually Means
Before You Retry
INVALID_RECIPIENT
The recipient’s data isn’t valid, such as a malformed address.
Correct the recipient’s data. Resending the same data is likely to fail again.
SEND_FAILED
The channel rejected the send.
Check reason to find the cause, and fix it before you resend.
RETRYABLE_SEND_FAILED
The send failed, possibly because of a temporary problem.
A later retry with backoff can succeed. Limit the number of attempts.
Idempotency
Use messageId and requestId to make retries safe.
messageId identifies one message. Set it on a single send and on each recipient in a bulk send.
requestId identifies a bulk batch.
Generate unique values, such as UUIDs, before the first attempt. Reuse the same values when you retry the same send, and never reuse them for a new message. Each messageId must be unique within a bulk request. If you omit messageId, the service generates one.
The deduplication window depends on the channel. Push deduplicates on the tenant, requestId, and messageId for 24 hours. The other channels don’t document a window, so assume that a retry can produce a second message.
Retry Policy
The same retry policy applies to every channel.
Status
Meaning
What to Do
429
A rate or concurrency limit was exceeded.
Retry with exponential backoff and jitter.
503
A downstream service failed temporarily.
Retry with exponential backoff and jitter.
401
The token is missing, expired, or invalid.
Request a new token and then retry.
500
An unexpected server error occurred.
Investigate before you retry broadly.
Other 4xx
The request is invalid.
Correct the request. Don’t retry it unchanged.
When you retry a 429 or 503 response:
Keep the same requestId and messageId values.
Wait with exponential backoff and add random jitter. For example, wait about 1 second, then 2 seconds, then 4 seconds. The schedule is an example, not a service guarantee.
Stop after a limited number of attempts.
For a bulk 200 response, don’t resend the whole batch. Resend only the failed recipients that you want to retry.
Base your error handling on the HTTP status code, not the message text. Error messages are general and can change.
This Node.js example retries 429 and 503 responses with exponential backoff and jitter.
200 with "status": "SUCCESS", but no message arrives
For SMS and RCS, a recipient who has no opt-in record is suppressed. Otherwise, the message was accepted but not yet delivered.
Check the recipient’s consent, and check channel delivery events or reporting.
Troubleshoot Send Definition Errors
When a request to create a send definition fails, the response body is an array of error objects. Each object has a message that describes the error. Match the message to find the cause.
Message
Cause
Request body is required.
The request has no JSON body.
name is required.
name is blank.
description cannot exceed 4000 characters.
description is longer than 4,000 characters.
Unrecognized field "{fieldName}"
The body has a field that the channel doesn’t accept.
fromAddress is required.
An Email request has no fromAddress.
fromAddress must use an authorized email domain.
The sender domain isn’t authorized for email sending. Ask your Salesforce admin to authorize it.
duplicate value found: Name duplicates value on record
An Email send definition with that name exists.
insufficient access rights on object id
The Run As user can’t create Email send definitions.
senderId is required.
An SMS, WhatsApp, or RCS request has no senderId.
sender is not an active Messaging Channel.
The Messaging Channel is inactive.
sender must be a {channel} Messaging Channel.
The Messaging Channel is for a different channel.
sender Messaging Channel usage is not active.
The WhatsApp channel setup isn’t active.
sender does not identify a usable Messaging Channel.
The Messaging Channel ID is unknown or unavailable.
mobileAppId is required.
A Push request has no mobileAppId.
mobileAppId does not identify a usable mobile application.
The Application Identifier is unknown or unavailable.
categoryName is required when managed content is not a Basic notification.
The Push content isn’t a Basic notification, and the request has no categoryName.
categoryName does not identify a category on the selected mobile application.
The label isn’t configured on the mobile app.
managedContentKey does not identify usable managed content.
The content key doesn’t match published content.
managedContentKey must identify {cmsType} content.
The content is for a different channel.
messagePurpose is required when managedContentKey is absent.
The request has no content and no purpose.
messagePurpose must be PROMOTIONAL or TRANSACTIONAL.
The purpose value isn’t supported.
messagePurpose conflicts with managed content.
The request purpose doesn’t match the content’s purpose.
communicationSubscription is required for transactional content.
A transactional send definition that requires a subscription has no subscription name.
The Marketing Communication Subscription is unavailable.
No subscription name was passed, and the default Marketing subscription isn’t configured.
You don't have access to this communication subscription. Please select a subscription from your Business Unit or a Global subscription.
The subscription belongs to another business unit. Pass a subscription from your business unit or a global subscription.
messageSendTiming must be Anytime, NotDuringActiveSession, or NotDuringOpenSession.
The timing value isn’t supported.
A 401 response means that the access token is missing or expired. Request a new token and retry.
Before You Go to Production
Before you move your integration to production, follow these practices.
Call the API from a trusted server, never from browser code.
Never expose or log access tokens. Rotate client secrets, and store them in a secrets manager.
Treat addresses, phone numbers, device IDs, individual IDs, and attributes as sensitive data. Redact them from application logs.
Log the requestId, messageId, deliveryId, channel, HTTP status, and error codes.
Use separate send definitions and credentials for test and production.
Don’t set internal x-sfdc-* headers. The gateway derives tenant and user context from the token.
If you relaxed the external client app’s IP restrictions for testing, restrict them to your server’s IP addresses.
Reuse a token until it expires instead of requesting a new token for every send.