> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Connect

Connect a Discord account with the Zernio API, every step with code.

Call `GET /v1/connect/discord` with `profileId` on [Get OAuth connect URL](/connect/get-connect-url). The user authorizes the bot to join their server.

You then bind a channel with `POST /v1/connect/discord` ([Connect Discord channel](/connect/connect-discord-channel)).

The [connecting accounts guide](/guides/connecting-accounts) covers the OAuth flow and [scopes](/guides/connecting-accounts#scopes) in general.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
import Zernio from '@zernio/node';

const zernio = new Zernio();

const { data: connect } = await zernio.connect.getConnectUrl({
  path: { platform: 'discord' },
  query: { profileId: '66a1f0c2a4b9d3e8f1a2b3c4' }
});
// Send the user's browser to connect.authUrl
```
</Tab>
<Tab value="Python">
```python
from zernio import Zernio

client = Zernio()

connect = client.connect.get_connect_url(
    platform="discord",
    profile_id="66a1f0c2a4b9d3e8f1a2b3c4"
)
# Send the user's browser to connect["authUrl"]
```
</Tab>
<Tab value="curl">
```bash
curl "https://zernio.com/api/v1/connect/discord?profileId=66a1f0c2a4b9d3e8f1a2b3c4" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```
</Tab>
</Tabs>

Response (`200`):

```json
{
  "authUrl": "https://discord.com/oauth2/authorize?client_id=...",
  "state": "..."
}
```

After the user authorizes, bind the channel that receives posts:

```bash
curl -X POST https://zernio.com/api/v1/connect/discord \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "profileId": "66a1f0c2a4b9d3e8f1a2b3c4",
    "guildId": "1098765432109876543",
    "channelId": "1234567890123456789"
  }'
```

Response (`200`):

```json
{
  "message": "Discord channel connected successfully",
  "account": {
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "platform": "discord",
    "displayName": "Acme HQ - #announcements",
    "channelId": "1234567890123456789",
    "guildId": "1098765432109876543",
    "isActive": true
  }
}
```

`account.accountId` is the `accountId` for every call below.

One connected account serves one channel. Repeat `POST /v1/connect/discord` with another `channelId` to add another.

`channelId` in `platformSpecificData` decides which channel receives each message.