---
description: Reference for verified Discord HTTP interactions from @flue/discord.
title: Discord Channel API | Flue
image: https://flueframework.com/docs/og4.jpg
---

# Discord Channel API

AI-generated, awaiting review [ View as Markdown](https://flueframework.com/docs/api/discord-channel/index.md) 

Import from `@flue/discord`.

## `createDiscordChannel()`

```
function createDiscordChannel<E extends Env = Env>(
  options: DiscordChannelOptions<E>,
): DiscordChannel<E>;
```

Creates one stateless Discord HTTP interactions channel.

## `DiscordChannelOptions`

```
interface DiscordChannelOptions<E extends Env = Env> {
  publicKey: string;
  bodyLimit?: number;
  interactions(input: { c: Context<E>; interaction: APIInteraction }): DiscordHandlerResult;
}
```

| Field        | Description                                                  |
| ------------ | ------------------------------------------------------------ |
| publicKey    | 32-byte application public key as 64 hexadecimal characters. |
| bodyLimit    | Maximum request body in bytes. Defaults to 1 MiB.            |
| interactions | Receives each authenticated non-PING Discord interaction.    |

The package verifies Ed25519 signatures before parsing. The application public key cryptographically binds authenticated requests to its Discord application, so no separate application-id option is required.

## Interaction types

`APIInteraction` and `APIInteractionResponse` are re-exported from`discord-api-types/v10`. Callbacks receive the parsed provider object with its field names, nesting, and numeric discriminants unchanged.

PING interactions are handled internally and return PONG without invoking the callback. The callback uses the current provider union for strong narrowing. Authenticated future numeric types are still forwarded at runtime, so an exhaustive branch must tolerate an unfamiliar numeric value after a Discord API change.

`interaction.token` is a short-lived provider capability. Keep it out of model context, dispatched input, logs, and durable history.

## Handler results

```
type DiscordHandlerResult =
  | APIInteractionResponse
  | Response
  | Promise<APIInteractionResponse | Response>;
```

Discord interactions require a provider response. Return a provider-native interaction response or an ordinary Hono or Fetch `Response`. Thrown errors flow through normal Hono error handling.

Discord requires an initial response within three seconds. The package does not race or cancel application handlers; applications must admit durable work and respond within that provider deadline.

## `DiscordChannel`

```
interface DiscordChannel<E extends Env = Env> {
  readonly routes: readonly ChannelRoute<E>[];
  conversationKey(ref: DiscordDestinationRef): string;
  parseConversationKey(id: string): DiscordDestinationRef;
}
```

`routes` contains one `POST /interactions` declaration. A file named`channels/discord.ts` is served at `/channels/discord/interactions` relative to the `flue()` mount.

## `DiscordDestinationRef`

```
type DiscordDestinationRef =
  | {
      type: 'guild';
      guildId: string;
      channelId: string;
    }
  | {
      type: 'dm';
      channelId: string;
    }
  | {
      type: 'private';
      channelId: string;
    };
```

Applications derive destination references from native interaction fields when a durable destination exists. Conversation keys are canonical identifiers, not authorization capabilities.

## Errors

* `InvalidDiscordConversationKeyError`
* `InvalidDiscordInputError`, with structured `field`

The package does not invent a timestamp freshness window or deduplicate interaction ids.

See [Discord setup](https://flueframework.com/docs/ecosystem/channels/discord/) for composition with`@discordjs/rest` and application-owned tools.

## Docs Navigation

Current page: [Discord Channel API](https://flueframework.com/docs/api/discord-channel/)

### Sections

* [Guide](https://flueframework.com/docs/getting-started/quickstart/)
* [Reference](https://flueframework.com/docs/api/agent-api/)
* [CLI](https://flueframework.com/docs/cli/overview/)
* [SDK](https://flueframework.com/docs/sdk/overview/)
* [Ecosystem](https://flueframework.com/docs/ecosystem/)

### Runtime

* [ Configuration ](https://flueframework.com/docs/reference/configuration/)
* [ Errors Reference ](https://flueframework.com/docs/api/errors-reference/)
* [ Agent API ](https://flueframework.com/docs/api/agent-api/)
* [ Provider API ](https://flueframework.com/docs/api/provider-api/)
* [ Routing API ](https://flueframework.com/docs/api/routing-api/)
* [ GitHub Channel ](https://flueframework.com/docs/api/github-channel/)
* [ Stripe Channel ](https://flueframework.com/docs/api/stripe-channel/)
* [ Notion Channel ](https://flueframework.com/docs/api/notion-channel/)
* [ Resend Channel ](https://flueframework.com/docs/api/resend-channel/)
* [ Shopify Channel ](https://flueframework.com/docs/api/shopify-channel/)
* [ Intercom Channel ](https://flueframework.com/docs/api/intercom-channel/)
* [ Zendesk Channel ](https://flueframework.com/docs/api/zendesk-channel/)
* [ Salesforce Marketing Cloud Channel ](https://flueframework.com/docs/api/salesforce-marketing-cloud-channel/)
* [ Slack Channel ](https://flueframework.com/docs/api/slack-channel/)
* [ Discord Channel ](https://flueframework.com/docs/api/discord-channel/)
* [ Teams Channel ](https://flueframework.com/docs/api/teams-channel/)
* [ Google Chat Channel ](https://flueframework.com/docs/api/google-chat-channel/)
* [ Linear Channel ](https://flueframework.com/docs/api/linear-channel/)
* [ Telegram Channel ](https://flueframework.com/docs/api/telegram-channel/)
* [ WhatsApp Channel ](https://flueframework.com/docs/api/whatsapp-channel/)
* [ Twilio Channel ](https://flueframework.com/docs/api/twilio-channel/)
* [ Messenger Channel ](https://flueframework.com/docs/api/messenger-channel/)
* [ Streaming Protocol ](https://flueframework.com/docs/api/streaming-protocol/)
* [ Events Reference ](https://flueframework.com/docs/api/events-reference/)

### Advanced

* [ Sandbox Adapter API ](https://flueframework.com/docs/api/sandbox-api/)
* [ Data Persistence API ](https://flueframework.com/docs/api/data-persistence-api/)