Set up a transactional push

Updated

Transactional 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:

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.

  1. 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.

  2. 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.

    create_transactional_step1.png
    create_transactional_step1.png

  3. Click Next: Add Content to go to the next step. Select Push to create a transactional push notification.

    create_transactional_step2.png
    create_transactional_step2.png

  4. 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.

    set up a transactional push notification
    set up a transactional push notification

     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. The data-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>

  5. 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—like password reset or order confirmation.

    configure your message's settings
    configure your message's settings
  6. 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_id
    Required 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).
    integer
    The ID of the transactional message you want to send.
    • token string
      Required The device token.
      • _last_status string
        The 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 string
        The 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 string
        The version of the Customer.io SDK in the app.
      • device_locale string
        The four-letter IETF language code for the device. For example, en-MX (indicating an app in Spanish formatted for a user in Mexico) or es-ES (indicating an app in Spanish formatted for a user in Spain).
      • device_model string
        The model of the device a person uses.
      • device_os string
        The operating system, including the version, on the device.
      • push_enabled string
        If "true", the device is opted-in and can receive push notifications.

        Accepted values:true,false

      • Custom Device Attributes* string
        Custom 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 string
      Required The device/messaging platform.

      Accepted values:ios,android

            • body_loc_arg string
              Variable 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 string
              The 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 string
              The 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 string
              The notification’s icon color in #rrggbb format.
            • icon string
              Sets the notification icon to myicon for drawable resource myicon. If you don’t send this key, FCM displays the launcher icon from your app manifest.
            • sound string
              The 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 string
              Variable 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 string
              The 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 string
            The body of your push notification.
          • title string
            The title of your push notification.
    • ios
      Your 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 string
                  The body of your push notification.
                • image string
                  The URL of an HTTPS image that you want to use for your message.
                • link string
                  A deep link (to a page in your app), or a link to a web page.
                • title string
                  The title of your push notification.
              • alert
                string
                A simple alert message.
              • badge integer
                The number you want to display on your app’s icon. Set to 0 to remove the current badge, if any.
              • category string
                The notification’s type. This string must correspond to the identifier of one of the UNNotificationCategory objects you register at launch time.
              • content-available integer
                The background notification flag. Use 1 without an alert to perform a silent update. 0 indicates a normal push notification.
              • interruption-level string
                Indicates the importance and delivery timing of a notification.

                Accepted values:passive,active,time-sensitive,critical

              • mutable-content integer
                If 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 number
                A number between 0 and 1. The highest score is considered the “most relevant” and is featured in the notification summary.
              • sound
                string
                The 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 string
                The identifier of the window brought forward.
              • thread-id string
                An identifier to group related notifications.
            • Custom key-value pairs* any type
              Additional properties that you've set up your app to interpret outside of the Customer.io SDK.
  • image_url string
    An image URL to show in the push. This overrides Image from the transactional template (referenced by transactional_message_id).
  • language string
    Overrides 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 string
    A deep link to open when the push is tapped. This overrides Link from the transactional template (referenced by transactional_message_id).
  • message string
    The message body for your notification. This overrides the notification body of the transactional template (referenced by transactional_message_id).
  • sound string

    Default: default

    For iOS Only: your notification can alert users with the device’s default notification sound or play no sound at all.

    Accepted values:default,none

  • title string
    The title for your notification. This overrides the title of the transactional template (referenced by transactional_message_id).
  • to string

    Default: all

    The person’s device(s) you want to send this push to. One of 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 by transactional_message_id).

    Accepted values:all,last_used,$device_token

  • disable_message_retention boolean
    If 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.
  • identifiers
    Required Identifies the person represented by your transactional message by one of, and only one of, id, email, or cio_id.
    • id string
      Required 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 type
      Insert key-values that you want to reference in your message here.
  • queue_draft boolean
    If 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 integer
    A 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: true

    If false, your message is not sent to unsubscribed recipients. Setting this value overrides the value set in the settings of your transactional_message_id.
Copied to clipboard!
  Contents
Is this page helpful?