API 목록으로
🛠️ 개발·협업무료

Slack API

Slack (Salesforce) · Slack Web API

인증 방식

🔐 OAuth 2.0

요금

무료 (90일 메시지 이력), Pro $7.25/월~

Base URL

slack.com/api

태그

Slack, 알림

서비스 소개

Slack Web API는 워크스페이스 채널에 메시지를 보내거나, 봇을 만들거나, 이벤트를 수신하는 등 Slack과의 통합을 구현합니다. Incoming Webhooks를 사용하면 토큰 없이 간단하게 메시지를 전송할 수 있습니다. 서버 에러 알림, 배포 완료 알림, 주문 알림 등에 많이 활용됩니다.

🚀 시작하기

  1. 1

    Slack 앱 생성

    api.slack.com/apps → Create New App → From scratch

  2. 2

    Incoming Webhook 활성화 (간단 방법)

    Features → Incoming Webhooks → 활성화 → Add New Webhook → 채널 선택 → Webhook URL 복사

  3. 3

    Bot Token (고급)

    OAuth & Permissions → Bot Token Scopes → chat:write 추가 → Install App → Bot Token 복사

📋 응답 예시

{ "ok": true, "channel": "C1234567890", "ts": "1503435956.000247" }

💡 코드 예제

JavaScriptIncoming Webhook (가장 간단)
// Webhook URL로 바로 메시지 전송 — 토큰 불필요
const WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL!

async function sendSlack(text: string, channel?: string) {
  await fetch(WEBHOOK_URL, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ text }),
  })
}

// 블록 형식 (버튼·이미지 포함)
await fetch(WEBHOOK_URL, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    blocks: [
      { type: 'header', text: { type: 'plain_text', text: '🚀 배포 완료' } },
      { type: 'section', text: { type: 'mrkdwn', text: '*버전:* v1.2.3
*환경:* Production' } },
      { type: 'actions', elements: [
        { type: 'button', text: { type: 'plain_text', text: '로그 보기' }, url: 'https://vercel.com/...' }
      ]},
    ],
  }),
})
PythonPython
import requests
import os

WEBHOOK_URL = os.environ["SLACK_WEBHOOK_URL"]

def send_slack(message: str):
    requests.post(WEBHOOK_URL, json={"text": message})

# 에러 알림 예시
try:
    risky_operation()
except Exception as e:
    send_slack(f":red_circle: *에러 발생*\n```{e}```")