logo
In-app Chat
Powered Byspreading
On this page

Batch delete friends


Overview

You can call this operation to batch delete up to 20 friends for a user in a one-way or two-way manner. If you need a higher limit (50 at maximum), contact ZEGOCLOUD technical support.

In this example, one-way deletion and two-way deletion are explained.

  • One-way deletion: If user A deletes user B in a one-way manner, user B is no longer a friend of user A, but not vice versa.
  • Two-way deletion: If user A deletes user B in a two-way manner, they are no longer friends with each other.

After friends are deleted, the client of the user receives the friend list update notification in the following ZIM SDK callbacks.

iOSAndroidmacOSWindows
friendListChangedonFriendListChangedfriendListChangedonFriendListChanged
WebFlutterReact Native
friendListChangedonFriendListChangedfriendListChanged

Operation prototype

  • Request method: POST
  • Request URL: https://zim-api.zego.im/?Action=DeleteFriends
  • Protocol: HTTPS
  • QPS limit: 20 calls per second

Request parameters

The following table describes only the operation-specific request parameters and some common request parameters. For the complete list of common request parameters, see the Public request parameters section of the Accessing Server APIs topic.

ParameterTypeRequiredDescription
FromUserIdStringYesThe ID of the registered user whose friends are to be deleted.
UserIdsArray of StringYesThe list of IDs of users to be deleted. Up to 20 user IDs can be included.
DeleteTypeNumberYesThe deletion type. Valid values:
  • 0: two-way deletion;
  • 1: one-way deletion.
Note

The `FromUserId` and `UserId` parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ' ', ', ', '|', '~'.

Sample request

  • Request URL:

    Untitled
    https://zim-api.zego.im/?Action=DeleteFriends
    &<Common request parameters>
    
    1
    Copied!
  • Request body:

    Untitled
    {
        "FromUserId": "zego_user",
        "UserIds": [
            "user_id1",
            "user_id2"
        ],
        "DeleteType": 1
    }
    
    1
    Copied!

Response parameters

ParameterTypeDescription
CodeNumber

The return code.

Note
When you request to delete multiple friends at a time, take note of the following items:
  • If one or more friends are successfully deleted, 0 is returned. For more information, see ErrorList.
  • If all friends fail to be deleted, a corresponding code is returned. For more information, see Return codes.
MessageStringThe description of the request result.
RequestIdStringThe request ID.
ErrorListArray of Object

The list of failed results.

  • If Code is 0:

    • If ErrorList is empty, all specified friends are successfully deleted.
    • If ErrorList is not empty, some specified friends fail to be deleted. In this case, see SubCode.
  • If Code is not 0 :

    • If ErrorList is empty, one or more parameters are invalid, the QPS limit is exceeded, or a system error occurs.
    • If ErrorList is not empty, all specified friends fail to be deleted.
└UserIDStringThe ID of the user failing to be deleted.
└SubCodeNumberThe code returned when the request fails.

Sample response

Untitled
{
    "Code": 0,
    "Message": "success",
    "RequestId": "343649807833778782",
    "ErrorList": [
        {
            "UserId": "usera2",
            "SubCode": 660800022
        }
    ]
}
1
Copied!

Return codes

The following table describes only the return codes related to the business logic of the operation. For the complete list of return codes, see Return codes.

Return CodeDescriptionSolution
660000002Invalid parameter.Check the input parameter.
660300005The QPS limit specified in AppID is exceeded.Try again later.
660500002FromUserId is not registered.Register FromUserId.
660800019The number of friends to be deleted at a time exceeds the limit.Reduce the number of friends to be deleted at a time.
660800022Repeated user IDs exist.Delete or modify repeated IDs.
660800033Any string in the UserIds parameter cannot be the same as the value of the FromUserId parameter.Modify the string in the UserId parameter that is the same as the value of the FromUserId parameter.
660800034The user is not a friend of FromUserId.No handling is required.

Previous

Check blockships

Next

Delete all friends