POST /functions/v1/send-discord
Sends a message to a Discord channel using a webhook URL. Supports custom username and avatar customization.Request
Headers
Bearer token for authentication:
Bearer <your-supabase-jwt-token>Must be
application/jsonBody Parameters
The workflow element ID used to load Discord webhook configuration from the database.
Discord webhook URL. Must start with
https://discord.com/api/webhooks/. If not provided, will be loaded from agent configuration.The message content to send. If not provided, will be loaded from
messageContent in agent configuration.Custom username to display for the webhook message. Overrides the default webhook name.
URL to a custom avatar image to display for the webhook message.
Response
Indicates whether the message was sent successfully
Discord message ID. May be “unknown” if Discord returns 204 No Content.
ISO 8601 timestamp of when the message was sent
Discord Webhook Format
The function sends a JSON payload to the Discord webhook:Configuration Loading
WhenwebhookUrl is not provided directly:
- Queries
agent_configstable fordiscord_messengerconfiguration - Filters by
user_idandelement_id - Extracts
webhookUrl,username,avatarUrl, andmessageContent - Uses database values as defaults, with request parameters taking priority
Examples
Request with Element ID
Request with Full Parameters
Success Response
Error Response
Error Codes
| Status Code | Error Message | Description |
|---|---|---|
| 400 | Element ID is required | Missing elementId parameter |
| 400 | Discord webhook URL is required | No webhook URL provided or found in config |
| 400 | Invalid Discord webhook URL format | Webhook URL doesn’t match Discord format |
| 404 | No Discord webhook configuration found | No agent configuration exists for element |
| 500 | Failed to retrieve agent configuration | Database error loading configuration |
| 500 | Failed to send Discord message | Discord API error or network issue |
Webhook URL Validation
Webhook URLs must:- Start with
https://discord.com/api/webhooks/ - Follow Discord’s webhook URL format
- Be active and have proper permissions
Discord Response Handling
Discord webhooks can return:- 204 No Content: Success, no message data returned
- 200 OK: Success with message JSON containing
idandtimestamp - 4xx/5xx: Error responses with error details
Workflow Integration
When used in workflows with placeholders:run-workflow function before calling this endpoint.
Output Storage
Successful message sends are stored inagent_outputs table:
Rate Limits
Discord webhook rate limits:- 30 requests per minute per webhook
- 2000 character limit for message content
- Rate limit headers are not parsed by this function
Notes
- Webhook URLs should be kept secure and not exposed publicly
- The webhook URL is not logged for security reasons
- Custom username and avatar are optional
- Discord may cache avatar images
- Embeds are not currently supported (only plain text content)
- The authenticated user must have permissions to use the configured webhook
- Configuration is stored in
agent_configstable withagent_type: 'discord_messenger'