Back to APIs
Slack API
Send messages, create channels, manage users, and build Slack apps using the Web API and Webhooks — integrates with any backend.
Base URL
https://slack.com/apimessageschannelsbotswebhooksnotifications
Endpoints
POST
/chat.postMessageSend a message to a Slack channel.
const response = await fetch("https://slack.com/api/chat.postMessage", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
},
body: JSON.stringify({
"channel": "#general",
"text": "Hello from APIYard!",
"blocks": []
})
});
const data = await response.json();
console.log(data);Response Preview
{
"ok": true,
"channel": "C024BE91L",
"ts": "1503435956.000247",
"message": {
"text": "Hello from APIYard!",
"username": "My Bot",
"type": "message"
}
}GET
/conversations.listList all channels in a Slack workspace.
const response = await fetch("https://slack.com/api/conversations.list?types=public_channel&limit=20", {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
});
const data = await response.json();
console.log(data);Response Preview
{
"ok": true,
"channels": [{
"id": "C024BE91L",
"name": "general",
"is_member": true,
"num_members": 42
}],
"response_metadata": { "next_cursor": "" }
}