API menu

SMS Documentation

Some countries might require additional information before being able to send SMS messages

Introduction

With the SMS API, anyone can build reliable SMS messaging services using our infrastructure. It is available as a free demo version too. Send some test SMS messages and experiment with the API before taking it into production. In your Developer Portal account you can apply to take the SMS API into production. Bulk SMS is now supported.

API specification

Test the API on SwaggerHub

Base URL

https://api-prd.kpn.com/communication/kpn/sms

Conceptual model

KPN SMS Conceptual model

Definitions

SMS

An abbreviation of Short Message Service. It's a service on mobile phones to send and receive short messages.

API workflow

KPN SMS API workflow

Features and constraints

Features

  • Send a text message to another mobile phone number.
  • Bulk messaging is now supported: multiple message can be sent to a single recipient, as well as a single message to multiple recipients. This combined features: multiple messages to multiple recipients.

Constraints

  • No images can be sent with SMS.
  • Messages longer than 160 characters will be sent as multiple SMS messages. Maximum message length is 1000 characters.
  • With this API, messages can be sent globally to mobile phones. Also 097 range is allowed.
  • With bulk messaging, the maximum number of messages multiplied by number of recipients in a single API call is 200.
  • In sandbox mode, message length is capped to 160 chars. This limitation is of course lifted in the production version.

060xxxxxxx, 067xxxxxxx and 069xxxxxxx are not valid mobile numbers.

Getting started

Make sure you've read What's in it for you for more info on how to register and start testing APIs.

Authentication

The API follows the KPN Store API Authentication Standard to secure the API. It includes the use of OAuth 2.0 client_id and client_secret to receive an access token.

Go to the Authentication tab on top of this page to find out how to:

  • Authenticate to an API using cURL.
  • Authenticate to an API on Swaggerhub.
  • Import Open API Specifications (OAS), also called Swagger files into Postman.

How to...

Send a single SMS

Send an SMS by calling the send endpoint of the SMS API in Swaggerhub or Postman.

post: {BASE_URL}/send

Create your payload for the request using below snippet:

Request example
{ "sender": "KPN API", "messages": [ { "mobile_number": "06xxxxxxxx or +316xxxxxxxx", "content": "Hi from KPN!" } ] }

The payload uses following parameters:

Parameter Description
sender A text that should resemble the sender's origin. This string can have a maximum length of 11 characters.
mobile_number The mobile phone number of the addressee. Use the relevant country code at the start. For example, +31 or +44.
content Put your message here. Long messages will be split into multiple SMS.

SwaggerHub:

  1. Select POST /send.
  2. Click Try it out.
  3. Edit the body parameter by providing the payload snippet above. In the payload change the content, mobile_number and sender to your own good. Make sure the content-type is set to application/json.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (POST) /send.
  2. In the Body section, set the type to raw and insert the payload snippet above. In the payload change the content, mobile_number and sender to your own good. Make sure the content-type is set to application/json.
  3. Click Send.
  4. Check the response code and message.

Result example:

Response example
{ "document_id": "b4e905d4-774c-4c83-8360-01427e17a33a", "status": "OK" }

Sending bulk SMS's

Sending bulk SMS's uses the same endpoint as a single SMS: the POST /send endpoint of the SMS API in Swaggerhub or Postman. Bulk SMS's are multidimensional, which means that you can:

  • send a single SMS to multiple recipients,
  • send multiple SMS's to a single recipient,
  • a combination of these two options; send multiple SMS's to multiple recipients.

Example of a payload for the request with a single SMS being send to multiple recipients:

Request example
{ "sender": "KPN API", "messages": [ { "mobile_number": "06xxxxxxxx,+316yyyyyyyy,06zzzzzzzz", "content": "Hi from KPN!" } ] }

Example of a payload for the request with a multiple SMS's being send to multiple recipients:

Request example
{ "sender": "KPN API", "messages": [ { "mobile_number": "06xxxxxxxx", "content": "Hi from KPN!" }, { "mobile_number": "+316xxxxxxxx", "content": "Hello there." }, { "mobile_number": "06xxxxxxxx,06yyyyyyyy,+316zzzzzzzz", "content": "Till we meet again." } ] }

Please keep in mind that the maximum message length is 1000 characters. Maximum messages times recipients in one API call is capped to 200 messages.

You will be charged for every SMS you send to a recipient. In the example above where one of the messages is sent to 3 recipients, will be charged as 1 + 1 + 3*1 = 5 SMS's.

This will also work in your sandbox. Feel free to test this, but be aware that you have a limited quota of 25 messages for testing purposes.

The payload uses following parameters:

Parameter Description
sender A text that should resemble the sender's origin. This string can have a maximum length of 11 characters.
mobile_number The mobile phone number(s) of the addressee(s). Use the country code +31 at the start.
content Put your message here. Long messages will be split into multiple SMS.

SwaggerHub:

  1. Select POST /send.
  2. Click Try it out.
  3. Edit the body parameter by providing the payload snippet above. In the payload change the content, mobile_number and sender to your own good. Make sure the content-type is set to application/json.
  4. Click Execute.
  5. Check the response code and message.

Postman:

  1. Select (POST) /send.
  2. In the Body section, set the type to raw and insert the payload snippet above. In the payload change the content, mobile_number and sender to your own good. Make sure the content-type is set to application/json.
  3. Click Send.
  4. Check the response code and message.

Result example:

Response example
{ "document_id": "b4e905d4-774c-4c83-8360-01427e17a33a", "status": "OK" }

Receive notification

For each SMS sent, you can receive a notification. For this you'll need a webhook configured to receive these notifications. By sending the URL of this webhook along with the request, the notification will be delivered on this URL, where you can process this. This applies for single SMS and for bulk SMS. With bulk SMS you can set this up to:

  • receive all notifications in the bulk request on a single URL,
  • receive a notification for one or more recipients on a specific URL,
  • receive a notification for one or more messages on a specific URL,
  • or make a combination of above options; receive notifications on a specific URL for one or more messages, one or more recipients and still use a general URL for the remainder of the messages.

Receiving notifications is free of charge.

Here are a couple of examples of a payload for the request with SMS's being send with the setup of a webhook.

One webhook for one or all SMS
{ "sender": "KPN", "webhook_url": "https://hostname/path", "messages": [{ "content": "Hi from KPN!", "mobile_number": "+316xxxxxxxx" }], }
Webhooks for each SMS
{ "sender": "KPN", "messages": [{ "content": "Hi from KPN!", "mobile_number": "+316xxxxxxxx", "webhook_url": "https://hostname1/path1" },{ "content": "Hi from KPN!", "mobile_number": "+316xxxxxxxx", "webhook_url": "https://hostname2/path2" }], }
A mix – one SMS with a dedicated webhook and others with a general webhook.
{ "sender": "KPN", "webhook_url": "https://hostname/path", "messages": [{ "content": "Hi from KPN!", "mobile_number": "+316xxxxxxxx" },{ "content": "Another Hi from KPN!", "mobile_number": "+316xxxxxxxx", "webhook_url": "https://hostname2/path2" },{ "content": "Yet another hi from KPN!", "mobile_number": "+316xxxxxxxx" }], }

Dedicated webhook(s) have a priority over the general one.

On the webhook you are going to receive a json message. The structure is as follows:

Notification received example
{ "Fields": { "Status": { "StatusDateTime": "2021-12-02T13:25:34Z", "StatusValue": "1", "StatusCode": "Delivered" }, "Sender": "KPN", "WebhookURL": "https://hostname/path", "Message": "Hi There", "RecipientPhonenumber": "+316xxxxxxxx", "CustomerId": "email@domain.com" }, "DLRID": "9F7742AD353FSGS2345SDCDSV45C02", "Service": "Sms", "MessageType": "SmsDeliveryReport", "MessageID": "4C0FWFWE86EE492ABCD34534122hJKHKHFDW" }

The possible values of statusValues - StatusCodes are:

  • 1 - Delivered
  • 2 - Queued
  • 3 - Accepted
  • 4 - Failed
  • 5 - Rejected
  • 6 - Expired

Inbound SMS

What is Inbound SMS?

Inbound SMS refers to text messages sent to your virtual number. These messages can be used for customer queries, feedback, or receiving confirmation codes, making it a versatile tool for enhancing communication with your audience.

You can receive inbound SMS messages directly to your virtual number and a registered webhook. You will need a virtual number and an active webhook. You can request a virtual number and the webhook configuration by filling out the support form.

inboundsms v2 (1)

Specification