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

# User and agent

> USER is someone in your app. AGENT is your team speaking from the dashboard or the API.

<Tip>
  In Chat, **user** and **agent** are not product roles. They are **who is speaking in the conversation**. That changes webhooks, metrics, and which JWT you put in the app.
</Tip>

## In short

|                         | User (`USER`)                                  | Agent (`AGENT`)                                  |
| ----------------------- | ---------------------------------------------- | ------------------------------------------------ |
| Who                     | Person signed in **in your app**               | Workspace member (support, ops, company bot)     |
| How to create           | `PUT /v1/chat/users` (default)                 | `POST /v1/chat/agents` (links `workspaceUserId`) |
| JWT in the client app   | Yes                                            | No. The client app must not get an agent JWT     |
| Send from the dashboard | No                                             | Yes — the dashboard speaks as an agent           |
| Send with API Key       | Pass `senderExternalUserId` of a USER or AGENT | Same: `senderExternalUserId` is who shows up     |
| Webhook                 | `chat.received`                                | `chat.sent`                                      |

## When to use USER

Use `USER` for **everyone who joins chat from your application**. Each person has a stable `externalUserId` in **your** database.

Typical flow:

1. The person signs in to your app
2. Your backend upserts them (`PUT /v1/chat/users`)
3. Your backend mints the JWT (`POST /v1/chat/users/token`)
4. The app opens the WebSocket with that JWT and sends as that person

The JWT carries `kind: USER`. Whoever holds that token **is** that person in the conversation.

## When to use AGENT

Use `AGENT` when the message should appear as **your company**, not an end user.

Typical cases:

* Someone on the team replies in the **dashboard** (Chat or Inbox) — Notifique already creates the agent `agent:{workspaceUserId}`
* Your backend posts a notice in the thread **as support**
* You want **sent** (agent) vs **received** (user) metrics on the Chat App detail

```http theme={null}
POST /v1/chat/agents
Content-Type: application/json
Authorization: Bearer sk_live_xxxxx
```

```json theme={null}
{
  "chatAppId": "clxxapp...",
  "workspaceUserId": "clxxuser...",
  "externalUserId": "agent:clxxuser...",
  "name": "Ana (support)"
}
```

`workspaceUserId` must be a workspace member. The default `externalUserId` is `agent:{workspaceUserId}`.

Then send as that agent:

```json theme={null}
{
  "from": "clxxapp...",
  "to": ["cnv_xxxxx"],
  "type": "text",
  "payload": { "message": "Hi, how can I help?" },
  "senderExternalUserId": "agent:clxxuser..."
}
```

## What not to mix

* **Do not** put an `AGENT` JWT in the customer app. The customer speaks with a `USER` JWT.
* **Do not** register staff as `USER` if they answer from the dashboard — the webhook would fire as `chat.received`.
* Two `USER`s in a 1:1 is people in your product talking. A `USER` and an `AGENT` is support.

## Chat App flags

Who can **create a conversation**, **create a group**, and **add members** with a user JWT applies to anyone with a user token. An agent via API Key ignores those flags: the backend can always create.

See [Quick Start](/en/chat-api/como-funciona/quick-start) and [Send messages](/en/chat-api/como-funciona/enviar-mensagens).
