Skip to content
github-actions[bot] edited this page Oct 4, 2026 · 2 revisions

Slack

Typed Slack Web API client for Deno, Bun, Node.js and Cloudflare Workers. Post, update and delete messages, list channels and read history, look up users, and verify request signatures. A lightweight alternative to @slack/web-api for the methods it covers.

JSR JSR Score

Overview

Slack's Web API is a large collection of POST/GET methods, all under https://slack.com/api, authenticated with a bot token as a standard Bearer header. This connect covers the core surface for a bot that posts notifications and reads back what it (or others) posted: sending, updating, and deleting a channel message; listing conversations; paging through a conversation's history; and looking up a user. It uses RESTler for transport and Guardian for runtime request/response validation.

Slack's defining API quirk — most documented failures arrive as HTTP 200 OK with { ok: false, error: '<string>' } in the body, not a 4xx/5xx status — is handled centrally; see Errors for the full mapping.

import { Slack } from '@tundraconnect/slack';

const client = new Slack({
  auth: { type: 'BEARER', token: 'xoxb-your-bot-token' },
});

Testing your code

Your tests don't need to fake HTTP. Have your code take a Slack instance and pass in a stand-in that returns the shapes from @tundraconnect/slack/schemas or throws a real SlackError:

import { SlackError } from '@tundraconnect/slack/errors';

const outage = new SlackError('SERVICE_UNAVAILABLE', { status: 503 });
console.log(outage.code);

To exercise the client itself against a fake transport, subclass it and reassign the protected _fetch.

Documentation

Topic Description
API Client configuration and endpoint methods
Errors Error codes and diagnostic metadata
Schemas Public Guardian schemas and inferred types

Upstream

Installation

Deno:

deno add jsr:@tundraconnect/slack

Bun:

bunx jsr add @tundraconnect/slack

Node.js:

npx jsr add @tundraconnect/slack

Quick Start

import { Slack } from '@tundraconnect/slack';

const client = new Slack({
  auth: { type: 'BEARER', token: 'xoxb-your-bot-token' },
});

const sent = await client.postMessage({
  channel: 'C123ABC456',
  text: 'Deploy succeeded',
});
console.log(sent.ts);

Webhooks

import { Slack } from '@tundraconnect/slack';

const client = new Slack({
  auth: { type: 'BEARER', token: 'xoxb-your-bot-token' },
});

export async function onSlackRequest(req: Request): Promise<void> {
  const raw = await req.text(); // text(), never json()
  const body = await client.verifyWebhook({
    payload: raw,
    headers: req.headers,
    signingSecret: 'your-signing-secret',
  });
  // `body` is now trustworthy.
}

See API → Webhooks.

License

MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.

Clone this wiki locally