3 User Endpoint

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:

KeyTypeDescription
user_id (required)stringUser Id in Qiscus Server, cannot contains symbol, except .-_@
username (required)<br>stringName of user
password (optional)stringUser password in Qiscus Server, if password is provided and user exists, the user’s password will be updated
avatar_url (optional)<br>stringUser avatar url
extras (optional)jsonYou 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:

KeyTypeDescription
user_id (required)stringUser 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:

KeyTypeDescription
user_id (required)StringUser 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)TypeDescription
pageintdefault: 1<br>
limitintdefault: 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
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *