A powerful API to send an SMS from your application

Inform your customers and employees by means of updates, confirmations and notifications whenever necessary.


Quick start

Make sure you’ve read Getting Started.

About

SMS is one of the most trusted messaging channels available. Reach any device anywhere. KPN has a long history in providing SMS services to the mobile clients and now it is exposing its service as an API. Anyone can build reliable SMS messaging services on KPN’s infrastructure.

The SMS API is available as a test version to get familiar with the SMS messaging services. Send some test SMS messages and experiment with the API. This API is currently available. All you'll need to do is apply for the production version. In your dashboard you can apply for the production SMS API after which KPN will follow up on your request.

How it works

To get started and test the API from your local workstation you can use Postman or our API Reference (powered by SwaggerHub) or cURL as an HTTP client. If you use the Postman collection or API Reference, make sure you update the environment settings with your credentials in order to authenticate.

 

If you use cURL scroll down to see the examples. The following diagram shows how the SMS flow works.

 

 

Connect to the API

To start testing the API you need to get authorization credentials. Log in to your account and create a developer app on the My Apps page. The steps to create a developer app are briefly discussed under 'Support' 🡆 'Frequently Asked Questions'.

Get access token

Copy your app's credentials and replace APP_CONSUMER_KEY and APP_CONSUMER_SECRET with the copied values, then execute the below cURL command to receive an access token.


curl -X POST \
 'https://api-prd.kpn.com/oauth/client_credential/accesstoken?grant_type=client_credentials' \
 -H 'content-type: application/x-www-form-urlencoded' \
 -d 'client_id=APP_CONSUMER_KEY&client_secret=APP_CONSUMER_SECRET'

Note: If you are using cURL for Windows then please use below command.


curl -X POST "https://api-prd.kpn.com/oauth/client_credential/accesstoken?grant_type=client_credentials" -H "content-type: application/x-www-form-urlencoded" -d "client_id=APP_CONSUMER_KEY&client_secret=APP_CONSUMER_SECRET"

The authorization service returns a JSON message that contains the access token field.

{
    "refresh_token_expires_in": "0",
    "api_product_list": "[SMS-KPN-v1-Demo]",
    "api_product_list_json": [
        "SMS-KPN-v1-Demo"
    ],
    "organization_name": "kpn",
    "developer.email": "demo123@kpn.com",
    "token_type": "BearerToken",
    "issued_at": "1521039195424",
    "client_id": "2Xvp2YLhEeT8w4cXQWvKuOpMoHQQ9zGx",
    "access_token": "haf2SDl07E9N7RluNQ4kJ1TkGgso",
    "application_name": "6e38ed2d-48b1-4362-97d6-04254065d79c",
    "scope": "",
    "expires_in": "3599",
    "refresh_count": "0",
    "status": "approved"
}

 

Send SMS using access token

Copy your access_token and replace access_token with the copied value, then you can execute the cURL command to send a SMS by calling the Send endpoint of the Send SMS API.

You can use same token to send multiple SMS, provided the token is active. If the token expires then you can repeat the above step 'Get access token'.

 

curl -X POST \
 'https://api-prd.kpn.com/messaging/sms-kpn/v1/send' \
 -H 'authorization: BearerToken access_token' \
 -H 'content-type: application/json' \
 -d '{
    "messages": [
        {
            "content": "Greetings from KPN!",
            "mobile_number": "+316********"
        }
    ],
   "sender": "Demo App"
 }'

Note: If you are using cURL for Windows then please use below command.


curl -X POST "https://api-prd.kpn.com/messaging/sms-kpn/v1/send" -H "authorization: BearerToken access_token" -H "content-type:application/json" -d "{\"messages\":[{\"content\":\"Greetings from KPN!\",\"mobile_number\": \"+316********\"}],\"sender\":\"Demo App\"}"