# Message IDs

Tag individual replies with your own id so you can reference them later — for example, to attach feedback.

A message id is your own identifier for a single reply in a conversation. Attaching it lets you reference that exact message later — most commonly to [record feedback](/docs/instrument/record-feedback.md) on it, even after the turn has finished.

## Set a message id

Call `set_message_id` / `setMessageId` inside a session, on the turn you want to tag. It applies to the turn's spans and propagates to the child spans created within the same context.

:::tabs
:::tab[Python]

```python
from brizz import set_message_id, start_session

with start_session("session-123"):
    set_message_id(message.id)  # your own id for this reply

    reply = agent.run(prompt)
```

:::tab[Node.js]

```typescript
import { startSession, setMessageId } from '@brizz/sdk';

await startSession('session-123', async () => {
  setMessageId(message.id); // your own id for this reply

  return agent.run(prompt);
});
```

:::

The id is emitted as `brizz.message.id`. Use whatever id you already have for the reply — a database row id, a chat message id, or a UUID you generate.

## Scoped form

To apply the message id to a single block and reset it on exit, use the scoped wrapper instead of the imperative setter.

:::tabs
:::tab[Python]

```python
from brizz import message

with message("msg-123"):
    reply = agent.run(prompt)
```

:::tab[Node.js]

```typescript
import { callWithMessageId } from '@brizz/sdk';

await callWithMessageId('msg-123', () => agent.run(prompt));
```

:::

## See also

- [Record feedback](/docs/instrument/record-feedback.md) — attach a 👍/👎 or rating to the message you tagged.
- [Sessions](/docs/instrument/sessions.md) — the session a message belongs to.
- [Identify users](/docs/instrument/identify-users.md) — attach the end-user behind the message.
