Introduction
Parley's Chat and Messaging API enables you to offer your customers a messaging channel integrated into your website or app. This chat solution enables secure communication between your agent/bot desktop and client website/mobile app.
Devices displaying a webpage or app start communication to the company endpoint, where agents on desktop clients or a bot can respond to the customer's message. Messages can contain text or images.
API specification
Test the API on SwaggerHub
Base URL
https://api-prd.kpn.com/communication/parley/secure-messenger
Conceptual model

Definitions
Messaging channel
A bidirectional communication channel between the user and an agent of a service where one can exchange messages.
Agent
A person that is working in a service center or contact center to answer your questions.
DeviceID
A unique identifier for every device. Provide this value in the UniqueAppDeviceID header key of each request. The minimum length for the DeviceID is 10 characters.
API workflow

Features and constraints
Features
- Secure chat and messaging channel between agent and client.
- Websites or mobile apps are supported as clients.
- Messages can include text or image.
- startTyping and stopTyping events can be used to indicate user activity.
- Paging of message history is supported.
Constraints
- An image attached to a message cannot exceed the size of 10 MB.
- A POST 'Messages' request can include text or an image, but not both in the same request.
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...
Subscribe a device
- You need to subscribe the device before you can send and get messages. When you do not subscribe, we can't tell who you are, so this is important.
- When you subscribe you will also want to setup the
pushToken and pushType of your device to receive updates when a new event or message is available for this device.
- For each request, you need to provide the
UniqueAppDeviceID key. This is a unique identifier that you have to create here for each device. The identifier has a minimum length of 10 characters.
SwaggerHub:
- Select
POST /devices.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId. For receiving messages also fill out the pushToken, pushType and type parameters. Please refer to the Swagger file for more detail.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(GET) Config.
- Fill out
uniqueAppDeviceId in the Headers section.
- Click
Send.
- Check the response code and message.
{
"data": {},
"notifications": [
{
"type": "success",
"message": "device_successfully_subscribed"
}
],
"status": "SUCCESS",
"metadata": {
"values": {
"url": "devices"
},
"method": "post",
"duration": 0.004
}
}
Get the configuration
Request the configuration for the identified account. This contains settings and display settings of the account. All colors are RGB colors saved in hexadecimals.
SwaggerHub:
- Select
GET /config.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(GET) Config.
- Fill out
uniqueAppDeviceId in the Headers section.
- Click
Send.
- Check the response code and message.
{
: {
: ,
: ,
: 4,
: true,
: ,
: ,
: ,
: ,
: ,
: false,
: false,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: 2,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: ,
: 1,
: ,
: ,
: ,
: ,
:
},
: [],
: ,
: {
: {
:
},
: ,
: 0.003
}
}
Indicate user starts typing
Fire the startTyping event to indicate that the user is typing something. To be used and triggered in your app or website.
SwaggerHub:
- Select
POST /services/event/startTyping.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(POST) StartTyping.
- Fill out
uniqueAppDeviceId in the Headers section.
- Click
Send.
- Check the response code and message.
{
"data": "event startTyping executed",
"notifications": [],
"status": "SUCCESS",
"metadata": {
"values": {
"url": "services/event/startTyping"
},
"method": "post",
"duration": 0.069
}
}
Indicate user stops typing
Fires the stopTyping event to indicate the user is not typing anymore. To be used and triggered in your app or website.
SwaggerHub:
- Select
POST /services/event/stopTyping.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(POST) stopTyping.
- Fill out
uniqueAppDeviceId in the Headers section.
- Click
Send.
- Check the response code and message.
{
"data": "event stopTyping executed",
"notifications": [],
"status": "SUCCESS",
"metadata": {
"values": {
"url": "services/event/stopTyping"
},
"method": "post",
"duration": 0.011
}
}
Send a message
Post a message to the API where the 'sender' is a particular user.
You can choose to send a text message or a message with an image. For the textual message, you send a 'regular' POST request with the parameters described in Query parameters. To send an image in a message, you need to send a POST as multipart/form-data with the attributes from Request Body schema.
SwaggerHub:
- Select
POST /messages.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId and message.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(POST) New Message.
- Fill out
uniqueAppDeviceId in the Headers section.
- Fill out
message in the Body section. (or use '''image''' to upload a file).
- Click
Send.
- Check the response code and message.
{
"data": {
"messageId": "1"
},
"notifications": [],
"status": "SUCCESS",
"metadata": {
"values": {
"url": "messages",
"message": "Hello, I have a question."
},
"method": "post",
"duration": 0.012
}
}
Get a list of messages
Get the latest 50 messages from and to a particular user. The order is by time and descending (from new to old).
SwaggerHub:
- Select
GET /messages.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(GET) Latest Messages.
- Fill out
uniqueAppDeviceId in the Headers section.
- Click
Send.
- Check the response code and message.
{
"data": [
{
"id": 1,
"time": 1548335198,
"message": "Hello, I have a question.",
"image": null,
"typeId": 1,
"agent": null
}
],
"notifications": [],
"status": "SUCCESS",
"metadata": {
"values": {
"url": "messages"
},
"method": "get",
"duration": 0.005
},
"agent": {
"id": null,
"name": null,
"avatar": null,
"isTyping": null
},
"paging": {
"before": "",
"after": "/messages/after:1"
},
"stickyMessage": null
}
Get a single specific message
Retrieve a specific message by the message ID.
SwaggerHub:
- Select
GET /messages/{id}.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId and id.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(GET) Latest Messages.
- Fill out
uniqueAppDeviceId in the Headers section and id in the URL.
- Click
Send.
- Check the response code and message.
{
"data": {
"id": 2,
"time": 1548335743,
"message": "What is my current balance?",
"image": null,
"typeId": 1,
"agent": null
},
"notifications": [],
"status": "SUCCESS",
"metadata": {
"values": {
"url": "messages/2"
},
"method": "get",
"duration": 0.003
}
}
Get older/newer messages
Retrieve messages by a paginator, defined as "before:messageID" or "after:messagedID".
SwaggerHub:
- Select
GET /messages/{paging}:{id}.
- Click
Try it out.
- Edit the parameters by filling out the
unqiueAppDeviceId, paging and id.
- Click
Execute.
- Check the response code and message.
Postman:
- Select
(GET) Latest Messages using paging.
- Fill out
uniqueAppDeviceId in the Headers section. Also, fill out paging and id in the URL.
- Click
Send.
- Check the response code and message.
For example:
/messages/before:2
returns:
{
"data": [
{
"id": 1,
"time": 1548335198,
"message": "Hello, I have a question.",
"image": null,
"typeId": 1,
"agent": null
}
],
"notifications": [],
"status": "SUCCESS",
"metadata": {
"values": {
"url": "messages/before:2"
},
"method": "get",
"duration": 0.004
},
"agent": {
"id": null,
"name": null,
"avatar": null,
"isTyping": null
},
"paging": {
"before": "",
"after": "/messages/after:1"
},
"stickyMessage": null
}
Return codes
In case of a 502 return code, the error description is in the response. For example in case the UniqueAppDeviceID is missing or misspelled:
{
"error": {
"transactionId": "apn07-4664-712680-9",
"status": "502 - Bad Gateway",
"name": "Bad - Request",
"message": {
"notifications": [
{
"type": "error",
"message": "device_not_registered"
}
],
"status": "ERROR",
"metadata": {
"values": {
"url": "messages/before:2"
},
"method": "get",
"duration": 0.003
}
},
"info": "https://developer.cubesbykpn.com"
}
}