Discord API
discord.com · Communication
Build Discord bots and integrations — send messages, manage servers, read channels, handle events, and interact with users. Free, bot token required.
Authentication
Bearer Token
Bot token from Discord Developer Portal (discord.com/developers/applications). Pass as Authorization: Bot YOUR_TOKEN.
Sample Requests
GET
Get current user
Get info about the bot's own account.
https://discord.com/api/v10/users/@me
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Authorization | Bot YOUR_BOT_TOKEN |
curl -X GET "https://discord.com/api/v10/users/@me" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
"https://discord.com/api/v10/users/@me",
headers=headers,
)
print(response.json())const url = 'https://discord.com/api/v10/users/@me';
const response = await fetch(url, {
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://discord.com/api/v10/users/@me"
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://discord.com/api/v10/users/@me")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://discord.com/api/v10/users/@me";
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Authorization: Bearer YOUR_ACCESS_TOKEN"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
POST
Send a message
Send a message to a channel.
https://discord.com/api/v10/channels/{channel_id}/messages
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Content-Type | application/json |
| Authorization | Bot YOUR_BOT_TOKEN |
Request Body — data you're sending
{
"content": "Hello from the API!"
}
curl -X POST "https://discord.com/api/v10/channels/{channel_id}/messages" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"content":"Hello from the API!"}'import requests
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = {
"content": "Hello from the API!"
}
response = requests.post(
"https://discord.com/api/v10/channels/{channel_id}/messages",
headers=headers,
json=data,
)
print(response.json())const url = 'https://discord.com/api/v10/channels/{channel_id}/messages';
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"content": "Hello from the API!"
}),
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"bytes"
"encoding/json"
)
func main() {
targetURL := "https://discord.com/api/v10/channels/{channel_id}/messages"
jsonData, _ := json.Marshal({"content":"Hello from the API!"})
req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://discord.com/api/v10/channels/{channel_id}/messages")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/json"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
req["Content-Type"] = "application/json"
req.body = "{\"content\":\"Hello from the API!\"}"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://discord.com/api/v10/channels/{channel_id}/messages";
$opts = ["http" => [
"method" => "POST",
"header" => implode("\r\n", [
"Content-Type: application/json",
"Authorization: Bearer YOUR_ACCESS_TOKEN",
"Content-Type: application/json"
]),
"content" => json_encode({"content":"Hello from the API!"}),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Create an app at discord.com/developers/applications
- Go to Bot tab → Reset Token to get your bot token
- Set Authorization: Bot YOUR_TOKEN
- Invite your bot: OAuth2 → URL Generator → bot scope + required permissions
- GET /users/@me to verify the token works