> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PFFriendsServerAddFriendAsync

> Adds the Friend user to the friendlist of the user with PlayFabId. At least one of FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName.

Adds the Friend user to the friendlist of the user with PlayFabId. At least one of FriendPlayFabId,FriendUsername,FriendEmail, or FriendTitleDisplayName should be initialized.

## Syntax

```cpp theme={null}
HRESULT PFFriendsServerAddFriendAsync(  
    PFEntityHandle titleEntityHandle,  
    const PFFriendsServerAddFriendRequest* request,  
    XAsyncBlock* async  
)  
```

### Parameters

**`titleEntityHandle`**   PFEntityHandle

PFEntityHandle for a title Entity obtained using PFAuthenticationGetEntityWithSecretKeyAsync.

**`request`**   [PFFriendsServerAddFriendRequest\*](/services/playfab/api-references/c/pffriendstypes/structs/pffriendsserveraddfriendrequest)

Populated request object.

**`async`**   XAsyncBlock\*<br />*Inout*

XAsyncBlock for the async operation.

### Return value

Type: HRESULT

Result code for this API operation.

## Remarks

This API is available on Win32, Linux, and macOS. See also ServerGetFriendsListAsync, ServerRemoveFriendAsync, ServerSetFriendTagsAsync. Call XAsyncGetStatus to get the status of the operation. If the service call is unsuccessful, the async result will be E\_PF\_USERS\_ALREADY\_FRIENDS or any of the global PlayFab Service errors. See doc page "Handling PlayFab Errors" for more details on error handling.

## Requirements

**Header:** PFFriends.h

## See also

[PFFriends members](/services/playfab/api-references/c/pffriends/pffriends_members)


## Related topics

- [Services C API overview - PFFriends.h](/services/playfab/api-references/c/pffriends/pffriends_members.md)
- [PFFriendsServerRemoveFriendAsync](/services/playfab/api-references/c/pffriends/functions/pffriendsserverremovefriendasync.md)
- [PFFriendsServerGetFriendsListAsync](/services/playfab/api-references/c/pffriends/functions/pffriendsservergetfriendslistasync.md)
- [PFFriendsServerSetFriendTagsAsync](/services/playfab/api-references/c/pffriends/functions/pffriendsserversetfriendtagsasync.md)
- [PFFriendsServerAddFriendRequest](/services/playfab/api-references/c/pffriendstypes/structs/pffriendsserveraddfriendrequest.md)
