Ban Accounts
Update time: 2022/12/12 09:34:24
Banning accounts
If an account is banned, you cannot log in. If the account is logged in when the ban operation is performed, the current login status will not be affected. You can still send and receive messages using the account. Therefore, we recommend that you set the parameter to true and invalidate the current login.
For security reasons, existing accounts can only be banned, but cannot be deleted; after accounts are banned, accounts are still counted in the total number of accounts in the application.
Request URL
POST https://api-sg.netease.im/nimserver/user/block.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
-
For information about headers in a POST request, see Overview.
-
The POST request body contains the following parameters:
Parameter | Type | String upper limit | Required | Example | Description |
accid | String | 32 | Yes | "123456" | The CommsEase account that you want to ban |
needkick | boolean | / | Optional | true | Whether to kick out the banned user, the default value is no. |
kickNotifyExt | String | 256 | Optional | {"k":"v"} | Extension field whose value can be transparently transmitted to the client SDK. v7.7.0 or later is required. |
Response parameters
Parameter | Type | Example | Description |
code | int | 200 | Status code |
desc | String | {"Jack is not registered"} | Information returned upon if the ban operation fails. |
Example
Request example (curl)
curl -X POST -H "AppKey: go9dnk49bkd***9vmel1kglw0803mgq3" -H "Nonce: 4tgggerg***ow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9abb2***62cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api-sg.netease.im/nimserver/user/block.action'
Success response
"Content-Type": "application/json; charset=utf-8"
{
"code": 200
}
Error response
"Content-Type": "application/json; charset=utf-8"
{
"code": 414,
"desc": "Jack is not registered"
}
Unbanning a user
To unban a user, you can call the unban API.
Request URL
POST https://api-sg.netease.im/nimserver/user/unblock.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
-
For information about headers in a POST request, see Overview.
-
The POST request body contains the following parameters:
Parameter | Type | String upper limit | Required | Example | Description |
accid | String | 32 | Yes | "123456" | The CommsEase account that need to unban. |
Response parameters
Parameter | Type | Example | Description |
code | int | 200 | Status code |
desc | String | {"Jack is not registered"} | Information returned if the unban operation fails. |
Example
Request example (curl)
curl -X POST -H "AppKey: go9dnk49bkd9jd9vm***kglw0803mgq3" -H "Nonce: 4tggg***igwow323t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b6c9a***e1962cf3e6f7316fcc55583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=zhangsan' 'https://api-sg.netease.im/nimserver/user/unblock.action'
Success response
"Content-Type": "application/json; charset=utf-8"
{
"code": 200
}
Error response
"Content-Type": "application/json; charset=utf-8"
{
"code": 414,
"desc": "Jack is not registered"
}
Error codes
Error codes may be returned in the body of HTTP responses. For more information, see Error codes.