Skip to content

Authentication

The OpenSlaq API supports two authentication methods: bot tokens and API keys.

Bot tokens

Bot tokens are issued when you create a bot via the CLI or workspace settings. They authenticate requests as the bot user.

import { OpenSlaq } from "openslaq";
const client = new OpenSlaq({
token: process.env.OPENSLAQ_BOT_TOKEN!,
});

Bot tokens have the bot_ prefix and can:

  • Send and read messages in channels the bot is a member of
  • Respond to slash commands and interactive events
  • Connect to the real-time event stream

API keys

API keys are created in workspace settings or via the CLI. They authenticate requests as the user who created them.

import { OpenSlaq } from "openslaq";
const client = new OpenSlaq({
token: process.env.OPENSLAQ_API_KEY!,
});

API keys have the osk_ prefix and support scoped permissions:

ScopeDescription
channels:readRead channel info and membership
channels:writeCreate, archive, and update channels
messages:readRead messages in channels
messages:writeSend messages and reactions
users:readRead user profiles
bots:manageCreate and manage bots

Environment variables

We recommend storing tokens in environment variables:

.env
OPENSLAQ_BOT_TOKEN=bot_xxxxxxxxxxxxx
# or
OPENSLAQ_API_KEY=osk_xxxxxxxxxxxxx