Discord API
Use this page for Discord-only public V2 endpoints.
Authentication
All Discord V2 public endpoints require:
x-api-keyx-api-secretContent-Type: application/json
Base path:
/v2
Rate limit:
180 requests / 60 seconds
Discord Routes
| Method | Path | Purpose |
|---|---|---|
POST | /v2/discord/send | Send a message to the bound Discord channel |
POST | /v2/discord/reply | Reply to a previously sent Discord message |
POST | /v2/discord/start-thread | Start a Discord thread from a bound channel |
POST | /v2/discord/send-thread-message | Send a message into an existing Discord thread |
Send A Discord Message
POST /v2/discord/send
Required Fields
channelRefmessage
Request Example
- cURL
- Node
- Python
- Go
- Java
- PHP
- C#
- Rust
- C++
- Elixir
curl --request POST \
--url https://api.usealerta.com/v2/discord/send \
--header "content-type: application/json" \
--header "x-api-key: YOUR_API_KEY" \
--header "x-api-secret: YOUR_API_SECRET" \
--data '{
"channelRef": "C_ALT_ABC123",
"message": "Database replication lag exceeded threshold."
}'
const response = await fetch("https://api.usealerta.com/v2/discord/send", {
method: "POST",
headers: {
"content-type": "application/json",
"x-api-key": process.env.ALERTA_API_KEY,
"x-api-secret": process.env.ALERTA_API_SECRET,
},
body: JSON.stringify({
channelRef: "C_ALT_ABC123",
message: "Database replication lag exceeded threshold.",
}),
});
const data = await response.json();
console.log(data);
import os
import requests
response = requests.post(
"https://api.usealerta.com/v2/discord/send",
headers={
"content-type": "application/json",
"x-api-key": os.environ["ALERTA_API_KEY"],
"x-api-secret": os.environ["ALERTA_API_SECRET"],
},
json={
"channelRef": "C_ALT_ABC123",
"message": "Database replication lag exceeded threshold.",
},
timeout=30,
)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
payload := []byte(`{
"channelRef": "C_ALT_ABC123",
"message": "Database replication lag exceeded threshold."
}`)
req, _ := http.NewRequest(http.MethodPost, "https://api.usealerta.com/v2/discord/send", bytes.NewBuffer(payload))
req.Header.Set("content-type", "application/json")
req.Header.Set("x-api-key", os.Getenv("ALERTA_API_KEY"))
req.Header.Set("x-api-secret", os.Getenv("ALERTA_API_SECRET"))
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public final class SendDiscordMessage {
public static void main(String[] args) throws Exception {
String payload = """
{
"channelRef": "C_ALT_ABC123",
"message": "Database replication lag exceeded threshold."
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.usealerta.com/v2/discord/send"))
.header("content-type", "application/json")
.header("x-api-key", System.getenv("ALERTA_API_KEY"))
.header("x-api-secret", System.getenv("ALERTA_API_SECRET"))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$payload = [
"channelRef" => "C_ALT_ABC123",
"message" => "Database replication lag exceeded threshold.",
];
$ch = curl_init("https://api.usealerta.com/v2/discord/send");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"content-type: application/json",
"x-api-key: " . getenv("ALERTA_API_KEY"),
"x-api-secret: " . getenv("ALERTA_API_SECRET"),
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR),
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch) . PHP_EOL;
curl_close($ch);
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("ALERTA_API_KEY"));
client.DefaultRequestHeaders.Add("x-api-secret", Environment.GetEnvironmentVariable("ALERTA_API_SECRET"));
var json = """
{
"channelRef": "C_ALT_ABC123",
"message": "Database replication lag exceeded threshold."
}
""";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.usealerta.com/v2/discord/send", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers.insert("x-api-key", HeaderValue::from_str(&env::var("ALERTA_API_KEY")?)?);
headers.insert("x-api-secret", HeaderValue::from_str(&env::var("ALERTA_API_SECRET")?)?);
let payload = json!({
"channelRef": "C_ALT_ABC123",
"message": "Database replication lag exceeded threshold."
});
let response = reqwest::Client::new()
.post("https://api.usealerta.com/v2/discord/send")
.headers(headers)
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{response}");
Ok(())
}
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, "content-type: application/json");
headers = curl_slist_append(headers, "x-api-key: YOUR_API_KEY");
headers = curl_slist_append(headers, "x-api-secret: YOUR_API_SECRET");
const char *payload =
"{\"channelRef\":\"C_ALT_ABC123\",\"message\":\"Database replication lag exceeded threshold.\"}";
curl_easy_setopt(curl, CURLOPT_URL, "https://api.usealerta.com/v2/discord/send");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
url = "https://api.usealerta.com/v2/discord/send"
headers = [
{"content-type", "application/json"},
{"x-api-key", System.fetch_env!("ALERTA_API_KEY")},
{"x-api-secret", System.fetch_env!("ALERTA_API_SECRET")}
]
body =
Jason.encode!(%{
channelRef: "C_ALT_ABC123",
message: "Database replication lag exceeded threshold."
})
{:ok, response} = Req.post(url, headers: headers, body: body)
IO.puts(response.body)
Latest Success Response
{
"statusCode": 200,
"message": "Message sent successfully",
"data": {
"messageId": "discord-message-1",
"threadId": "discord-message-1",
"channelId": "discord-channel-1",
"channelRef": "C_ALT_ABC123",
"balance": 90
}
}
Field meanings:
messageId: Discord message ID of the sent messagethreadId: same asmessageId, used as reply targetchannelId: Discord channel ID where the message was postedchannelRef: internal Alerta Discord binding referencebalance: remaining wallet balance
Reply To A Discord Message
POST /v2/discord/reply
Required Fields
channelRefchannelIdthreadIdmessage
- cURL
- Node
- Python
- Go
- Java
- PHP
- C#
- Rust
- C++
- Elixir
curl --request POST \
--url https://api.usealerta.com/v2/discord/reply \
--header "content-type: application/json" \
--header "x-api-key: YOUR_API_KEY" \
--header "x-api-secret: YOUR_API_SECRET" \
--data '{
"channelRef": "C_ALT_ABC123",
"channelId": "1119355453625880591",
"threadId": "1492962136463249598",
"message": "Acknowledged, investigating now."
}'
const response = await fetch("https://api.usealerta.com/v2/discord/reply", {
method: "POST",
headers: {
"content-type": "application/json",
"x-api-key": process.env.ALERTA_API_KEY,
"x-api-secret": process.env.ALERTA_API_SECRET,
},
body: JSON.stringify({
channelRef: "C_ALT_ABC123",
channelId: "1119355453625880591",
threadId: "1492962136463249598",
message: "Acknowledged, investigating now.",
}),
});
const data = await response.json();
console.log(data);
import os
import requests
response = requests.post(
"https://api.usealerta.com/v2/discord/reply",
headers={
"content-type": "application/json",
"x-api-key": os.environ["ALERTA_API_KEY"],
"x-api-secret": os.environ["ALERTA_API_SECRET"],
},
json={
"channelRef": "C_ALT_ABC123",
"channelId": "1119355453625880591",
"threadId": "1492962136463249598",
"message": "Acknowledged, investigating now.",
},
timeout=30,
)
print(response.json())
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
payload := []byte(`{
"channelRef": "C_ALT_ABC123",
"channelId": "1119355453625880591",
"threadId": "1492962136463249598",
"message": "Acknowledged, investigating now."
}`)
req, _ := http.NewRequest(http.MethodPost, "https://api.usealerta.com/v2/discord/reply", bytes.NewBuffer(payload))
req.Header.Set("content-type", "application/json")
req.Header.Set("x-api-key", os.Getenv("ALERTA_API_KEY"))
req.Header.Set("x-api-secret", os.Getenv("ALERTA_API_SECRET"))
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public final class ReplyDiscordMessage {
public static void main(String[] args) throws Exception {
String payload = """
{
"channelRef": "C_ALT_ABC123",
"channelId": "1119355453625880591",
"threadId": "1492962136463249598",
"message": "Acknowledged, investigating now."
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.usealerta.com/v2/discord/reply"))
.header("content-type", "application/json")
.header("x-api-key", System.getenv("ALERTA_API_KEY"))
.header("x-api-secret", System.getenv("ALERTA_API_SECRET"))
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$payload = [
"channelRef" => "C_ALT_ABC123",
"channelId" => "1119355453625880591",
"threadId" => "1492962136463249598",
"message" => "Acknowledged, investigating now.",
];
$ch = curl_init("https://api.usealerta.com/v2/discord/reply");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"content-type: application/json",
"x-api-key: " . getenv("ALERTA_API_KEY"),
"x-api-secret: " . getenv("ALERTA_API_SECRET"),
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR),
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch) . PHP_EOL;
curl_close($ch);
using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", Environment.GetEnvironmentVariable("ALERTA_API_KEY"));
client.DefaultRequestHeaders.Add("x-api-secret", Environment.GetEnvironmentVariable("ALERTA_API_SECRET"));
var json = """
{
"channelRef": "C_ALT_ABC123",
"channelId": "1119355453625880591",
"threadId": "1492962136463249598",
"message": "Acknowledged, investigating now."
}
""";
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.usealerta.com/v2/discord/reply", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers.insert("x-api-key", HeaderValue::from_str(&env::var("ALERTA_API_KEY")?)?);
headers.insert("x-api-secret", HeaderValue::from_str(&env::var("ALERTA_API_SECRET")?)?);
let payload = json!({
"channelRef": "C_ALT_ABC123",
"channelId": "1119355453625880591",
"threadId": "1492962136463249598",
"message": "Acknowledged, investigating now."
});
let response = reqwest::Client::new()
.post("https://api.usealerta.com/v2/discord/reply")
.headers(headers)
.json(&payload)
.send()
.await?
.text()
.await?;
println!("{response}");
Ok(())
}
#include <curl/curl.h>
int main() {
CURL *curl = curl_easy_init();
if (!curl) return 1;
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, "content-type: application/json");
headers = curl_slist_append(headers, "x-api-key: YOUR_API_KEY");
headers = curl_slist_append(headers, "x-api-secret: YOUR_API_SECRET");
const char *payload =
"{\"channelRef\":\"C_ALT_ABC123\",\"channelId\":\"1119355453625880591\",\"threadId\":\"1492962136463249598\",\"message\":\"Acknowledged, investigating now.\"}";
curl_easy_setopt(curl, CURLOPT_URL, "https://api.usealerta.com/v2/discord/reply");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}
url = "https://api.usealerta.com/v2/discord/reply"
headers = [
{"content-type", "application/json"},
{"x-api-key", System.fetch_env!("ALERTA_API_KEY")},
{"x-api-secret", System.fetch_env!("ALERTA_API_SECRET")}
]
body =
Jason.encode!(%{
channelRef: "C_ALT_ABC123",
channelId: "1119355453625880591",
threadId: "1492962136463249598",
message: "Acknowledged, investigating now."
})
{:ok, response} = Req.post(url, headers: headers, body: body)
IO.puts(response.body)
Success Response
{
"statusCode": 200,
"message": "Reply sent successfully",
"data": {
"balance": 80
}
}
Start A Discord Thread
POST /v2/discord/start-thread
Required Fields
channelReftitlemessage
curl --request POST \
--url https://api.usealerta.com/v2/discord/start-thread \
--header "content-type: application/json" \
--header "x-api-key: YOUR_API_KEY" \
--header "x-api-secret: YOUR_API_SECRET" \
--data '{
"channelRef": "C_ALT_ABC123",
"title": "Incident #1192",
"message": "Starting investigation thread."
}'
Success Response
{
"statusCode": 200,
"message": "Thread started successfully",
"data": {
"rootChannelId": "1119355453625880591",
"baseMessageId": "1492962136463249598",
"threadChannelId": "1492963000000000000",
"threadName": "Incident #1192",
"balance": 80
}
}
Send A Message To A Discord Thread
POST /v2/discord/send-thread-message
Required Fields
channelRefthreadChannelIdmessage
curl --request POST \
--url https://api.usealerta.com/v2/discord/send-thread-message \
--header "content-type: application/json" \
--header "x-api-key: YOUR_API_KEY" \
--header "x-api-secret: YOUR_API_SECRET" \
--data '{
"channelRef": "C_ALT_ABC123",
"threadChannelId": "1492963000000000000",
"message": "Investigating replica lag now."
}'
Success Response
{
"statusCode": 200,
"message": "Message sent to thread",
"data": {
"threadChannelId": "1492963000000000000",
"balance": 70
}
}
Common Errors
{
"statusCode": 403,
"message": "Missing API key"
}
{
"statusCode": 403,
"message": "Missing API secret"
}
{
"statusCode": 403,
"message": "Invalid API key"
}
{
"statusCode": 403,
"message": "Invalid API secret"
}
{
"statusCode": 403,
"message": "Organization is inactive"
}
{
"statusCode": 400,
"message": "Invalid Channel reference"
}
{
"statusCode": 400,
"message": "No Discord channel bound"
}
Discord Notes
channelRefis an internal Alerta reference such asC_ALT_..., not the raw Discord channel name.channelIdandthreadIdare returned directly byPOST /v2/discord/send; you do not need a separate lookup before replying.threadIdis the same as the sent DiscordmessageIdfor reply targeting.- Discord thread APIs are separate from normal replies.