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:
It's based on JSONAPI specification. We hope that following the rules of this specification will make our API easy to understand.
This documentation is generated from swagger file - written in OpenAPI 3.0.2 Specification
This API always accept application/json format at the API input and always return the same format as output.
API output always follows this scheme:
Following rules applies to the above scheme:
meta
element is always presentmeta.numberOfErrors
indicates how many elementserrors
array includesmeta.numberOfData
indicates how many elementsdata
array includesmeta.status
indicates response HTTP statusmeta.uniqId
is used to identify request, if your will have some troubles with your request, please make sure that you sent usmeta.uniqId
valuemeta.someField
may contain additional fieldsdata
array cannot be present witherrors
array if status code is different from HTTP 207 (MULTI-STATUS)errors
array always consists object with fields:title
,message
andcode
.errors.meta
element may be present inside single error object and contain additional information (that can be parsed) about errorerrors.meta.parameter
the parameter that causes the errorerrors.meta.value
the value of this parameter passederrors.meta.source
a link to the entity that caused the error, e.g. externalIderrors.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:
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:
Client executes long running action (ex. POST /long-running)
If response data is available then response with HTTP status 200 and data array is returned
If request is not yet available API returns following response:
And here we have to explain the meaning of above response headers:
HTTP/1.1 202 ACCEPTED
indicates that response is not yet availableRetry-After
indicates how long client should wait before making next request to this endpointExpires
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:
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 returnoffset
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:
And then your to
parameter could look like this:
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
Identify the events you want to monitor and the event payloads to parse (payloads are described below).
Create a webhook endpoint as an HTTPS endpoint (URL) on your server.
Handle requests by saving each event object (parse it later) and returning 200 response status codes with a string message 'ok'.
Test that your webhook endpoint is working properly using settings in our panel
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
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:
or like this:
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:
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:
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:
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:
Email campaign webhooks
Example:
Values for field status
:
Values for field details
:
Sms campaign webhooks
Example:
Values for field status
:
Values for field details
:
Push campaign webhooks
Example:
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
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