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

# canonicalize • AI Agent SDK

> canonicalize: Map a raw, potentially-volatile platform id to a stable canonical id.

# canonicalize

Method

> This is a method of the [**BasePlatformAdapter**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/BasePlatformAdapter.md) class in the [**base**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/base.md) module.

Map a raw, potentially-volatile platform id to a stable canonical id.

Consulted on the session-key path *before* link/pairing resolution so
an alias/format change for the *same* human (e.g. WhatsApp's JID→LID
migration, a number↔UUID alias flip) collapses to one stable session
key — preserving transcript, memory and in-flight run-state — instead
of silently forking the conversation.

This is the :class:`~praisonaiagents.gateway.protocols.
IdentityCanonicalizerProtocol` method, so a `BasePlatformAdapter`
conforms structurally and can be handed anywhere that protocol is
accepted.

Default is the identity function, so adapters that do not override this
are fully backward-compatible (the raw id keys the session exactly as
before). Implementations MUST be deterministic and total: return the
raw id unchanged when no canonical form is known, never raise.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def canonicalize(platform: str, raw_user_id: str) -> str
```

## Parameters

**platform** `str` *required*

No description available.

**raw\_user\_id** `str` *required*

No description available.

### Returns

**Returns** `str`

The result of the operation.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/bots/base.py#L682)
>
> `praisonaiagents/bots/base.py` at line 682


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