> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# mint_handle

> Issue a signed handle for a conversation, server-side.

[ref-chatgateway]: /docs/server-sdks/reference/python/agents/chat-gateway

[readhandle]: /docs/server-sdks/reference/python/agents/chat-gateway/read-handle

Issue a signed handle for a new conversation, generating a conversation id when you don't supply
one. The handle carries the id and an expiry, signed with the gateway's HMAC secret.

The browser never names a conversation. If it did, a publishable key plus a guessed id would be
enough to continue someone else's chat, so signing means a caller can only present handles this
gateway issued.

The router mints handles for you. Reach for this when you want to hand a page a handle for a
conversation your server already started.

## **Parameters**

**`conversation_id`** `str | None`

The conversation to bind the handle to. Generates a random id when omitted.

---

## **Returns**

`str` — the signed handle, in the form `<payload>.<signature>`, both base64url.

## **Example**

```python {8}
from signalwire.ai_chat import ChatGateway

gateway = ChatGateway(
    config_url="https://bayview-taxi.example.com/swml",
    secret="a-stable-secret-across-replicas",
)

handle = gateway.mint_handle("chat-8f21")
# hand `handle` to the page; it sends it back on every later call
```

Read one back with [`read_handle()`][readhandle].