Overview
Register a user and obtain the token that the Android, iOS, or Web client uses to connect to the IM Server. Tokens are permanent by default. You can configure token expiration in application management.
After obtaining a token, cache it on your application server and return it directly when the user signs in to reduce network requests.
Request
Authentication: Add authentication headers to the request. See Authentication.
Method:
POST
Rate limit:
100 requests/second
Endpoint: https://API domain/apigateway/users/register
Content-Type:
application/json
Request Parameters
| Parameter | Data Type | Required | Description | |
|---|---|---|---|---|
| user_id | string | Yes | User ID. Maximum length: 32 characters. | |
| nickname | string | No | User nickname. An empty value may cause the nickname to display incorrectly in the client. Maximum length: 50 characters. | |
| user_portrait | string | No | User avatar URL. An empty value may cause the avatar to display incorrectly in the client. Maximum length: 200 characters. | |
| ext_fields | map | No | Additional user information as key-value pairs. Keys can contain up to 50 characters; values can contain up to 2,000 characters. | |
| permit_convers | array | No | Access-control settings that restrict the token to specified conversations and limit the amount of message history available in each conversation. Each conversation's target_id can contain up to 32 characters. |
Request Example
POST /apigateway/users/register HTTP/1.1
appkey: appkey
signature: 2e639ae3600a4sdff61fb88b76f485b
nonce: nonce
timestamp: 1672568121910
Content-Type: application/json
{
"user_id": "user1",
"nickname": "nickname",
"user_portrait": "https://portrait.example.com/avatar.png",
"ext_fields":{
"k1":"v1",
"k2":"v2"
},
"permit_convers":[
{
"target_id":"groupid1",
"channel_type":2,
"max_his_msg_count":100
}
]
}
Response Parameters
| Parameter | Data Type | Description | |
|---|---|---|---|
| code | int | Status code. See Status Codes for details. | |
| user_id | string | User ID. | |
| token | string | Authentication token returned to the client for connecting to the IM Server. |
Response Example
{
"code":0,
"msg":"sucess",
"data":{
"user_id":"user1",
"token":"tokenStr"
}
}