# Discord

Publish messages, embeds, polls, forum posts and threads to Discord channels with the Zernio API, send DMs, manage roles and pins, and create scheduled events, with no bot hosting.

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

Publish messages, embeds, polls, forum posts and threads to a Discord channel with `POST /v1/posts` and `platform: "discord"`.

The same bot sends DMs, lists members, assigns roles, pins messages and creates scheduled events, all over REST.

## Quick reference

| Property | Value |
|----------|-------|
| Content limit | 2,000 characters (message content) |
| Embeds per message | 10 (max 6,000 characters total) |
| Images per message | Up to 10 attachments |
| Image formats | JPEG, PNG, GIF, WebP |
| Image max size | 20 MiB default (higher on Boosted servers) |
| Video formats | MP4 |
| Video max size | 20 MiB default (higher on Boosted servers) |
| Post types | Messages, Embeds, Polls, Forum Posts, Threads |
| Scheduling | Yes |
| Direct messages | Outbound only |
| Role management | Yes (list, create, edit, delete, assign, remove) |
| Member listing | Yes (list with cursor pagination, search, get one) |
| Pinned messages | Yes (list, pin, unpin) |
| Scheduled events | Yes (create, list, update, cancel, delete) |
| Inbox (DM replies) | No (Discord requires a Gateway connection) |
| Inbox (comments) | No |
| Analytics | No (Discord Bot API limit) |

## Before you start

Discord requires Zernio's bot in your server. You do not create a Discord application, request privileged intents or host a gateway connection.

Zernio runs one central bot. The user installs it into their server through OAuth, and you POST to the REST API.

`MESSAGE_CONTENT` and the other privileged intents are handled on Zernio's bot, and you never open a WebSocket.

The bot asks for these permissions at install time:

- Send Messages
- Embed Links
- Attach Files
- Send Messages in Threads
- Create Public Threads
- Manage Messages (pin and unpin)
- Manage Roles (role assignment)
- Manage Events (scheduled events)

<Callout type="warn">
Servers connected before Manage Roles and Manage Events were added to the install do not have them, so the role and event endpoints return `502` there.
</Callout>

Ask a server admin to re-invite the bot (the new permissions come with the invite) or to grant the missing permission on the bot's role under Server Settings, Roles.

## Connect

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 full flow, with code for every step, is on [Connect](/platforms/discord/connect).

## Publish a post

This request sends a message to a Discord channel right away. `platformSpecificData.channelId` picks the channel.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
const { data: published } = await zernio.posts.createPost({
  body: {
    content: 'Release 2.3 is live. Changelog in the thread below.',
    platforms: [
      {
        platform: 'discord',
        accountId: '66b2e19d8c3f5a7e9d0b1c2d',
        platformSpecificData: { channelId: '1234567890123456789' }
      }
    ],
    publishNow: true
  }
});

console.log(published.post.platforms[0].platformPostUrl);
```
</Tab>
<Tab value="Python">
```python
published = client.posts.create_post(
    content="Release 2.3 is live. Changelog in the thread below.",
    platforms=[
        {
            "platform": "discord",
            "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
            "platformSpecificData": {"channelId": "1234567890123456789"}
        }
    ],
    publish_now=True
)

print(published["post"]["platforms"][0]["platformPostUrl"])
```
</Tab>
<Tab value="curl">
```bash
curl -X POST https://zernio.com/api/v1/posts \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Release 2.3 is live. Changelog in the thread below.",
    "platforms": [
      {
        "platform": "discord",
        "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
        "platformSpecificData": {"channelId": "1234567890123456789"}
      }
    ],
    "publishNow": true
  }'
```
</Tab>
</Tabs>

Every option is on [Publish](/platforms/discord/posts).

## In this section

<PlatformPages platform="discord" />

## Related

- [Connecting accounts](/guides/connecting-accounts): the OAuth flow and bot installation.
- [Create post](/posts/create-post): every field of the request.
- [Discord settings](/discord/update-discord-settings) and [Discord channels](/discord/get-discord-channels): webhook identity and channel switching.
- [Send Discord DM](/discord/send-discord-direct-message): 1:1 messages from the bot.
- [Pricing](/pricing): what outbound DMs cost.