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

# messageKey()

> Function exported by @botmesh/core/spi.

```ts theme={null}
function messageKey(ref): string;
```

Defined in: [core/provider.ts:1607](https://github.com/andresayac/botmesh/blob/main/packages/core/src/core/provider.ts#L1607)

Unambiguous storage key for a message: `<chatId>:<id>` with `%` and `:`
percent-escaped in each part, so the single raw `:` always separates the
two. Ids without `:` or `%` (WhatsApp JIDs, Telegram/Discord numbers…) get
the exact same key as before; ids that do contain them (Twilio's
`whatsapp:+1555…` chat ids) no longer collide — the former plain
`${chatId}:${id}` mapped `('a:b', 'c')` and `('a', 'b:c')` to one key.

Persistent stores that wrote keys in the old format read and delete through
[legacyMessageKey](https://botmesh.afaya.com.co/api/core/spi/functions/legacyMessageKey.md) as a fallback (see the store READMEs).

## Parameters

| Parameter | Type |
| - | - |
| `ref` | [`MessageRef`](https://botmesh.afaya.com.co/api/core/interfaces/MessageRef) |

## Returns

`string`


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