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

# XblPresenceSetPresenceAsync

> XblPresenceSetPresenceAsync

Sets presence info for the current user context.

## Syntax

```cpp theme={null}
HRESULT XblPresenceSetPresenceAsync(  
         XblContextHandle xblContextHandle,  
         bool isUserActiveInTitle,  
         XblPresenceRichPresenceIds* richPresenceIds,  
         XAsyncBlock* async  
)  
```

### Parameters

*xblContextHandle*   \_In\_\
Type: [XblContextHandle](https://docs.xbox.com/reference/live/xsapi-c/types_c/handles/xblcontexthandle.md)

XBOX services context for the local user.

*isUserActiveInTitle*   \_In\_\
Type: bool

Indicates if the current user context is currently active or inactive in the title. The application can choose to set this based on an amount of inactivity.

*richPresenceIds*   \_In\_opt\_\
Type: [XblPresenceRichPresenceIds\*](https://docs.xbox.com/reference/live/xsapi-c/presence_c/structs/xblpresencerichpresenceids.md)

Optional pointer to struct which controls the rich presence strings.

*async*   \_In\_\
Type: XAsyncBlock\*

The AsyncBlock for this operation.

### Return value

Type: HRESULT

HRESULT return code for this API operation. Possible error codes include the following. This list isn't exhaustive.

| Return code | Description |
| - | - |
| S\_OK | The operation started. |
| E\_INVALIDARG | *xblContextHandle* or *async* is null. |
| E\_XBL\_NOT\_INITIALIZED | [XblInitialize](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblinitialize.md) hasn't been called. |

## Remarks

To get the result of the service call, call [XAsyncGetStatus](https://docs.xbox.com/reference/system/xasync/functions/xasyncgetstatus.md) inside the AsyncBlock callback or after the AsyncBlock is complete. To choose how to handle a failed result, pass it to [XblGetErrorCondition](https://docs.xbox.com/reference/live/xsapi-c/errors_c/functions/xblgeterrorcondition.md). For example, `XblErrorCondition::Network` indicates a network connectivity problem, `XblErrorCondition::Auth` indicates an authentication problem, and `XblErrorCondition::Http429TooManyRequests` indicates that the title called the Presence service too often.

Call this function when the player's activity changes. The Presence service limits how often each user and title can write presence. For more information, see [Fine-grained rate limiting](https://docs.xbox.com/services/xbox-services/develop/best-practices/live-fine-grained-rate-limiting.md).

If *richPresenceIds* isn't null but its *scid* or *presenceId* member is empty, the request includes only the active or inactive state and doesn't include a Rich Presence string.

For an example, see [Updating a user's Presence via XSAPI C](https://docs.xbox.com/services/xbox-services/community/presence/how-to/live-updating-user-presence.md).

## Requirements

**Header:** presence\_c.h

**Library:** Microsoft.Xbox.Services.142.C.lib or Microsoft.Xbox.Services.143.C.lib

## See also

[presence\_c](https://docs.xbox.com/reference/live/xsapi-c/presence_c/presence_c_members.md)


## Related topics

- [XblPresenceRichPresenceIds](https://docs.xbox.com/reference/live/xsapi-c/presence_c/structs/xblpresencerichpresenceids.md)
- [Rich Presence overview](https://docs.xbox.com/services/xbox-services/community/presence/live-presence-overview.md)
- [Updating a user's Presence via XSAPI C](https://docs.xbox.com/services/xbox-services/community/presence/how-to/live-updating-user-presence.md)
- [Optional services](https://docs.xbox.com/build/gdk-and-engines/optional-services.md)
- [Updating a user's Presence via REST](https://docs.xbox.com/services/xbox-services/community/presence/how-to/live-updating-presence-rest.md)
