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

# Set User Attribute — POST /api/v1/add-user-attribute

> Store a custom key-value attribute on a Botsify bot user to enable personalized conversation flows, targeted segments, and dynamic content delivery.

Use this endpoint to attach a custom key-value attribute to a specific Botsify bot user. User attributes let you store contextual information — such as subscription plan, preferred language, or loyalty tier — directly on the user record, which you can then reference in bot flows for personalization or use to build targeted segments. You must supply your bot API key in the body or the `X-Api-Key` header.

## Request

**apikey** `string` *required*

Your bot's API key. You may alternatively supply this value in the `X-Api-Key` request header instead of the body.

**messenger\_user\_id** `string` *required*

The unique identifier of the target bot user to whom the attribute will be applied.

**key** `string` *required*

The name of the custom attribute you want to set (e.g., `plan`, `city`, `account_tier`).

**value** `string` *required*

The value to assign to the attribute key (e.g., `premium`, `New York`, `gold`).

**fbId** `string`

An alternative user identifier. You may supply this instead of or in addition to `messenger_user_id` when working with users identified by their Messenger session ID.

## Example Request

```bash theme={null}
curl --request POST \
  --url https://app.botsify.com/api/v1/add-user-attribute \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: YOUR_BOT_API_KEY' \
  --data '{
    "apikey": "BOT_KEY",
    "messenger_user_id": "user-123",
    "key": "plan",
    "value": "premium"
  }'
```

## Response

A successful request returns a JSON object confirming that the attribute was stored against the user record. The response echoes back the `key` and `value` that were applied, along with the affected user identifier.

```json theme={null}
{
  "success": true,
  "messenger_user_id": "user-123",
  "key": "plan",
  "value": "premium"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.