> ## 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.

# Generate Code • AI Agent SDK

> generate_code: Generate a new pairing code for a channel.

# generate\_code

Method

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

Generate a new pairing code for a channel.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def generate_code(channel_type: str, channel_id: Optional[str]) -> str
```

## Parameters

**channel\_type** `str` (default: 'unknown')

Type of channel (e.g., "telegram", "slack", "ui")

**channel\_id** `Optional[str]`

Optional channel identifier

### Returns

**Returns** `str`

The generated pairing code

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L3065)
>
> `praisonaiagents/gateway/protocols.py` at line 3065

***

## Related Documentation

> [card] [Code Agent](https://praison.ai/docs/docs/features/codeagent)

> [card] [Code Feature](https://praison.ai/docs/docs/features/code)


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