NAV Navbar
Logo
cURL Objective-C Swift

Introduction

Channel API

Channel API

The Channel API make is easy to integreate service into your SDK.

Get started

API Base URL

Production server

https://api.getchannel.co

Supported Methods

GET | POST | PUT | DELETE

Request

Request header Value Description
Authorization Channel {access_token} User authorization token
X-Channel-Application-Key {application_key} Application key.
X-Channel-Client-ID {client_id} Client id
curl "https://api.getchannel.co/thread/messages"

The above command and “all API error” returns JSON structured like this:

{
    "code": 401,
    "error": {
        "message": "Require Application key",
        "type": "Unauthorized"
    }
}
Code Meaning
400 Bad Request – Your request is invalid
401 Unauthorized – Your API key is invalid
403 Forbidden – The kitten requested is hidden for administrators only
404 Not Found – The specified could not be found
405 Method Not Allowed – You tried to access an endpoint with an invalid method
406 Not Acceptable – You requested a format that isn’t json
410 Gone – The kitten requested has been removed from our servers
418 I’m a teapot
429 Too Many Requests – You’re requesting too many data!
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarily offline for maintenance. Please try again later.

Application

App Info

curl "https://api.getchannel.co/app/info" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw"

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "application": {
                "id": "j8aPhus-icq0-nlJDyx6e1lmvOHdsqBftwz0jxxbd_0",
                "name": "Channel Example",
                "data": {},
                "createdAt": "2017-03-02T09:51:07.019275Z"
            },
            "agents": [{
                "name": "Apisit",
                "profilePictureURL": "https://lh3.googleusercontent.com/-4eaJ_b6DB-0/AAAAAAAAAAI/AAAAAAAAAWo/tBAvmS43j40/s96-c/photo.jpg"
            }, {
                "name": "Rataphon",
                "profilePictureURL": "https://lh6.googleusercontent.com/-Cy5r9p6rKsU/AAAAAAAAAAI/AAAAAAAAAAA/AAomvV2i-ITcx5lGHq0TPJIaXeYQjeEYtg/s96-c/photo.jpg"
            }]
        }
    }
}

This endpoint get an application information.

HTTP Request

GET /app/info

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES

Client

New client

curl "https://api.getchannel.co/client" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-X POST -d '{"deviceInfo" : {"os-version":"10.1.1","application-version":"1.0","device-model":"iPhone9,3"},"userID":"apiExample"}'

The above command returns “success” JSON structured like this:

{
    "code":200,
    "result":{
        "data":{
            "clientID":"clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"
        }
    }
}

This endpoint create a new client.

HTTP Request

POST /client

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES

HTTP Body

Parameter Description Required
userID a user identify of applied app NO
userData a user data of applied app NO
deviceInfo info of installation device NO

Update client

curl "https://api.getchannel.co/client" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X PUT -d '{"userID":"apiExampleUpdated"}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "clientID": "clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"
        }
    }
}

This endpoint update a client.

HTTP Request

PUT /client

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
userID a user identify of applied app NO
userData a user data of applied app NO
deviceInfo info of installation device NO

Add client data

curl "https://api.getchannel.co/client/data" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"data" : {"tag":"exampleUser"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to add a data related to client.

HTTP Request

POST /client/data

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
data a data of applied application client YES

Update client status

curl "https://api.getchannel.co/client/status" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X PUT -d '{"active" : true,"data":{"flag":"sample status"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "active": true,
            "data": {
                "flag": "sample status"
            }
        }
    }
}

This endpoint update a client status.

HTTP Request

PUT /client/status

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
active true or false (default false) NO
data a data of applied application client YES

Add client device

curl "https://api.getchannel.co/client/device" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"token" : "this-is-an-example-token","info":{"systemData":"iOS"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to add a device token.

HTTP Request

POST /client/device

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
token a device token YES
info device information YES

Subscribe to topic

curl "https://api.getchannel.co/client/topics" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"topic" : "topic-name"}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "publicID": "top_hc5K1QaEx9tcjPudh7qA9bLG4xpMe6CFpZhU-x9ayX0",
            "name": "AAPL",
            "createdAt": "2017-09-04T19:30:57.51553+09:00",
            "updatedAt": "2017-09-04T19:30:57.51553+09:00"
        }
    }
}

Use this endpoint to subscribe client to the topic you wish to send message to client later.

HTTP Request

POST /client/topics

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
topic a topic name YES

Unsubscribe from topic

curl "https://api.getchannel.co/client/topics" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X DELETE -d '{"topic" : "topic-name"}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to unsubscribe client from the topic.

HTTP Request

DELETE /client/topics

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
topic a topic name YES

List subscribed topic

curl "https://api.getchannel.co/client/topics" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" 

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": [
            {
                "publicID": "top_ZKdMtcEan4t7WULDJJLT5872fn_ANceKuPzma_4iO7o",
                "name": "AAPL",
                "createdAt": "2017-09-01T10:22:19.407031+09:00",
                "updatedAt": "2017-09-01T10:25:08.44251+09:00"
            }
        ]
    }
}

Use this endpoint to list client’s subscribed topics.

HTTP Request

GET /client/topics

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

Messaging

Load messages

curl "https://api.getchannel.co/thread/messages" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "messages": [{
                "id": "msg_jD0C9ygQG9ut1I_quwxB9BdDchR6f8SDF_X6Tw1ak7I",
                "data": {
                    "text": "Hello world"
                },
                "sender": {
                    "clientID": "cnt_k2U_GpNABARSYfVYHk-8St2hbMxVDG4T8NV5nwmFsn0",
                    "name": "Rataphon Chitnorm",
                    "profilePictureURL": "https://lh6.googleusercontent.com/-Cy5r9p6rKsU/AAAAAAAAAAI/AAAAAAAAAAA/AAomvV2i-ITcx5lGHq0TPJIaXeYQjeEYtg/s96-c/photo.jpg"
                },
                "createdAt": "2017-05-15T13:05:44.76208Z",
                "isFromBusiness": true,
                "isOwner": false,
                "isNewMessage": false
            }, {
                "id": "msg_i4tEDAL_yTcynuqMJ3pEwRZGtgxnJz5MXBNN0hq2iMY",
                "data": {
                    "card": {
                        "payload": {
                            "url": "https://api.getchannel.co/files/fil_PxDOM2KcR3IyecYkugVC7HaVVrCAsUyt717dyqpnjvQ"
                        },
                        "type": "image"
                    }
                },
                "sender": {
                    "clientID": "cnt_k2U_GpNABARSYfVYHk-8St2hbMxVDG4T8NV5nwmFsn0",
                    "name": "Rataphon Chitnorm",
                    "profilePictureURL": "https://lh6.googleusercontent.com/-Cy5r9p6rKsU/AAAAAAAAAAI/AAAAAAAAAAA/AAomvV2i-ITcx5lGHq0TPJIaXeYQjeEYtg/s96-c/photo.jpg"
                },
                "createdAt": "2017-05-15T13:08:23.875282Z",
                "isFromBusiness": true,
                "isOwner": false,
                "isNewMessage": false
            }],
            "next": "/api/thread/messages?last=3621&limit=20",
            "ID": "thd_pStO7KEInfeXxNqLVif89SY7o1762zJfCQuFXfOAs30",
            "clientID": "clt_-udsmejWfvdmW1qAh4FAD3zlmSY-5b06S5bID1nvHFg"
        }
    }
}

This endpoint load client current thread messages.

HTTP Request

GET /thread/messages/?last=<last>&limit=<limit>

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

URL Query String

Parameter Description Required
last last record returned use to paging NO
limit number of record that you need NO

Get number of unread messages

curl "https://api.getchannel.co/client/newmessage" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "numberOfNewMessages": 0
        }
    }
}

This endpoint return number of unread messages by client.

HTTP Request

GET /client/newmessage

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

Send new message

curl "https://api.getchannel.co/thread/messages" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"data" : {"text":"This is a sample message from channel API"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "id": "msg_mWgEyrEBOdAdwInB1_kSJ_Z-KOCgVB1waw_vmYHxEOk",
            "data": {
                "text": "This is a sample message from channel API"
            },
            "sender": {
                "profilePictureURL": "https://cdn.getchannel.co/img/characters/2.png",
                "clientID": "clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"
            },
            "createdAt": "2017-05-15T13:18:36.798434755Z",
            "isFromBusiness": false,
            "isOwner": false,
            "isNewMessage": false
        }
    }
}

Use this endpoint to send a new message from client to business.

HTTP Request

POST /thread/messages

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
data See Message Protocal YES

Upload image

curl "https://api.getchannel.co/thread/messages/upload" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"imageBase64" : "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAAWdEVYdENyZWF0aW9uIFRpbWUAMDkvMzAvMTDV/ukiAAAAmUlEQVQYlY3QrRHCQBiE4ffiKCFtJMggrwU6uIvCYrGgsHe4yKQMdCgAkbiQMhbBjyEBvplV+8zszIck5hJCkJyTJBJmLsYoay27NKX3XpOwb4zK0lJVFUVRsAc+5roaSZ00bKQWuef0V1Rv0av7C73hL/SAwUlDq/ORWSSJ5DaOcG1ZLRxNA+uDzNQnTJZl8sAyh/x0mUQAd07MymNoJZhoAAAAAElFTkSuQmCC"}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "url": "https://api.getchannel.co/files/fil_yFyL7syrykSPqebybKIGJ7mZQyaquGlcaNuH7Xp9P2g"
        }
    }
}

Use this endpoint to upload image. image must be encoded to base64. You will get a file url if success.

HTTP Request

POST /thread/messages/upload

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
imageBase64 Base64 of image YES

Close thread

curl "https://api.getchannel.co/thread/messages" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X DELETE

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to close a current thread.

HTTP Request

DELETE /thread/messages

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

SSE

Subscribe to SSE

curl "https://api.getchannel.co/subscribe" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"

Instead of keep refreshing every second to check if there is new message from business. Use this endpoint to subscribe to change from server. We use standard Server-Sent-Event protocal.

HTTP Request

GET /subscribe

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

In-App Notification

Check In-App Notification

curl "https://api.getchannel.co/notification" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "publicID": "cnt_eNT71SL0fw-TBaGieSn8oW1KbK4grQ6XC5fjSKFZd9M",
            "data": {
                "notification": {
                    "payload": {
                        "buttons": [{
                            "backgroundColor": "#1BA9E1",
                            "textColor": "#FFFFFF",
                            "title": "Go",
                            "url": "https://www.getchannel.co"
                        }, {
                            "backgroundColor": "#555555",
                            "textColor": "#FFFFFF",
                            "title": "Right button",
                            "url": ""
                        }],
                        "imageURL": "",
                        "templateType": "IMAGE_TEXT_ONE_BUTTON",
                        "text": "Our updated website"
                    },
                    "type": "template"
                }
            },
            "notification": {
                "publicID": "ant_1nJpLA3qSqOG7lFcmkkvlNEfahiCRjk5W0tf53qFU_U",
                "data": null,
                "createdAt": "0001-01-01T00:00:00Z"
            }
        }
    }
}

Use this endpoint to check if there is new in-app notification sent to the client.

HTTP Request

GET /notification

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

Track In-App Notification Action

curl "https://api.getchannel.co/notification/cnt_eNT71SL0fw-TBaGieSn8oW1KbK4grQ6XC5fjSKFZd9M" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"data" : {"backgroundColor": "#1BA9E1","textColor": "#FFFFFF","title": "Go","url": "https://www.getchannel.co"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to send an action of received notification back to server.

HTTP Request

POST /notification/<notificationID>

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
data button json in array []button YES

Track push notification open

curl "https://api.getchannel.co/notification/ant_1nJpLA3qSqOG7lFcmkkvlNEfahiCRjk5W0tf53qFU_U/open/push" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {

        }
    }
}

Use this endpoint track if user opened the app from push notification.

HTTP Request

POST /notification/<notificationID>/open/push

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

Enable/Disable push notification

curl "https://api.getchannel.co/client/device/notifications" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"enable" : true}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

If you want to provide a user to be able to unscribe to push notification sent from Channel. Use this endpoint to enable or disable the push notification.

HTTP Request

POST /client/device/notifications

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
enable true or false YES

Webhooks

Use webhooks to be notified about events that happen in Channel.
Webhook endpoints are URLs defined by users to which Channel sends events. A single event may be sent to many webhook endpoints.

You might use webhooks to be notified: • When user sent you a new message.
• When there is a new client registered to your app.
• When client launched the app and data is updated.
• When Channel Platform sent a push notification for In-App Notification.
• When a client opened a campaign you created in In-App Notification.
• When a client made an action on a campaign. e.g left button or right button.
• When a client open a push notification from your campaign.

New client

A payload Channel POST to your endpoint for new.user

{
    "clientID": "clt_WUiwwO0BLHWzjiQ5GUAqDJwF5CM_InFAkSyAvVRBq5I",
    "device": {
        "info": null,
        "token": ""
    },
    "deviceInfo": {
        "AccessoriesAttached": "No",
        "ActiveMemoryFormatted": "21.318245",
        "ActiveMemoryNotFormatted": "873.195312",
        "ApplicationVersion": "1.0",
        "BatteryLevel": "-1.000000",
        "CFUUID": "D57A7857-EC68-4C93-BF5D-ED0555164F16",
        "CPUUsage": "36.300003",
        "CarrierAllowsVOIP": "No",
        "CarrierCountry": "US",
        "CarrierISOCountryCode": "Unknown",
        "CarrierMobileCountryCode": "Unknown",
        "CarrierMobileNetworkCode": "Unknown",
        "CarrierName": "Unknown",
        "Charging": "No",
        "ConnectedToCellNetwork": "No",
        "ConnectedToWiFi": "Yes",
        "Country": "en_US",
        "Currency": "$",
        "DebuggerAttached": "No",
        "DeviceModel": "iPhone",
        "DeviceName": "Rataphon’s MacBook Air",
        "DeviceOrientation": "-1",
        "DeviceSignature": "1073641400000010ENAS4000111000SS",
        "DiskSpace": "111.87 GB",
        "FreeDiskSpaceFormatted": "11%",
        "FreeDiskSpaceNotFormatted": "12.66 GB",
        "FreeMemoryFormatted": "2.094841",
        "FreeMemoryNotFormatted": "85.804688",
        "FullyCharged": "No",
        "HeadphonesAttached": "No",
        "InactiveMemoryFormatted": "19.519901",
        "InactiveMemoryNotFormatted": "799.535156",
        "Jailbroken": "4783242",
        "Language": "en",
        "LongDiskSpace": "120120541184",
        "LongFreeDiskSpace": "13597253632",
        "MultitaskingEnabled": "Yes",
        "NameAttachedAccessories": "Unknown",
        "NumberActiveProcessors": "4",
        "NumberAttachedAccessories": "0",
        "NumberProcessors": "4",
        "ParentPID": "1808",
        "PluggedIn": "No",
        "ProcessID": "1807",
        "ProcessName": "ChannelExample",
        "ProcessStatus": "2",
        "ProcessorBusSpeed": "100",
        "ProcessorSpeed": "1300",
        "ProximitySensorEnabled": "No",
        "PurgableMemoryFormatted": "0.075626",
        "PurgableMemoryNotFormatted": "3.097656",
        "ScreenBrightness": "50.000000",
        "ScreenHeight": "736",
        "ScreenWidth": "414",
        "SystemDeviceType": "x86_64",
        "SystemDeviceTypeFormatted": "iPhone Simulator",
        "SystemName": "iOS",
        "SystemVersion": "10.3",
        "TimeZone": "Asia/Bangkok",
        "TotalMemory": "4096.000000",
        "UniqueID": "6ES447104118851S",
        "Uptime": "0 2 49",
        "UsedDiskSpaceFormatted": "88%",
        "UsedDiskSpaceNotFormatted": "99.21 GB",
        "UsedMemoryFormatted": "62.548828",
        "UsedMemoryNotFormatted": "2562.511719",
        "WiredMemoryFormatted": "21.723175",
        "WiredMemoryNotFormatted": "889.781250"
    },
    "isActive": false,
    "latestMessage": {
        "createdAt": "0001-01-01T00:00:00Z",
        "data": null,
        "isFromBusiness": false,
        "isNewMessage": false,
        "isOwner": false,
        "sender": null
    },
    "status": {
        "active": false,
        "createdAt": "0001-01-01T00:00:00Z"
    },
    "userData": {
        "profilePictureURL": "https://cdn.getchannel.co/img/characters/2.png"
    }
}

Using new.user to be notified when there is a new client on your app.

Client is updated

A payload Channel POST to your endpoint for update.user

{
    "clientID": "clt_WUiwwO0BLHWzjiQ5GUAqDJwF5CM_InFAkSyAvVRBq5I",
    "device": {
        "info": null,
        "token": ""
    },
    "deviceInfo": {
        "AccessoriesAttached": "No",
        "ActiveMemoryFormatted": "18.758583",
        "ActiveMemoryNotFormatted": "768.351562",
        "ApplicationVersion": "1.0",
        "BatteryLevel": "-1.000000",
        "CFUUID": "8B8702E3-6338-4153-8E89-D222FCE9778C",
        "CPUUsage": "40.399994",
        "CarrierAllowsVOIP": "No",
        "CarrierCountry": "US",
        "CarrierISOCountryCode": "Unknown",
        "CarrierMobileCountryCode": "Unknown",
        "CarrierMobileNetworkCode": "Unknown",
        "CarrierName": "Unknown",
        "Charging": "No",
        "ConnectedToCellNetwork": "No",
        "ConnectedToWiFi": "Yes",
        "Country": "en_US",
        "Currency": "$",
        "DebuggerAttached": "No",
        "DeviceModel": "iPhone",
        "DeviceName": "Rataphon’s MacBook Air",
        "DeviceOrientation": "-1",
        "DeviceSignature": "1073641400000010ENAS4000111000SS",
        "DiskSpace": "111.87 GB",
        "FreeDiskSpaceFormatted": "11%",
        "FreeDiskSpaceNotFormatted": "12.66 GB",
        "FreeMemoryFormatted": "0.493145",
        "FreeMemoryNotFormatted": "20.199219",
        "FullyCharged": "No",
        "HeadphonesAttached": "No",
        "InactiveMemoryFormatted": "18.756962",
        "InactiveMemoryNotFormatted": "768.285156",
        "Jailbroken": "4783242",
        "Language": "en",
        "LongDiskSpace": "120120541184",
        "LongFreeDiskSpace": "13593812992",
        "MultitaskingEnabled": "Yes",
        "NameAttachedAccessories": "Unknown",
        "NumberActiveProcessors": "4",
        "NumberAttachedAccessories": "0",
        "NumberProcessors": "4",
        "ParentPID": "1808",
        "PluggedIn": "No",
        "ProcessID": "1807",
        "ProcessName": "ChannelExample",
        "ProcessStatus": "2",
        "ProcessorBusSpeed": "100",
        "ProcessorSpeed": "1300",
        "ProximitySensorEnabled": "No",
        "PurgableMemoryFormatted": "-1.000000",
        "PurgableMemoryNotFormatted": "-1.000000",
        "ScreenBrightness": "50.000000",
        "ScreenHeight": "736",
        "ScreenWidth": "414",
        "SystemDeviceType": "x86_64",
        "SystemDeviceTypeFormatted": "iPhone Simulator",
        "SystemName": "iOS",
        "SystemVersion": "10.3",
        "TimeZone": "Asia/Bangkok",
        "TotalMemory": "4096.000000",
        "UniqueID": "6ES447104118851S",
        "Uptime": "0 2 51",
        "UsedDiskSpaceFormatted": "88%",
        "UsedDiskSpaceNotFormatted": "99.21 GB",
        "UsedMemoryFormatted": "61.206055",
        "UsedMemoryNotFormatted": "2507.265625",
        "WiredMemoryFormatted": "23.697090",
        "WiredMemoryNotFormatted": "970.632812"
    },
    "isActive": true,
    "latestMessage": {
        "createdAt": "0001-01-01T00:00:00Z",
        "data": null,
        "isFromBusiness": false,
        "isNewMessage": false,
        "isOwner": false,
        "sender": null
    },
    "status": {
        "active": false,
        "createdAt": "0001-01-01T00:00:00Z"
    },
    "userData": {
        "lastname": "Bar",
        "name": "Foo",
        "profilePictureURL": "https://cdn.getchannel.co/img/characters/2.png"
    },
    "userID": "foo.bar@apple.com"
}

Using update.user to be notified when client is updated.

A new message from client

A payload Channel POST to your endpoint for new.message

{
    "createdAt": "2017-05-17T10:12:26.760420956+07:00",
    "data": {
        "text": "Hi there"
    },
    "id": "msg_d8wiA_0Cj85-VibpGsHc9tUE-3phWmrrUdo7rtBbSzY",
    "isFromBusiness": false,
    "isNewMessage": false,
    "isOwner": false,
    "sender": {
        "lastname": "Bar",
        "name": "Foo",
        "profilePictureURL": "https://cdn.getchannel.co/img/characters/2.png",
        "clientID": "clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"
    }
}

Using new.message to be notified when client sent a message from your app.

Open Campaign

A payload Channel POST to your endpoint for open.campaign

{
    "notification": {
        "payload": {
            "buttons": [{
                "backgroundColor": "#1BA9E1",
                "textColor": "#FFFFFF",
                "title": "Left button",
                "url": "https://www.getchannel.co"
            }, {
                "backgroundColor": "#555555",
                "textColor": "#FFFFFF",
                "title": "Right button",
                "url": ""
            }],
            "imageURL": "",
            "templateType": "IMAGE_TEXT_ONE_BUTTON",
            "text": "Our new website"
        },
        "type": "template"
    }
}

Using open.campaign to be notified when client opened your app and see an in-app notification.

Campaign Action

A payload Channel POST to your endpoint for click.campaign

{
    "action": {
        "backgroundColor": "#1BA9E1",
        "textColor": "#FFFFFF",
        "title": "Left button",
        "url": "https://www.getchannel.co"
    },
    "data": {
        "notification": {
            "payload": {
                "buttons": [{
                    "backgroundColor": "#1BA9E1",
                    "textColor": "#FFFFFF",
                    "title": "Left button",
                    "url": "https://www.getchannel.co"
                }, {
                    "backgroundColor": "#555555",
                    "textColor": "#FFFFFF",
                    "title": "Right button",
                    "url": ""
                }],
                "imageURL": "",
                "templateType": "IMAGE_TEXT_ONE_BUTTON",
                "text": "Our new website"
            },
            "type": "template"
        }
    }
}

Using click.campaign to be notified when client either click left or right button on your campaign.

Push notification sent

A payload Channel POST to your endpoint for send.push

{
    "notification": {
        "publicID": "ant_Ablap7mfHDOIiPkWsv3Yj7Vuz1uQSyqk3Uze01NoyF0",
        "data": null,
        "createdAt": "0001-01-01T00:00:00Z"
    },
    "client": {
        "clientID": "clt_NmgFvUT36SxKmcuqg6Go0-5LP-DpYfTxuX1Nq-gHS90",
        "userData": null,
        "isActive": false,
        "threadID": "thd_gSsP_apl0FS2yWs90rHNp2KnvQwqzUjNPKbmRxiVRFw",
        "latestMessage": {
            "data": null,
            "sender": null,
            "createdAt": "0001-01-01T00:00:00Z",
            "isFromBusiness": false,
            "isOwner": false,
            "isNewMessage": false
        },
        "status": {
            "active": false,
            "createdAt": "0001-01-01T00:00:00Z"
        },
        "device": {
            "token": "",
            "info": {}
        }
    }
}

Using send.push to be notified when Channel Platform sent a push notification to client.

Push notification opened

A payload Channel POST to your endpoint for open.push

{
    "notification": {
        "publicID": "ant_Ablap7mfHDOIiPkWsv3Yj7Vuz1uQSyqk3Uze01NoyF0",
        "data": null,
        "createdAt": "0001-01-01T00:00:00Z"
    },
    "client": {
        "clientID": "clt_NmgFvUT36SxKmcuqg6Go0-5LP-DpYfTxuX1Nq-gHS90",
        "userData": null,
        "isActive": false,
        "threadID": "thd_gSsP_apl0FS2yWs90rHNp2KnvQwqzUjNPKbmRxiVRFw",
        "latestMessage": {
            "data": null,
            "sender": null,
            "createdAt": "0001-01-01T00:00:00Z",
            "isFromBusiness": false,
            "isOwner": false,
            "isNewMessage": false
        },
        "status": {
            "active": false,
            "createdAt": "0001-01-01T00:00:00Z"
        },
        "device": {
            "token": "",
            "info": {}
        }
    }
}

Using open.push to be notified when client tap push notification sent by Channel Platform.

Bot

Send new message

curl "https://api.getchannel.co/bot/clients/clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw/messages" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Bot-Token:btk_f5RH_N3njm-_vVxy2EUWBme23Im7Wqf9VhHW8Rjiu8A" \
-X POST -d '{"data" : {"text":"This is a sample message from bot"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "id": "msg_E25jyfNOqGTt5MzMXnCVVkrILH0qk-55ZE99qyL-0Co",
            "data": {
                "text": "This is a sample message from bot"
            },
            "sender": {
                "clientID": "clt_gvlVMzWglhVUh91zHqPBf8CQy5PJ250bdj2OVCZKaCw",
                "name": "i am an example Bot",
                "profilePictureURL": "https://cdn.getchannel.co/img/characters/4.png"
            },
            "createdAt": "2017-06-08T05:01:34.121065043Z",
            "isFromBusiness": true,
            "isOwner": false,
            "isNewMessage": false
        }
    }
}

Use this endpoint to send a new message from bot to client.

HTTP Request

POST /bot/clients/<clientID>/messages

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Bot-Token a bot token YES

HTTP Body

Parameter Description Required
data See Message Protocal YES

Publish message

curl "https://api.getchannel.co/bot/publish/mytopic" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Bot-Token:btk_f5RH_N3njm-_vVxy2EUWBme23Im7Wqf9VhHW8Rjiu8A" \
-X POST -d '{"data" : {"text":"This is a sample message from bot"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to send message to clients that subscribed to particular topic. note: A message which is sent with topic will have "topic":"{topic_name}" attached in the payload.

HTTP Request

POST /bot/publish/{topic_name}

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Bot-Token a bot token YES

HTTP Body

Parameter Description Required
data See Message Protocal YES

Message Protocol

data object

{
    "data": {
        "text": "hi there"
    }
}
Property name description required
text message text text or card must be set
card card object text or card must be set
buttons a list of button object no

button object

{
    "data": {
        "text": "hi there"
        "buttons":{}
    }
}
Property name description required
title A title of button Yes
payload Payload of button A payload must be set if type is postback
type Type of button may be web_url, postback Yes
url A url for type web_url A url must be set if type is web_url
backgroundColor A background color of a button. e.g. #FFCC00 No
textColor A text color of a button. e.g. #FFFFFF No

card object

{
    "data": {
        "card": {
            "type": "image",
            "payload": {
                "url": "https://api.getchannel.co/files/fdasfadsf093ujfad.jpg"
            }
        }
    }
}
Property name description required
type Type of card may be image, template Yes
payload Payload of card Yes

card object type image

Property name description required
url Image url Yes

card object type template

Property name description required
templateType A template type Yes
url a destination url when user tap a card No

Channel iOS SDK

The Channel iOS SDK make is easy to integreate in-app messaging into your iOS app.

Requirements

Our SDK is compatible with iOS apps supporting iOS 8.0 and above.

Install the SDK

  1. Go to our Github releases page and download and upzip Channel.framework.zip.
  2. In Xcode, with your project open, click on “File” then “Add files to Project…”.
  3. Select Channel.framework in the directory you just unzipped.
  4. Checked “Copy items if needed”.
  5. Click “Add”.
  6. In “Embedded Binaries” Click “+”
  7. Select Channel.framework.
  8. Create a new Run Script Phase in your app’s target’s Build Phases and paste the following snippet in the script text field. bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Channel.framework/strip-frameworks.sh" This step is required to work around an App Store submission bug when archiving universal binaries.

  9. Add NSPhotoLibraryUsageDescription and NSCameraUsageDescription to a info.plist file.

Configure the SDK

Once you downloaded the SDK, configure it with your Channel Application ID.

    #import "AppDelegate.h"
    #import <Channel/Channel.h>

    @implementation AppDelegate

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        [Channel setupWithApplicationId:@"app_VJSiM8Eq9FvnkdH1YBJ9_823TzGbzI5UOuiHbw6BANk"];
        // do any other necessary launch configuration

        return YES;
    }

import UIKit
import Channel

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

        Channel.setup(withApplicationId: "app_VJSiM8Eq9FvnkdH1YBJ9_823TzGbzI5UOuiHbw6BANk")
        // do any other necessary launch configuration

        return true
    }

More methods in setting up.

Some app might want to enable Channel only for authroized user. If you already have your UserID and other userData. Channel also provides these helper methods

+ (void)setupWithApplicationId:(NSString* _Nonnull)appId;
+ (void)setupWithApplicationId:(NSString* _Nonnull)appId userID:(NSString* _Nullable)userID userData:(NSDictionary* _Nullable)userData;
+ (void)setupWithApplicationId:(NSString* _Nonnull)appId launchOptions:(NSDictionary* _Nullable)launchOptions;
+ (void)setupWithApplicationId:(NSString* _Nonnull)appId userID:(NSString* _Nullable)userID userData:(NSDictionary* _Nullable)userData launchOptions:(NSDictionary* _Nullable)launchOptions;;
open class func setup(withApplicationId appId: String)
open class func setup(withApplicationId appId: String, userID: String?, userData: [AnyHashable : Any]?)
open class func setup(withApplicationId appId: String, launchOptions: [AnyHashable : Any]? = nil)
open class func setup(withApplicationId appId: String, userID: String?, userData: [AnyHashable : Any]?, launchOptions: [AnyHashable : Any]? = nil)

Integration

Channel provides a view controller that encapsulate all the functionalities.

You can send userID and UserData (optional) to Channel backend to help you identify which user you are communicating with. The data will show up in user side bar.

- (IBAction)didTapButton:(id)sender {
    NSString* userID = @"AnyID";
    NSDictionary* userData = @{@"name":@"John",
        @"lastname": @"Doe"};
    UIViewController* vc = [Channel chatViewControllerWithUserID:userID userData:userData];
    vc.title = @"Your title here";
    UINavigationController* nav = [[UINavigationController alloc]initWithRootViewController:vc];
    [self presentViewController:nav animated:YES completion:nil];
}
   @IBAction func didTapButton(_ sender: Any) {
        let userID = "AnyID"
        let userData = ["screen":"help",
                        "action":"contact"]
        let vc = Channel.chatViewController(withUserID: userID, userData: userData)
        vc.title = "Your title"
        self.navigationController?.pushViewController(vc, animated: true)
    }

Checking new message

Sometimes you want to notify a client when you sent some message from our backend.

 [Channel checkNewMessages:^(NSInteger numberOfNewMessages) {
        if (numberOfNewMessages > 0){
            NSString* title = [NSString stringWithFormat:@"You have new %ld messages",numberOfNewMessages];
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];

            UIAlertAction* view = [UIAlertAction actionWithTitle:@"View" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                //open chat view 
            }];
            [alert addAction:view];

            UIAlertAction* later = [UIAlertAction actionWithTitle:@"Later" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

            }];
            [alert addAction:later];
            [self presentViewController:alert animated:YES completion:nil];
        }
    }];
Channel.checkNewMessages { (numberOfNewMessages) in
            if numberOfNewMessages > 0 {
                let alert = UIAlertController(title: "", message: "You have \(numberOfNewMessages) new mesage", preferredStyle: .alert)
                let viewAction = UIAlertAction(title: "View", style: .default, handler: { (_) in
                   //do something or open Channel chat view controller
                })
                alert.addAction(viewAction)
                let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: { (_) in

                })
                alert.addAction(cancelAction)
                self.present(alert, animated: true, completion: nil)
            }
        }

In-app notification

This method allows you to check if there is new in-app notification to the client.

[[Channel shared] showLatestNotification];
Channel.shared().showLatestNotification()

In-app Notification Delegate

Delegate method related to in-app notification.

@protocol ChannelDelegate <NSObject>

@optional
- (void)channelUserDidTapButtonNotificationView:(CHNotification* _Nonnull)notification button:(CHNotificationButton* _Nonnull)button;
@optional
- (void)channelUserDidTapPushNotificationTypeConversations;
@optional
- (void)channelUserDidTapPushNotificationTypeInAppMessage;
@end

optional public func channelUserDidTapButtonNotificationView(_ notification: CHNotification, button: CHNotificationButton)
optional public func channelUserDidTapPushNotificationTypeConversations()
optional public func channelUserDidTapPushNotificationTypeInAppMessage()

Push notification

If you have push notification capability enabled in your app. Channel SDK will do everything for you.
However, if you want to provide user to opt-out from a push notification. This is disable
You can call the method below passing boolean value to it.

[Channel pushNotificationEnabled:YES];
Channel.pushNotificationEnabled(true)

Questions?

We are always happy to help. Send us an email at channel@mogohichi.com

User to User chat API

Search user

curl "https://api.getchannel.co/search/client?q=apisit" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
            "userData": {
                "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                "profilePictureURL": "https://cdn.getchannel.co/img/characters/1.png"
            },
            "userID": "apisit"
        }
    }
}

This endpoint search client by your application userID .

HTTP Request

GET /search/client?q=<your_application_userID>

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

URL Query String

Parameter Description Required
q your application userID that you need find YES

New conversation

curl "https://api.getchannel.co/conversations" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"clients":["clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo"]}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "thread": {
                "ID": "thd_5KhsUHetpuN1uml8TBz1iXqICANTul0Kc-oANXBJ3PE",
                "clientID": "clt_e_Gb4AZqCdBDWltP2QGUEX-OfPL6I0BW8IqdHxNPFFg"
            },
            "isAccept": false,
            "participants": [
                {
                    "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                    "userData": {
                        "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                        "profilePictureURL": "https://cdn.getchannel.co/img/characters/1.png"
                    },
                    "userID": "apisit"
                }
            ]
        }
    }
}

Use this endpoint to new conversation.

HTTP Request

POST /conversations

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
clients an array list of client for new conversation YES

Invite

curl "https://api.getchannel.co/conversations/thd_ifM0dJn5_JnKrQXzaybVY6BIljnB3dR3u" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"clients":["clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo"]}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "thread": {
                "ID": "thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg"
            },
            "isAccept": false,
            "participants": [
                {
                    "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                    "userData": {
                        "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                        "profilePictureURL": "https://cdn.getchannel.co/img/characters/1.png"
                    },
                    "userID": "apisit"
                }
            ]
        }
    }
}

Use this endpoint to invite new client to conversation.

HTTP Request

POST /conversations/<threadID>

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
clients an array list of client for new conversation YES

Load conversations

curl "https://api.getchannel.co/conversations" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw"

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": [
            {
                "thread": {
                    "ID": "thd_ifM0dJn5_JnKrQXzaybVY6BIljnB3dR3u-2aBAOnRV8"
                },
                "isAccept": true,
                "participants": [
                    {
                        "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                        "userData": {
                            "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                            "profilePictureURL": "https://cdn.getchannel.co/img/characters/1.png"
                        },
                        "userID": "apisit"
                    }
                ]
            },
            {
                "thread": {
                    "ID": "thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg"
                },
                "isAccept": true,
                "participants": [
                    {
                        "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                        "userData": {
                            "clientID": "clt_LP_M9Q_3DzF7qNCt3mzZqiTXAdn6-YTfCwGyQhHCKOo",
                            "profilePictureURL": "https://cdn.getchannel.co/img/characters/1.png"
                        },
                        "userID": "apisit"
                    }
                ]
            }
        ]
    }
}

This endpoint load current client conversations.

HTTP Request

GET /conversations

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

Load conversation thread

curl "https://api.getchannel.co/conversations/thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg?last=0&limit=20" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "messages": [
                {
                    "id": "msg_ZF8bkctcoB0WbpwQx6rczAEbWeYDq2hJI3rzndSf9iM",
                    "data": {
                        "text": "This is a sample message from channel API"
                    },
                    "sender": {
                        "clientID": "clt_e_Gb4AZqCdBDWltP2QGUEX-OfPL6I0BW8IqdHxNPFFg",
                        "profilePictureURL": "https://cdn.getchannel.co/img/characters/2.png"
                    },
                    "createdAt": "2017-12-04T08:17:57.375168Z",
                    "isFromBusiness": true,
                    "isOwner": true,
                    "isNewMessage": false
                },
                {
                    "id": "msg_ArYqGbF72XIa6XT-IIuuKXEM2Nbe2Vo8nDVhZpZLf-w",
                    "data": {
                        "text": "This is a sample message from channel API"
                    },
                    "sender": {
                        "clientID": "clt_e_Gb4AZqCdBDWltP2QGUEX-OfPL6I0BW8IqdHxNPFFg",
                        "profilePictureURL": "https://cdn.getchannel.co/img/characters/2.png"
                    },
                    "createdAt": "2017-12-04T08:19:06.673603Z",
                    "isFromBusiness": true,
                    "isOwner": true,
                    "isNewMessage": false
                }
            ],
            "next": "/api/thread/messages?last=370&limit=20",
            "ID": "thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg"
        }
    }
}

Use this endpoint to load messages in thread.

HTTP Request

GET /conversations/<threadID>?last=<last>&limit=<limit>

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

URL Query String

Parameter Description Required
last last record returned use to paging NO
limit number of record that you need NO

Send new message

curl "https://api.getchannel.co/thread/messages?threadID=thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST -d '{"data" : {"text":"This is a sample message from channel API"}}'

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": {
            "id": "msg_ZF8bkctcoB0WbpwQx6rczAEbWeYDq2hJI3rzndSf9iM",
            "data": {
                "text": "This is a sample message from channel API"
            },
            "sender": {
                "clientID": "clt_e_Gb4AZqCdBDWltP2QGUEX-OfPL6I0BW8IqdHxNPFFg",
                "profilePictureURL": "https://cdn.getchannel.co/img/characters/2.png"
            },
            "createdAt": "2017-12-04T08:17:57.330573772Z",
            "isFromBusiness": false,
            "isOwner": false,
            "isNewMessage": false
        }
    }
}

Use this endpoint to send a new message from current client to specific thread.

HTTP Request

POST /thread/messages?threadID=<threadID>

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

HTTP Body

Parameter Description Required
data See Message Protocal YES

URL Query String

Parameter Description Required
threadID conversation threadID YES

Invite Conversation

curl "https://api.getchannel.co/thread/thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg/join" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to join conversation.

HTTP Request

POST /conversations/<threadID>/join

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

Accept Conversation

curl "https://api.getchannel.co/thread/thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg/join" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to join conversation.

HTTP Request

POST /conversations/<threadID>/join

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES

Leave Conversation

curl "https://api.getchannel.co/thread/thd_1LoCE2jLsTBKwabSmYOHx5q6GMnz5XpUdMZxWmvOFmg/leave" \
-H "X-Channel-Application-Key:app_dK5cqQHzHiSYE6DfW7SfCUDemfj444LmEmow0OkpyUw" \
-H "X-Channel-Client-ID:clt_GAk3s82H3YDx9iDG7jJ6ZQ4hbG1embKonrs5UQkxFQw" \
-X POST

The above command returns “success” JSON structured like this:

{
    "code": 200,
    "result": {
        "data": ""
    }
}

Use this endpoint to leave conversation.

HTTP Request

POST /conversations/<threadID>/leave

HTTP Header

Parameter Description Required
X-Channel-Application-Key an application key YES
X-Channel-Client-ID a returned clientID from new client API YES