User
This section contains user Qiscus Chat SDK behavior. You can do login or register user with meta data, update user profile with metadata, get users who have unread count, and get all users data.
You need to register the user to Qiscus Server, or if you already have Qiscus Account, you can login or update user properties except the userId.
Login or Register
You can use this endpoint to create new user if it does not exist yet, or login in Qiscus Server if does exist, or update user's data, such as password, avatar, and, extras. You also can send an extra data in user's data by using extras payload, such as you want to add user type, then you can put key as user_type and put your desired value.
Request:
https://api.qiscus.com/api/v2.1/rest/login_or_register.
Header:
"Content-Type":"application/json"
"QISCUS-SDK-APP-ID":"Your Qiscus App Id"
"QISCUS-SDK-SECRET":"Your Qiscus SDK Secret Key"
Endpoint:
[POST] /login_or_register
Params:
Key | Type | Description |
---|---|---|
user_id (required) | string | User Id in Qiscus Server, cannot contains symbol, except .-_@ |
username (required) | string | Name of user |
password (optional) | string | User password in Qiscus Server, if password is provided and user exists, the user's password will be updated |
avatar_url (optional) | string | User avatar url |
extras (optional) | json | You can define meta data here using valid JSON |
Example request:
curl -X POST \
https://api.qiscus.com/api/v2.1/rest/login_or_register \
-H 'Content-Type: application/json' \
-H 'QISCUS-SDK-APP-ID: sdksample' \
-H 'QISCUS-SDK-SECRET: 2820ae9dfc5362f7f3a10381fb89afc7' \
-d '{
"user_id": "guest99@qiscus.com",
"password": "password",
"username": "QISCUS demo user",
"avatar_url": "https://image.url/image.jpeg"
}'
Response:
{
"results": {
"user": {
"avatar_url": "https://image.url/image.jpeg",
"extras": {},
"user_id": "guest99@qiscus.com",
"username": "QISCUS demo user"
}
},
"status": 200
}
Note : password is optional, it will generate random string on the backend if you don't pass it during User creation through this API. However, please note for those users already created you can not use this API login_or_register without passing password value
Get User Profile
To get user's profile data.
Request:
https://api.qiscus.com/api/v2.1/rest/user_profile
Header:
"Content-Type":"application/json"
"QISCUS-SDK-APP-ID":"Your Qiscus App Id"
"QISCUS-SDK-SECRET":"Your Qiscus SDK Secret Key"
Endpoint:
[GET] /user_profile
Params:
Key | Type | Description |
---|---|---|
user_id (required) | string | User id in Qiscus Server, cannot contains symbol, except .-_@ |
Example request:
curl -X GET \
'https://api.qiscus.com/api/v2.1/rest/user_profile?user_id=guest@qiscus.com' \
-H 'Content-Type: application/json' \
-H 'QISCUS-SDK-APP-ID: sdksample' \
-H 'QISCUS_SDK_SECRET: 2820ae9dfc5362f7f3a10381fb89afc7'
Response:
{
"results": {
"user": {
"avatar_url": "https://d1edrlpyc25xu0.cloudfront.net/kiwari-prod/image/upload/EoQ084KxNc/avatar-blank_ur7lzt.jpg",
"extras": {},
"user_id": "guest@qiscus.com",
"username": "Qiscus Demo"
}
},
"status": 200
}
Reset User Token
To reset user's token.
Request:
https://api.qiscus.com/api/v2.1/rest/reset_user_token
Headers:
"Content-Type":"application/json"
"QISCUS-SDK-APP-ID":"Your Qiscus App Id"
"QISCUS-SDK-SECRET":"Your Qiscus SDK Secret Key"
Endpoint:
[POST] /reset_user_token
Params:
Key | Type | Description |
---|---|---|
user_id (required) | String | User id in Qiscus Server, cannot contains symbol, except .-_@ |
Example request:
curl -X POST \
https://api.qiscus.com/api/v2.1/rest/reset_user_token \
-H 'Content-Type: application/json' \
-H 'QISCUS-SDK-APP-ID: sdksample' \
-H 'QISCUS-SDK-SECRET: 2820ae9dfc5362f7f3a10381fb89afc7' \
-d '{
"user_id": "guest2@qiscus.com"
}'
Response:
{
"results": {
"token": "ZwgqkeWfsM1k3GCcSgXl"
},
"status": 200
}
Get User List
To get list of users.
Request:
https://api.qiscus.com/api/v2.1/rest/get_user_list
Headers:
"QISCUS-SDK-APP-ID":"Your Qiscus App Id"
"QISCUS-SDK-SECRET":"Your Qiscus SDK Secret Key"
Endpoint:
[GET]/get_user_list
Params:
Key (Optional) | Type | Description |
---|---|---|
page | int | default: 1 |
limit | int | default: 20, max: 100, if the limit more than 100 then return 20 |
Example request:
curl -X GET \
'https://api.qiscus.com/api/v2.1/rest/get_user_list?page=1&limit=2' \
-H 'QISCUS-SDK-APP-ID: sdksample' \
-H 'QISCUS_SDK_SECRET: 2820ae9dfc5362f7f3a10381fb89afc7'
Response:
{
"results": {
"meta": {
"total_data": 791,
"total_page": 395
},
"users": [
{
"avatar_url": "https://d1edrlpyc25xu0.cloudfront.net/kiwari-prod/image/upload/0AlS8O2rr_/1507606591-Lina_icon.png",
"created_at": "2017-10-12T04:07:10.926973Z",
"email": "guest2@qiscus.com",
"extras": {},
"id": 188202,
"name": "guest2",
"updated_at": "2017-10-12T04:07:10.926973Z",
"username": "guest2"
},
{
"avatar_url": "https://d1edrlpyc25xu0.cloudfront.net/kiwari-prod/image/upload/75r6s_jOHa/1507541871-avatar-mine.png",
"created_at": "2019-10-30T07:47:01.323761Z",
"email": "rere",
"extras": {},
"id": 65527309,
"name": "rere",
"updated_at": "2019-10-30T07:47:01.323761Z",
"username": "rere"
}
]
},
"status": 200
}