Set up a transactional push
UpdatedTransactional messages are email or push notifications that your audience implicitly opts-into, like a transaction receipt or a password reset request. You can send transactional messages programmatically through Customer.io.
Before you begin
Before you can send transactional push notifications you need to:
- Enable Push Notifications in your workspace for Android and/or iOS.
- Set up your app to receive push notifications from Customer.io. We strongly recommend that you use our SDKs. If this isn’t an option, you can follow the instructions here to configure push without our SDKs.
Create a transactional push notification
Try our Postman collection!
You can use our Postman collection and associated environment to get started with the Customer.io API. Our environment is based on our US endpoints; if you’re in our EU region, you’ll need to add -eu
to track_api_url
and app_api_url
variables.
Go to the Transactional page and click Send your first message or Create message—depending on whether there are already transactional messages in your workspace.
Name your message and provide a description. These fields help your team members understand what kind of message this is (like “Password Reset Instructions”). You can also use the Name of your message instead of the
transactional_message_id
when you send your message.Click Next: Add Content to go to the next step. Select Push to create a transactional push notification.
Click Add Content and compose your push notification. Add images, deeplinks and custom data through the editor, or provide these values in the API request. You can also use attributes (
customer.<attribute>
) or trigger data (trigger.<data-object-property>
) to customize your message.Need to track personalized links?
Add the
data-cio-tag
attribute to your links. This lets you track different individualized links in the same category, so you can gather useful metrics about clicks to things like personalized product recommendations, password reset links, customer dashboards, etc. Thedata-cio-tag
takes a string representing the “group” you want to track—<a href="http://mydomain.com?token=123abc" data-cio-tag="YOUR-LINK-GROUP-NAME">CLICK HERE</a>
Configure your message settings.
Send to unsubscribed people? Unsubscribed people usually still want to receive your important transactional messages.
Protect sensitive data by disabling message retention? This setting prevents Customer.io from retaining your message content in delivery history and associated API calls. You might want to do this to conceal sensitive content, like password reset tokens.
Queue messages as drafts? This setting generates a draft for every message you trigger, rather than sending them automatically. You can review these messages under the “Drafts” tab and decide whether to send or delete them.
Set a Trigger Name: This is a friendly name for your message that you can use instead of the
transactional_message_id
when you send your message. It may help make your integration more human-readable if you use triggers that represent the kinds of messages you send—likepassword reset
ororder confirmation
.
To complete the setup, you need to call the API and trigger a message. If you’re not yet ready to send a message directly from your code, you can use an HTTP client like Postman or send a cURL request from your terminal to test your message and complete the setup process.
It can take a few minutes for us to process changes to your snippet.
This means your customers may receive outdated content if, for instance, your campaign is active, you update a snippet in an email, then 30 seconds later we send that email. This could also happen if the message is at the beginning of your workflow, you update a snippet in the message, then immediately activate a campaign or trigger a broadcast, newsletter, or transactional message that contains it.
Examples and API parameters
Below are examples of transactional push notifications. We’ve provided a basic payload and examples for cURL, our Node.JS SDK, and our Python SDK.
Below the examples, you’ll find a list of parameters for transactional push payloads. Your payload changes based on whether you reference a transactional_message_id
(a template) or not. See our REST API documentation for more information.
{
"transactional_message_id": 44,
"title": "Did you really login from a new location?",
"identifiers": {
"email": "person@example.com"
},
"message_data": {
"password_reset_token": "abcde-12345-fghij-d888",
"account_id": "123dj"
}
}
const { APIClient, SendPushRequest, RegionUS } = require("customerio-node");
const api = new APIClient('app-key', { region: RegionUS });
const request = new SendPushRequest({
to: "person@example.com",
transactional_message_id: "44",
message_data: {
password_reset_token: "abcde-12345-fghij-d888",
account_id: "123dj"
},
identifiers: {
id: "2",
},
});
api.sendPush(request)
.then(res => console.log(res))
.catch(err => console.log(err.statusCode, err.message))
from customerio import APIClient, Regions, SendPushRequest
client = APIClient("your API key", region=Regions.US)
request = SendPushRequest(
transactional_message_id="3",
identifiers={
"id": "2",
}
)
response = client.send_push(request)
print(response)
curl --request POST \
--url https://api.customer.io/v1/send/push \
--header 'content-type: application/json' \
--data '{"transactional_message_id":44,"title":"Did you really login from a new location?","identifiers":{"id":12345},"message_data":{"password_reset_token":"abcde-12345-fghij-d888","account_id":"123dj"}}'
- transactional_message_idRequired The transactional message template that you want to use for your message. You can call the template by its numerical ID or by the Trigger Name that you assigned the template (case insensitive).integerThe ID of the transactional message you want to send.
-
- token stringRequired The device token.
-
- _last_status stringThe delivery status of the last message sent to the device—sent, bounced, or suppressed. An empty string indicates that that the device hasn’t received a push yet.
Accepted values:
,
bounced
,sent
,suppressed
- app_version stringThe version of your app that a customer uses. You might target app versions to let people know when they need to update, or expose them to new features when they do.
- cio_sdk_version stringThe version of the Customer.io SDK in the app.
- device_locale stringThe four-letter IETF language code for the device. For example,
en-MX
(indicating an app in Spanish formatted for a user in Mexico) ores-ES
(indicating an app in Spanish formatted for a user in Spain). - device_model stringThe model of the device a person uses.
- device_os stringThe operating system, including the version, on the device.
- push_enabled stringIf
"true"
, the device is opted-in and can receive push notifications.Accepted values:
true
,false
- Custom Device Attributes* stringCustom properties that you want to associate with the device.
- last_used integer (unix timestamp)The
timestamp
when you last identified this device. If you don’t pass a timestamp when you add or update a device, we use the time of the request itself. Our SDKs identify a device when a person launches their app. - platform stringRequired The device/messaging platform.
Accepted values:
ios
,android
-
-
-
-
-
- body_loc_arg stringVariable string values used in place of the format specifiers in
body_loc_key
to localize the body text to the user’s current localization. See Formatting and Styling for more information. - body_loc_key stringThe key to the body string in the app’s string resources that you want to use to localize the body text to the user’s current localization. See String Resources for more information.
- click_action stringThe action that occurs when a user taps on the notification. Launches an activity with a matching intent filter when a person taps the notification.
- color stringThe notification’s icon color in
#rrggbb
format. - icon stringSets the notification icon to
myicon
for drawable resourcemyicon
. If you don’t send this key, FCM displays the launcher icon from your app manifest. - sound stringThe sound that plays when the device receives the notification. Supports
"default"
or the filename of a sound resource bundled in your app. Sound files must reside in/res/raw/
. - tag string
Identifier to replace existing notifications in the notification drawer. If empty, each request creates a new notification.
If you specify a tag, and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer.
- title_loc_arg stringVariable string values used in place of the format specifiers in
title_loc_key
to localize the title text to the user’s current localization. See Formatting and Styling for more information. - title_loc_key stringThe key to the title string in the app’s string resources that you want to use to localize the title text to the user’s current localization. See String Resources for more information.
-
-
- body stringThe body of your push notification.
- title stringThe title of your push notification.
-
-
- iosYour payload changes depending on whether you send to iOS devices through Google’s Firebase Cloud Messaging (FCM) or Apple’s Push Notification service (APNs).
-
-
-
-
-
- body stringThe body of your push notification.
- image stringThe URL of an HTTPS image that you want to use for your message.
- link stringA deep link (to a page in your app), or a link to a web page.
- title stringThe title of your push notification.
-
-
- alertstringA simple alert message.
- badge integerThe number you want to display on your app’s icon. Set to 0 to remove the current badge, if any.
- category stringThe notification’s type. This string must correspond to the identifier of one of the
UNNotificationCategory
objects you register at launch time. - content-available integerThe background notification flag. Use
1
without analert
to perform a silent update.0
indicates a normal push notification. - interruption-level stringIndicates the importance and delivery timing of a notification.
Accepted values:
passive
,active
,time-sensitive
,critical
- mutable-content integerIf you use the Customer.io SDK, you must set this value to
1
to support images and “delivered” metrics from your push notifications. When the value is 1, your notification is passed to your notification service app extension before delivery. Use your extension to modify the notification’s content. - relevance-score numberA number between 0 and 1. The highest score is considered the “most relevant” and is featured in the notification summary.
- soundstringThe name of a sound file in your app’s main bundle or in the Library/Sounds folder of your app’s container directory. Use “default” to play the system sound. For critical alerts, you’ll pass an object instead.
- target-content-id stringThe identifier of the window brought forward.
- thread-id stringAn identifier to group related notifications.
- Custom key-value pairs* any typeAdditional properties that you've set up your app to interpret outside of the Customer.io SDK.
-
-
-
-
- image_url stringAn image URL to show in the push. This overrides Image from the transactional template (referenced by
transactional_message_id
). - language stringOverrides language preferences for the person you want to send your transactional message to. Use one of our supported two- or four-letter language codes.
- link stringA deep link to open when the push is tapped. This overrides Link from the transactional template (referenced by
transactional_message_id
). - message stringThe message body for your notification. This overrides the notification body of the transactional template (referenced by
transactional_message_id
). - sound string
Default:
For iOS Only: your notification can alert users with the device’s default notification sound or play no sound at all.default
Accepted values:
default
,none
- title stringThe title for your notification. This overrides the title of the transactional template (referenced by
transactional_message_id
). - to string
Default:
The person’s device(s) you want to send this push to. One ofall
all
,last_used
, or a custom device token which belongs to the profile from the Identifiers block. Defaults to ‘all’. This overrides To from the transactional template (referenced bytransactional_message_id
).Accepted values:
all
,last_used
,$device_token
- disable_message_retention booleanIf true, the message body is not retained in delivery history. Setting this value overrides the value set in the settings of your
transactional_message_id
. - identifiersRequired Identifies the person represented by your transactional message by one of, and only one of,
id
,email
, orcio_id
.- id stringRequired The identifier for the person represented by the transactional message. NOTE: If your workspace identifies people by email, use the
email
identifier instead.
-
- Liquid Data* any typeInsert key-values that you want to reference in your message here.
- queue_draft booleanIf true, your transactional message is held as a draft in Customer.io and not sent directly to your audience. You must go to the Deliveries and Drafts page to send your message.
- send_at integerA unix timestamp (seconds since epoch) determining when the message will be sent. The timestamp can be up to 90 days in the future. If this value is in the past, your message is sent immediately.
- send_to_unsubscribed boolean
Default:
If false, your message is not sent to unsubscribed recipients. Setting this value overrides the value set in the settings of yourtrue
transactional_message_id
.