Application API
The Application APIs are REST APIs that are based on HTTP protocol and used for accessing an Individual user’s data. These are developed for client-side programming languages to retrieve data into your Web & Mobile Applications.
NOTE: The Application APIs can also be accessed using the Admin API’s request header.
Find below details to access Application APIs.
Base URL
Application APIs base URL format.
https://api.channelize.io/v1/
Header
Application APIs header format.
Content-Type: application/json
Public-Key: YOUR_PUBLIC_KEY
Authorization: Bearer base_64_encode(ACCESS_TOKEN)
Content-Type: Every API request should include
Content-Type
having valueapplication/json
.Public Key: For authorizing APIs you need Public Key, find your Public Key from Channelize.io dashboard. Go to Overview > Application Credentials.
- Authorization: A Base64 encoded Access Token is required in all API requests except login and verify access token.
How to get Access Token?
Here are the steps to get Access Token:
- A user needs to login to the Channelize.io server using the Login API call. Here is the syntax for the login request, its header, and the response.
POST https://api.channelize.io/v1/users/login
Content-Type: application/json
Public-Key: YOUR_PUBLIC_KEY
{
"email": "YOUR_EMAIL",
"password": "YOUR_PASSWORD",
"authenticationType": 1
}
{
"id": "IVhBHzWChmlcZtSn7j7hIHjejdFhOihzVQvwmwjNmevcNQtUuFpgxi16v8uabcde",
"ttl": 1209600,
"created": "2019-04-25T10:56:12.311Z",
"userId": "15"
}
curl -XPOST -H 'Content-Type: application/json' -H 'Public-Key: YOUR_PUBLIC_KEY' -d '{
"email": "YOUR_EMAIL",
"password": "YOUR_PASSWORD",
"authenticationType": 1
}' 'https://api.channelize.io/v1/users/login'
In response to the Login API request, an Access Token is received. In the above response, the parameter with name id has the Access Token which is required in Application APIs header.
To use this Access Token, you need to encode it to Base64.
Example Request
Content-Type: application/json
Public-Key: sABSGLytBJGQTaLm
Authorization: Bearer SVZoQkh6V0NobWxjWnRTbjdqN2hJSGplamRGaE9paHpWUXZ3bXdqTm1ldmNOUXRVdUZwZ3hpMTZ2OHVhYmNkZQ==
Login
Channelize.io server provides two login options.
Login with User Id
This login method is useful for any of the below use-cases:
- Channelize.io real-time messaging is integrated into application / website, and you want single sign-on b/w both i.e the user will auto-login to the messaging interface with the login in your application / website.
- If the email address or password is not mandatory to login into your application / website.
- If you do not want to save the user's email and password on your Channelize.io services.
POST https://api.channelize.io/v1/users/login
Body Params
This table lists all possible parameters this API call supports.
Name | Type | Required | Description |
---|---|---|---|
authenticationType | number | yes | Specifies the type of authentication. Allowed values are 0 and 1. Value should be 0 for login with userId and token. |
userId | string | yes | The unique ID of the user. |
pmClientServerToken | string | yes | Specifies the token for the user that is generated by your application at the backend. |
pmClientServerToken is a login token which is generated and managed by your Main Application server and will ensure that only a verified user of your application will have access to Channelize.io real-time messaging. Here are the detailed steps on how single sign-on will work b/w your Main Application and Channelize.io using pmClientServerToken:
- Generate a token every time a user logs into your Main Application.
- To get login token verified create a login token callback URL which would be configured in Channelize.io Dashboard.
- In Channelize.io Dashboard under App Settings > Security configure the generated callback URL.
Note: pmClientServerToken and accessToken both are different. The accessToken is saved on Channelize.io server and is used to provide users access to Channelize.io powered messaging. While pmClientServerToken is saved on your main application server and is passed to Channelize.io login API to login a user to Channelize.io server. pmClientServerToken is also known as login token, as this is used for the login process.
Login token Callback URL
Login Token Callback URL is a POST API call which is developed at your end and is verified by pmClientServerToken. Once it’s verified the pmClientServerToken will be deleted and a response with 200 status code is returned.
Login with Email and Password
Use this login method for Standalone chat applications where email & password are mandatory for users to login.
POST https://api.channelize.io/v1/users/login
Body Params
This table lists all possible parameters this API call supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
authenticationType | number | yes | - | Specifies the type of authentication. Allowed values are 0 and 1 . Value should be 1 for login with email and password. |
string | yes | - | The email address of user. | |
password | string | yes | - | The login password of user. |
Response Body
Status Code : 200
{
"id": "IVhBHzWChmlcZtSn7j7hIHjejdFhOihzVQvwmwjNmevcNQtUuFpgxi16v8uabcde",
"ttl": 1209600,
"created": "2019-04-25T10:56:12.311Z",
"userId": "15"
}
Response Body
Status Code : 200
{
"id": "IVhBHzWChmlcZtSn7j7hIHjejdFhOihzVQvwmwjNmevcNQtUuFpgxi16v8uabcde",
"ttl": 1209600,
"created": "2019-04-25T10:56:12.311Z",
"userId": "15"
}
Verify Access Token
Allows to verify the generated access token.
POST https://api.channelize.io/v1/users/verify_access_token
Body Params
This table lists all possible parameters this API call supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
accessToken | string | yes | - | The access token of login. |
Status Code : 200
{
"id": "QBwo1bGPDWIIHE3GBoSnAFAnXLVyC6EmmXTMW3aAU8wGDenbYFfUsabcde",
"ttl": 1209600,
"created": "2018-11-05T12:41:46.904Z",
"userId": "152",
"user": {
"id": "152",
"displayName": "Channelize Demo User",
"language": "en",
"profileImageUrl": "https://channelize.io/profileImage.jpg",
"profileUrl": "https://channelize.io/profile",
"isOnline": true,
"visibility": true,
"notification": true,
"lastSeen": "2019-04-23T09:26:18.320Z",
"lastLogin": "2019-04-25T11:30:37.988Z",
"lastActivity": "2019-04-25T11:30:37.990Z",
"createdAt": "2018-05-25T11:52:39.000Z",
"updatedAt": "2018-05-25T11:52:39.000Z",
"email": "test1@gmail.com"
}
}
Logout User
Allows to log out a user from Channelize.io. The generated access token will expire on logout.
POST https://api.channelize.io/v1/users/logout
Body Params
This table lists all possible parameters this API call supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
deviceId | string | no | - | Specifies the device ID. This device ID should be the unique id of your device (Android/iOS OR Web Browser). |
Response Body
Status Code : 204
No Content