APIYard
Back to APIs
SocialBearer TokenFree tier

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/api
messageschannelsbotswebhooksnotifications

Endpoints

POST/chat.postMessage

Send 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.list

List 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": "" }
}