Overview
Svara sends native voice messages on Discord through the Discord API. Voice messages appear with the distinctive purple waveform in the channel, identical to recording a voice message directly in the Discord app. Discord voice messages include waveform visualization data and are flagged as voice messages, so they render natively rather than as generic file attachments.
Your Discord Bot acts as the sender. The bot must have access to the target channel to send messages.
Required session data
| Field | Type | Description |
|---|---|---|
| bot_token | string | A Discord Bot token from the Discord Developer Portal |
How to get credentials
1. Create a Discord Application
- Go to the Discord Developer Portal and click New Application.
- Give your application a name.
- Navigate to the Bot section in the sidebar.
- Click Add Bot (if not already created).
2. Get your bot token
- In the Bot section, click Reset Token (or Copy if visible).
- Store the token securely. It grants full access to your bot.
export DISCORD_BOT_TOKEN="MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.Gabcde.abc123..."
Important: Enable the Message Content Intent under Privileged Gateway Intents if your bot needs to read messages. For sending voice notes, the default intents are sufficient.
3. Invite the bot to your server
- Go to OAuth2 > URL Generator in the Developer Portal.
- Select the
botscope. - Under Bot Permissions, select:
Send MessagesAttach FilesSend Messages in Threads(if using threads)
- Copy the generated URL and open it in your browser to invite the bot to your server.
4. Get the channel ID
The recipient is a Discord channel ID (a numeric snowflake identifier).
To find a channel ID:
- Enable Developer Mode in Discord (Settings > Advanced > Developer Mode).
- Right-click the target channel and select Copy Channel ID.
For DMs, use the DM channel ID. You can get this by calling the Create DM endpoint with the target user's ID.
Audio format
Discord voice messages use OGG format with Opus codec. Svara converts your audio automatically:
| Input format | Behavior | |---|---| | OGG / OPUS | Sent directly with waveform data, no conversion needed | | M4A / AAC | Auto-converted to OGG/OPUS | | MP3 | Auto-converted to OGG/OPUS | | WAV | Auto-converted to OGG/OPUS | | WebM | Auto-converted to OGG/OPUS |
Svara automatically generates the waveform visualization data required for native voice message rendering. Audio files must be under 25 MB. Discord voice messages should be under 5 minutes for the best experience.
Example request
curl -X POST https://api.svarapi.io/v1/send \
-H "Authorization: Bearer $SVARA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platform": "discord",
"recipient": "1234567890123456789",
"audio_url": "https://cdn.example.com/notes/update.m4a",
"session": {
"bot_token": "MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.Gabcde.abc123..."
}
}'
const response = await fetch("https://api.svarapi.io/v1/send", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SVARA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
platform: "discord",
recipient: "1234567890123456789",
audio_url: "https://cdn.example.com/notes/update.m4a",
session: {
bot_token: process.env.DISCORD_BOT_TOKEN,
},
}),
});
const result = await response.json();
console.log(`Voice note queued: ${result.id}`);
import requests
response = requests.post(
"https://api.svarapi.io/v1/send",
headers={"Authorization": f"Bearer {api_key}"},
json={
"platform": "discord",
"recipient": "1234567890123456789",
"audio_url": "https://cdn.example.com/notes/update.m4a",
"session": {
"bot_token": bot_token,
},
},
)
result = response.json()
print(f"Voice note queued: {result['id']}")
Common errors
| Error | Cause | Solution |
|---|---|---|
| invalid_bot_token | The bot token is malformed or revoked | Reset and copy a new token from the Developer Portal |
| channel_not_found | The channel ID is invalid or the bot cannot access it | Verify the channel ID and ensure the bot has access to the server |
| missing_permissions | The bot lacks Send Messages or Attach Files permissions | Update the bot's role permissions in Server Settings |
| missing_access | The bot is not a member of the server containing the channel | Invite the bot to the server using the OAuth2 URL |
| audio_too_large | The audio file exceeds 25 MB | Compress or shorten your audio |
| audio_fetch_failed | Could not download the audio from the URL | Ensure the URL is publicly accessible |