Welcome!

Introduction

We are pleased to present you our new REST API. At the begining of this documentation we would like to give you some general informations about this API:

  1. It's based on JSONAPI specification. We hope that following the rules of this specification will make our API easy to understand.

  2. This documentation is generated from swagger file - written in OpenAPI 3.0.2 Specification

  3. This API always accept application/json format at the API input and always return the same format as output.

  4. API output always follows this scheme:

{
    "meta": {
        "numberOfErrors": NUMBER_OF_ELEMENTS_IN_ERRORS (number),
        "numberOfData": NUMBER_OF_ELEMENTS_IN_DATA (number),
        "status": HTTP_STATUS (number),
        "uniqId": UNIQUE_REQUEST_ID (string)
        "someField": SOME_VALUE (string)
    },
    "data": [],
    "errors": [
        {
            "title": ERROR_TITLE (string),
            "message": ERROR_MESSAGE (string),
            "code": ERROR_CODE (string),
            "meta":{
                "parameter": SOME_VALUE (string),
                "value": SOME_VALUE (string),
                "source": SOME_VALUE (string),
                "someField": SOME_VALUE (string)
            }
        }
    ]
}

Following rules applies to the above scheme:

  • meta element is always present

  • meta.numberOfErrors indicates how many elements errors array includes

  • meta.numberOfData indicates how many elements data array includes

  • meta.status indicates response HTTP status

  • meta.uniqId is used to identify request, if your will have some troubles with your request, please make sure that you sent us meta.uniqId value

  • meta.someField may contain additional fields

  • data array cannot be present with errors array if status code is different from HTTP 207 (MULTI-STATUS)

  • errors array always consists object with fields: title, message and code.

  • errors.meta element may be present inside single error object and contain additional information (that can be parsed) about error

  • errors.meta.parameter the parameter that causes the error

  • errors.meta.value the value of this parameter passed

  • errors.meta.source a link to the entity that caused the error, e.g. externalId

  • errors.meta.somefield additional fields that may appear

Authentication

Second version of VercomAPI offers authentication with pair of keys: Application-Key and Authorization. You can generate your keys in your account panel. To authenticate simply add to your request header with name Authorization and your authorization key as value (string of 128 characters length) and header with name Application-Key and your app key as value.

Example:

$ curl --request POST \
  --header 'Content-Type: application/json' \
  --header 'Application-Key: ' \
  --header 'Authorization: ' \
  --url '...'
  --data '{ ... }'  

REST clients samples

To make integration with our API clear, we have provided examples for some well known REST clients. Feel free to play with these samples.

Long running actions - Retry-After header explained

This API provide some actions that should be used in different way. When we have to deal with long running tasks we don't want to make client wait. To resolve this case we provided support for Retry-After header. How it works? Pretty simple:

  1. Client executes long running action (ex. POST /long-running)

  2. If response data is available then response with HTTP status 200 and data array is returned

  3. If request is not yet available API returns following response:

HTTP/1.1 202 ACCEPTED

Content-Type: application/json
Retry-After: <delay-seconds>
Expires: <http-date>

...

And here we have to explain the meaning of above response headers:

  • HTTP/1.1 202 ACCEPTED indicates that response is not yet available

  • Retry-After indicates how long client should wait before making next request to this endpoint

  • Expires contains the date/time after which the response is considered stale (client should NOT make another request to this endpoint after time specified at this header)

That all. Pretty simple. Isn't it?

Input compression

This API supports following compression algorithms: gzip. To enable this feature just add following header to your request:

Content-Encoding: gzip 

Note that API always returns application/json response body.

In case of sending not compressed data with Content-Encoding: gzip header error will be returned.

Using filters

This API supports filters for GET methods. Almost all of these methods support two filters: limit and offset. They are used for pagination.

  • limit is used to limit number of elements that should API return

  • offset is used to omit number of elements from beginning

Other frequently used filters are dateFrom and dateTo. Full list of available filters in specific request is always present in query parameters list and request examples.

In some GET methods you can also use additional filters:

  • getFullDate is used to get pretty printed DateTime instead Timestamp, accept int values, 0 means get timestamp, 1 means get formated DateTime

Dynamic e-mail content

With this feature, you can dynamically generate e-mail content (HTML/TEXT of the e-mail) based on additional variables passed in to parametr as vars or in globalVars parameter. You can see examples of these parameters in the description of the method.

This feature is best suited for transactional e-mails to generate e.g. product lists or personalise the e-mail to suit each individual recipient. Remember that the overall pers request payload limit applies.

How to use this feature? Easy.

Your HTML/TEXT should contain variables and/or: foreach loop, if else statement. For example like this:

<!DOCTYPE html>
<html>
  <head>
    <!--some headers-->
  </head>
  <body>
    <div data-gb-custom-block data-tag="if" data-0='female'>
      <p>Dear Madame,</p>
    <div data-gb-custom-block data-tag="elseif" data-0='male' data-1='male'></div>
      <p>Dear Sir,</p>
    <div data-gb-custom-block data-tag="else"></div>
      <p>Hello,</p>
    </div>
    
    <br>

    <div data-gb-custom-block data-tag="if">
        <div>Thank you for ordering some products!</div>
    </div>

    <br><br>

    <div data-gb-custom-block data-tag="if">
      You have some promos!
      <ul>
        <div data-gb-custom-block data-tag="for">
        <li> {{promo.name}}: <b>{{promo.value}}</b></li>
        </div>
      </ul>
    </div>

    <br><br>

    BASIC PRODUCT LIST
    <ul>
      <div data-gb-custom-block data-tag="for">
        <div style=\"background-color: {{product.color}}\"> 
          {{product.name}}: {{product.id}} <br>
        </div> 
      </div>
    </ul>

    <br><br>

    Show some alpaca if user has newsletter option! <br>
    <div data-gb-custom-block data-tag="if" data-0='true' data-1='true' data-2='true' data-3='true'>
      <img src=\"https://www.publicdomainpictures.net/pictures/310000/nahled/llama-1575022717hXs.jpg\">
    </div>

    {{footer}}
    
  </body>
 </html>

And then your to parameter could look like this:

{
   "to":[
      {
         "email":"jane.doe@acmedomain.com",
         "messageId":"janedoe00001id@acmedomain.com",
         "name":"Jane Doe",
         "vars":{
            "hasNewsletter":true,
            "products":{
               "1":{
                  "name":"skirt",
                  "id":1,
                  "color":"green"
               },
               "2":{
                  "name":"hoodie",
                  "id":6,
                  "color":"red",
                  "options":[
                     "pocket",
                     "print",
                     "glitter"
                  ]
               },
               "3":{
                  "name":"dress",
                  "id":"100",
                  "color":"blue"
               }
            },
            "promos":{
               "1":{
                  "name":"test40",
                  "value":300
               },
               "2":{
                  "name":"test800",
                  "value":3008
               }
            },
            "footer":"<div style=\"background-image: linear-gradient(red, yellow, green);\"><strong>crazy custom footer</strong></div>"
         }
      }
   ]
}

And that's the tea. Happy sending! :)

SMS Billing

Sms billing table. GSM-7 characters are standard characters used in SMS messages. The use of other characters significantly shortens the length of individual messages. The tables below illustrate this rule.

Incoming webhooks

Listen for events on your account so your integration can automatically trigger reactions.

It is possible to receive delivery and/or click and/or open statuses of all your sendouts from different channels of communication via webhook. A webhook enables us to push real-time notifications to your app. We use HTTPS to send these notifications to your app as a JSON payload. You can then use these notifications to execute actions in your backend systems. Webhooks are particularly useful for sendouts in which you wish to act on the event or display information about delivery in your systems as soon as possible. Alternatively when you need very detailed status information for each message for a large dataset that cannot be found in our panel (for example due to TTL).

Steps to configure webhooks

  1. Identify the events you want to monitor and the event payloads to parse (payloads are described below).

  2. Create a webhook endpoint as an HTTPS endpoint (URL) on your server.

  3. Handle requests by saving each event object (parse it later) and returning 200 response status codes with a string message 'ok'.

  4. Test that your webhook endpoint is working properly using settings in our panel

  5. Save your webhook configuration in panel

Step 1: Identify the events to monitor

The events you can monitor are dependent on your plan and features that you use. The full list is available in the configuration page in our panel under Account -> Settings -> Webhooks.

Step 2: Create a webhook endpoint

Generally you can specify two URLs for each webhook type. Default URL and secondary URL. Unless specified otherwise (in send request), the webhook will be sent to the main URL and when it’s unavailable or fails to respond properly, to the secondary URL.

Step 3: Handle requests

The data is provided in a POST request that consists of an array of events. Each event is structured as an event object but its structure varies in accordance to the type of the event (see below for detailed descriptions for each type). Your endpoint should: check the authorization (in accordance to the setting in panel), save the payload, respond with

HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8

ok

The ‘ok’ is a lowercase string.

Your server should NOT validate the payload before giving the response. The only reasons to respond with something other than success should be authorization failure or an actual internal server error. You should parse your stored payload data into intended structures in a different process (than the receiving endpoint).

Our request can look like this:

[{
  "externalId":"xxxxxxxxxxxxxxxxxxxxxxxx",
  "phoneNumber":"+48XXXXXXXXX",
  "status":1,
  "statusDesc":"DELIVERED",
  "statusTime":"2021-04-27T00:00:18",
  "webhookUrl":"xxxxxxxxxxxxxxx"
}]

or like this:

[{
  "externalId": "xxxxxxxxxxxxxxxxxxxxxxxx",
  "appId": "xxxxxxxxxxxxxxxxxxxxxxxx",
  "platform": 1,
  "status": 1,
  "statusDesc": "Accepted by push operator",
  "statusDetails": "NOTIFICATION_CLICK_ACTION",
  "statusTime": "2020-12-08T11:57:08",
  "actionId": null,
  "code":null
}]

The specific fields depend on the type of webhook (see below).

Authorization

Make sure that the webhooks actually come from us and stay secure. In the panel you can see 2 options for authentication:

  • None

  • Basic auth.

Whether you choose to additionally use basic auth or not, you should always check the hash of incoming webhook. With our POST request, in addition to the standard HTTP headers, we send three headers will allow you to verify if the data actually come from us:

Now, the checksum is generated from a string built like this:

secretkey|X-Webhook-Date|Request-Id

Additionally, you can protect your script with basic auth. All you need to do is turn the option on and set login and password in the panel. Then, of course, add authentication to your endpoint.

Webhook types and event object structures

Transactional e-mails

Remember to use unique message_ids so that you can later aggregate all the webhooks (with consecutive statuses).

example:

[
{
      "subject": "Your chosen subject",
      "smtpAccount": "1.accountname.smtp",
      "to": {
        "email": "test@test.com",
        "name": "Jane Doe",
        "messageId": "d18aa9aa-109e-1b16-a52d-205eac42e44a@domain.com"
      },
      "from": {
        "email": "test@domain.com",
        "name": "Test Corp."
      },
      "tags": null,
      "status": "dropped",
      "statusTime": 1580996271,
      "statusDesc": "test@test.com in blacklist",
      "allStatuses": [
        {
          "status": "injected",
          "statusTime": 1580996275,
          "statusDesc": "injected"
        },
        {
          "status": "dropped",
          "statusTime": 1580996271,
          "statusDesc": "test@test.com in blacklist"
        }
      ]
    }
]

Transactional SMS - delivery reports

*This object contains a webhookUrl field because, when sending transactional SMS it is possible to specify a webhook URL inside send request directly. In that case, both default URL and secondary URL configured in the panel will be ignored and the webhook will be sent to this, additionally specified, URL.

example:

[{
  "externalId":"xxxxxxxxxxxxxxxxxxxxxxxx",
  "phoneNumber":"+48XXXXXXXXX",
  "status":1,
  "statusDesc":"DELIVERED",
  "statusTime":"2021-04-27T00:00:18",
  "webhookUrl":"xxxxxxxxxxxxxxx"
}]

Transactional SMS - clicked link

*This object contains a webhookUrl field because, when sending transactional SMS it is possible to specify a webhook URL inside send request directly. In that case, both default URL and secondary URL configured in the panel will be ignored and the webhook will be sent to this, additionally specified, URL.

2-way communication - Incoming SMS

Push messages - delivery reports

Values for field platform:

Values for field status:

Values for field statusDesc:

Values for field statusDetails:

example:

[{
  "externalId": "xxxxxxxxxxxxxxxxxxxxxxxx",
  "appId": "xxxxxxxxxxxxxxxxxxxxxxxx",
  "platform": 1,
  "status": 1,
  "statusDesc": "Accepted by push operator",
  "statusDetails": "NOTIFICATION_CLICK_ACTION",
  "statusTime": "2020-12-08T11:57:08",
  "actionId": null,
  "code":null
}]

Email campaign webhooks

Example:

{
    "id": "345dfsg2-dfws-w451-1245-sdfgsdf23441",
    "contact": {
        "externalId": "78b556af-c01b-4341-8059-f5ce08f5ad14",
        "email": "test@domain.com",
        "phoneNumber": "+48111222333"
    },
    "campaign": {
        "externalId": "DFG2345T-3456-6734-6345-FHDF65341235"
    },
    "status": {
        "id": 4,
        "desc": "CLICKED",
        "time": "2023-08-08T11:15:53.053"
    },
    "details": {
        "id": null,
        "desc": null,
        "ip": "100.20.30.400",
        "userAgent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36",
        "referer": "https://www.redlink.pl/"
    }
}

Values for field status:

Values for field details:

Sms campaign webhooks

Example:

{
    "id": "345dfsg2-dfws-w451-1245-sdfgsdf23441",
    "contact": {
        "externalId": "78b556af-c01b-4341-8059-f5ce08f5ad14",
        "email": "test@domain.com",
        "phoneNumber": "+48111222333"
    },
    "campaign": {
        "externalId": "DFG2345T-3456-6734-6345-FHDF65341235"
    },
    "status": {
        "id": 4,
        "desc": "CLICKED",
        "time": "2023-08-08T11:15:53.053"
    },
    "details": {
        "id": null,
        "desc": null,
        "ip": "100.20.30.400",
        "userAgent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36",
        "referer": "https://www.redlink.pl/"
    }
}

Values for field status:

Values for field details:

Push campaign webhooks

Example:

{
    "id": "345dfsg2-dfws-w451-1245-sdfgsdf23441",
    "contact": {
        "externalId": "78b556af-c01b-4341-8059-f5ce08f5ad14",
        "email": "test@domain.com",
        "phoneNumber": "+48111222333"
    },
    "campaign": {
        "externalId": "DFG2345T-3456-6734-6345-FHDF65341235"
    },
    "status": {
        "id": 4,
        "desc": "CLICKED",
        "time": "2023-08-07T17:26:07"
    },
    "details": {
        "id": 1,
        "desc": "NOTIFICATION_CLICK_ACTION",
        "actionId": 3,
        "actionDesc": "ACCEPT"
    },
    "platform": {
        "id": 1,
        "desc": "ANDROID",
        "appId": 50
    }
}

Values for field status:

Values for field platform:

Values for field action:

Values for field details:

Step 4: Test your webhook

Only after a successful test result can your webhook configuration be saved. Make sure your endpoint returns

HTTP/1.1 200 OK
Content-Type: text/plain; charset=UTF-8

ok

Step 5: Save your webhook configuration

Voilà! You have configured your webhook integration.

External resources

Converting OAS specification file RAML, API Blueprint...

Generating clients from OAS file

Other tool for client generation

Current Version

This API is using semantic versioning. Current API version is 2.0.0.

Looking for older one?

License

Vercom © 2021

Last updated