KPN

SMS - KPN

KPN

Inform users with SMS updates, confirmations and notifications

Fast and reliable SMS messaging for your application

  • Communication

API reference on SwaggerHub API reference on Postman

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 API Store account you can apply to take the SMS API into production.

API workflow

API workflow

Getting started

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.

Authentication

OAuth 2.0

For accessing and/or manipulating the resources, the client application (your application) needs to be granted permission to do so. The OAuth 2.0 standard defines a protocol that allows such third party authorization through the use of access tokens. Access tokens are central in the protocol. These tokens, in the form of strings, are delivered by an authorization server (our authentication server) and they enable the client application to securely access protected data on behalf of the resource owner (the end user).

We use Client Credentials Grant. This means the application makes the request to the authentication service by sending authorization credentials. The service responds with an access token among other useful information.

Get access token

Copy your app's credentials and replace APP_CONSUMER_KEY and APP_CONSUMER_SECRET with the copied values, then execute below curl command to receive 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 the 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": "[xxxxxxx]",
    "api_product_list_json": [
        " xxxxxxx"
    ],
    "organization_name": "kpn",
    "developer.email": "demo123@kpn.com",
    "token_type": "Bearer",
    "issued_at": "1521039195424",
    "client_id": "APP_CONSUMER_KEY",
    "access_token": "haf2SDl07E9N7RluNQ4kJ1TkGgso",
    "application_name": "6e38ed2d-48b1-4362-97d6-04254065d79c",
    "scope": "",
    "expires_in": "3599",
    "refresh_count": "0",
    "status": "approved"
}

How to...

Send SMS

Send an SMS by calling the POST /send endpoint of the SMS API in Swaggerhub or Postman. If you want to manually test the API, execute the below cURL command, replacing the access_token with your access_token. You can use the same token to send multiple SMS messages, provided the token is still active. If the token expires then you can get a new access token (see 'Get access token') above.

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

Return codes

Code   Description
200   Success
201   Created
202   Accepted
302   Found. Link in location header
400   Bad request
401   Unauthorized
403   Forbidden
404   Not found
405   Method not allowed
412   Precondition failed
429   Too many requests
500   Internal server error
502   Bad gateway
503   Service unavailable

Changelog

Version   Description
v1.0   Initial version