---
source_url: https://www.pubnub.com/docs/sdks/rest-api/set-user-state
title: Set user state
---

# Set user state

> For AI agents: documentation index at https://www.pubnub.com/llms-full.txt

Set the Presence state info for a given UUID.

| Path Parameters |
| --- |
| `sub_key`string—**REQUIRED**Your app's subscribe key from Admin Portal.Example: sub-c-50264475-1902-558x-d213-7p19052012n2 |
| `channel`string—**REQUIRED**The channel ID to perform the operation on. In the context of Presence, this parameter relates to a channel for which the new state will be applied or the existing state will be returned. Verify that channels are comprised of valid characters. You can use a single channel or multiple channels separated by a comma.Example: myChannel |
| `uuid`string—**REQUIRED**A UTF-8 encoded string of up to 92 characters used to identify the client.Example: myUniqueUserId |

| Query Parameters |
| --- |
| `channel-group`stringComma-separated list of channel group names to perform the operation on. In the context of Presence, this parameter relates to channel group name(s) to which you subscribe. You may subscribe to channels, channels and channel groups, or just channel groups.Note: Wildcard patterns (e.g., group.*) are not supported for channel groups. Use exact channel group names only.Example: myChannelGroup |
| `auth`stringString which is either the auth key (Access Manager legacy) or a valid token (Access Manager) used to authorize the operation if access control is enabled.Example: myAuthKey |
| `state`string—**REQUIRED**This value is an object that will be set for all specified channels. You must be present in a channel to set state for it.Example: %7B%22text%22%3A%22hey%22%7D |
| `callback`stringThe JSONP callback name to wrap the function in.Example: myCallback |
| `signature`stringSignature used to verify that the request was signed with the secret key associated with the subscribe key.If Access Manager is enabled, either a valid authorization token or a signature are required. Check Access Manager documentation for details on how to compute the signature. |
| `timestamp`integerUnix epoch timestamp used as a nonce for signature computation. Must have no more than ± 60 seconds offset from NTP. Required if signature parameter is supplied. |

| Responses |
| --- |
| `200`OKSchema — OPTIONALservice string — OPTIONALstatus integer — OPTIONALerror boolean — OPTIONALmessage string — OPTIONALpayload string — OPTIONAL | Schema—**OPTIONAL** | `service`string—**OPTIONAL** | `status`integer—**OPTIONAL** | `error`boolean—**OPTIONAL** | `message`string—**OPTIONAL** | `payload`string—**OPTIONAL** |
| Schema—**OPTIONAL** |
| `service`string—**OPTIONAL** |
| `status`integer—**OPTIONAL** |
| `error`boolean—**OPTIONAL** |
| `message`string—**OPTIONAL** |
| `payload`string—**OPTIONAL** |

sub_key
*
Type:
string
Your app's subscribe key from
[Admin Portal](https://admin.pubnub.com)
.
channel
*
Type:
string
The channel ID to perform the operation on.

In the context of Presence, this parameter relates to a channel for which the new state will be applied or the existing state will be returned.  Verify that channels are comprised of valid characters. You can use a single channel or multiple channels separated by a comma.
uuid
*
Type:
string
A UTF-8 encoded string of up to 92 characters used to
[identify the client](https://www.pubnub.com/docs/architecture/core-concepts.md)
.
channel-group
Type:
string
Comma-separated list of channel group names to perform the operation on.

In the context of Presence, this parameter relates to channel group name(s) to which you subscribe. You may subscribe to channels, channels and channel groups, or just channel groups.

Note:
Wildcard patterns (e.g.,
group.*
) are not supported for channel groups. Use exact channel group names only.
auth
Type:
string
String which is either the auth key (Access Manager legacy) or a valid token (
[Access Manager](https://www.pubnub.com/docs/security/access-control/overview.md)
) used to authorize the operation if access control is enabled.
state
*
Type:
string
This value is an object that will be set for all specified channels. You must be present in a channel to set state for it.
callback
Type:
string
The JSONP callback name to wrap the function in.
signature
Type:
string
Signature used to verify that the request was signed with the secret key associated with the subscribe key.

If Access Manager is enabled, either a valid authorization token or a signature are required.

Check
[Access Manager documentation](https://www.pubnub.com/docs/sdks/rest-api/access-manager-introduction.md)
for details on how to compute the signature.
timestamp
Type:
integer
Unix epoch timestamp used as a nonce for signature computation. Must have no more than ± 60 seconds offset from NTP.

Required if
signature
parameter is supplied.
service
Type:
string
Example:
"Presence"
status
Type:
integer
Example:
200
error
Type:
boolean
Example:
false
message
Type:
string
Example:
"OK"
payload
Type:
string
Example:
"{text:hey}"
Example Response

```
{
  "service": "presence",
  "status": 200,
  "error": false,
  "message": "OK",
  "payload": "{text:hey}"
}
```
