Transactional API

Transactionals API Overview

The Transactionals API is used to send transactional messages such as Order Delivery and Abandoned Cart notifications to both Voyage and non-Voyage subscribers. This API is organized around REST. The API endpoints were designed to be predictable and resource-oriented and use HTTP response codes to indicate API errors. This means a single resource or endpoint can and often does provide different functionality based on the HTTP verb used to access it. JSON is returned in all responses from the API, including errors.

Creating a new Transactional campaign

You can create a new Transactional Campaign from the ‘Transactional’ tab. Name your new template and then create your message.

When creating the message you can have dynamic variables. These can be defined and passed through in the API call. To declare a variable in the message, surround the key/name of the variable with double curly brackets like {{variableName}}. An example message could be:

  • Hello {{firstName}}! Don’t forget to buy that rug. Go to {{URL}} to complete your checkout!

Here ‘firstName’ and ‘URL’ can be passed through in the API Call.

Note: After saving a new template, a unique key called Template Slug will be generated. You will need the Template Slug to complete the API call.

Sending Transactional messages via API

You need to call the following API endpoint in order to activate the template you created above.

You will need your Voyage API Key and the Template Slug.

HTTP Request

POST: https://api.voyagetext.com/api/sms-transaction/send-sms

Headers

x-api-key:api_key

Replace api_key with your API Key.

Body

Body data should be in JSON format.

{
"templateSlug": "<template_slug>",
"toPhoneNumber": "<phone_number>",
"variables": [
{
"key" : "variable1",
"value" : "Value1"
},
{
"key" : "variable2",
"value" : "Value2"
}
]
}
  • template_slug should be replaced with the Template Slug that was generated when creating a new Transactional campaign in the Voyage app.
  • ‘phone number’ should contain the phone number of the specific recipient.
  • The variables array in the request body should contain all the variable names in key/value pair formats. This can include dynamic URLs.

Example

If you send a request as below for message like ‘Hi, {firstName} {lastName}!’ then the SMS will be sent as ‘Hi, Roger Rabbit!’

{
"templateSlug": "862e87d1e192c27f0e5734a5b",
"toPhoneNumber": "1844XXXXXXX",
"variables": [
{
"key" : "firstName",
"value" : "Roger"
},
{
"key" : "lastName",
"value" : "Rabbit"
}
]
}