DEV Community

Alex Spinov
Alex Spinov

Posted on

Slack Has a Free API — Send Messages, Build Apps, and Automate Your Workspace Programmatically

Slack isn't just a chat app — it has a powerful API that lets you send messages, create workflows, manage channels, and build interactive apps. The free tier is generous enough for most automation projects.

Here's how to start building with it.

Get Your Free API Token

  1. Go to api.slack.com/apps
  2. Click "Create New App" → "From scratch"
  3. Give it a name, select your workspace
  4. Go to "OAuth & Permissions" → add scopes like chat:write, channels:read
  5. Install to your workspace → copy the Bot User OAuth Token (starts with xoxb-)

1. Send a Message to a Channel

curl -X POST "https://slack.com/api/chat.postMessage" \
  -H "Authorization: Bearer xoxb-YOUR-TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C01234567",
    "text": "Hello from my bot! :rocket:"
  }'
Enter fullscreen mode Exit fullscreen mode

2. Send Rich Messages (Block Kit)

curl -X POST "https://slack.com/api/chat.postMessage" \
  -H "Authorization: Bearer xoxb-YOUR-TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C01234567",
    "blocks": [
      {
        "type": "section",
        "text": {
          "type": "mrkdwn",
          "text": "*Deploy Complete* :white_check_mark:\nVersion 2.4.1 is live on production."
        }
      },
      {
        "type": "actions",
        "elements": [
          {
            "type": "button",
            "text": { "type": "plain_text", "text": "View Logs" },
            "url": "https://example.com/logs"
          }
        ]
      }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

3. List Channels

curl "https://slack.com/api/conversations.list" \
  -H "Authorization: Bearer xoxb-YOUR-TOKEN"
Enter fullscreen mode Exit fullscreen mode

4. Python — Alert Bot

import requests

SLACK_TOKEN = "xoxb-YOUR-TOKEN"
CHANNEL = "C01234567"  # Your channel ID

def send_alert(message, severity="info"):
    emoji = {"info": ":information_source:", "warning": ":warning:", "error": ":rotating_light:"}

    requests.post("https://slack.com/api/chat.postMessage", 
        headers={"Authorization": f"Bearer {SLACK_TOKEN}"},
        json={
            "channel": CHANNEL,
            "text": f"{emoji.get(severity, '')} *{severity.upper()}*: {message}"
        }
    )

# Usage
send_alert("CPU usage above 90%", "warning")
send_alert("Database connection restored", "info")
send_alert("Payment service down!", "error")
Enter fullscreen mode Exit fullscreen mode

5. Node.js — Scheduled Reports

const SLACK_TOKEN = "xoxb-YOUR-TOKEN";
const CHANNEL = "C01234567";

async function sendDailyReport(metrics) {
  const blocks = [
    {
      type: "header",
      text: { type: "plain_text", text: "Daily Report" },
    },
    {
      type: "section",
      fields: Object.entries(metrics).map(([key, val]) => ({
        type: "mrkdwn",
        text: `*${key}:*\n${val}`,
      })),
    },
  ];

  await fetch("https://slack.com/api/chat.postMessage", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${SLACK_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ channel: CHANNEL, blocks }),
  });
}

sendDailyReport({
  "Users Today": "1,234",
  "Revenue": "$5,678",
  "Errors": "3 (all resolved)",
  "Uptime": "99.98%",
});
Enter fullscreen mode Exit fullscreen mode

Rate Limits

Tier Methods Limit
Tier 1 chat.postMessage 1 request/second
Tier 2 conversations.list 20 requests/minute
Tier 3 users.list 50 requests/minute
Tier 4 auth.test 100+ requests/minute

The free plan has the same API access as paid plans — the limits are per-method, not per-plan.

What You Can Build

  • Deploy notifications — post to Slack when CI/CD pipeline completes
  • Alert system — server monitoring, error tracking, uptime alerts
  • Daily digest bot — summarize metrics, news, or tasks every morning
  • Approval workflow — interactive buttons for PR reviews, expense approvals
  • Customer support bridge — forward support tickets to Slack channels
  • Standup bot — collect daily standups and post summaries

More Free API Articles


Need Web Data? Try These Tools

If you're building apps that need web scraping or data extraction, check out my ready-made tools on Apify Store — scrapers for Reddit, YouTube, Google News, Trustpilot, and 80+ more. No coding needed, just run and get your data.

Need a custom scraping solution? Email me at spinov001@gmail.com


More Free APIs You Should Know About

Need custom data scraping? Email me or check my Apify actors.

Top comments (0)