Webhooks Quickstart
Webhooks are the fastest way to send messages into a Chattr text channel.
Create a webhook
- Open the developer portal.
- Choose the server and text channel.
- Create a Webhook app.
- Copy the generated webhook URL.
Send a message
POST /webhooks/:appId/:token
Content-Type: application/json
{
"content": "Deploy completed successfully."
}
Optional fields:
name: override the webhook display name for this messageavatarUrl: override the webhook avatar for this message
Code examples
cURL
curl -X POST "https://chattr.example.com/webhooks/APP_ID/WEBHOOK_TOKEN" \
-H "Content-Type: application/json" \
-d '{"content": "Deploy completed successfully."}'
JavaScript (Node.js)
const WEBHOOK_URL = "https://chattr.example.com/webhooks/APP_ID/WEBHOOK_TOKEN";
const res = await fetch(WEBHOOK_URL, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
content: "Deploy completed successfully.",
name: "CI Bot", // optional
avatarUrl: null // optional
})
});
const data = await res.json();
console.log("Message ID:", data.message.id);
Python
import requests
WEBHOOK_URL = "https://chattr.example.com/webhooks/APP_ID/WEBHOOK_TOKEN"
res = requests.post(WEBHOOK_URL, json={
"content": "Deploy completed successfully.",
"name": "CI Bot", # optional
"avatarUrl": None # optional
})
data = res.json()
print("Message ID:", data["message"]["id"])
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
webhookURL := "https://chattr.example.com/webhooks/APP_ID/WEBHOOK_TOKEN"
body, _ := json.Marshal(map[string]any{
"content": "Deploy completed successfully.",
"name": "CI Bot",
})
resp, err := http.Post(webhookURL, "application/json", bytes.NewReader(body))
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Status:", resp.StatusCode)
}
PHP
$webhookUrl = "https://chattr.example.com/webhooks/APP_ID/WEBHOOK_TOKEN";
$ch = curl_init($webhookUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"content" => "Deploy completed successfully.",
"name" => "CI Bot", // optional
"avatarUrl" => null // optional
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo "Message ID: " . $data["message"]["id"];
Permissions
Creating and managing webhooks requires the manage_server permission on the target server. Server owners and administrators have this by default.
Notes
- Webhooks target one text channel at a time.
- Regenerating the webhook URL invalidates the old one.