返回博客
Guide

Slack Bot Token: How to Get One, and xoxb vs xoxp Explained

A Slack bot token starts with xoxb- and acts as your app's bot user. Get one by creating an app at api.slack.com/apps, adding bot scopes under OAuth & Permissions, installing the app, and copying the Bot User OAuth Token. How it differs from xoxp user tokens, xapp app-level tokens, xoxe rotation and xoxc session tokens.

Slack Green Team
September 23, 2026
September 23, 2026
5 min read
Share:
slack api
developers
slack tokens

A Slack bot token starts with xoxb- and lets your app act as its own bot user. To get one, create an app at api.slack.com/apps, open OAuth & Permissions, add Bot Token Scopes such as chat:write, click Install to Workspace, approve it, and copy the Bot User OAuth Token. A user token starts with xoxp- and acts as the person who approved it. Slack's docs recommend bot tokens for most apps, because they stay working even if the installing user is deactivated.

Some things only a user can do: a bot has its own presence and cannot set yours, for example. That is why tools that keep your own Slack dot green, like Slack Green, use your signed-in session rather than a bot token; the difference is covered in Slack xoxc and xoxd tokens.

Slack bot token: how to get one, xoxb, xoxp, xapp, xoxe, xwfp prefixes

How to get a Slack bot token

Get a Slack bot token: create an app, add bot scopes, install, copy the token

  • Go to api.slack.com/apps, click Create New App, choose From scratch, name it and pick the workspace.
  • Open OAuth & Permissions and add Bot Token Scopes, for example chat:write to post and users:read to read people and presence.
  • Click Install to Workspace and Allow. Some workspaces require an admin to approve new apps.
  • Copy the Bot User OAuth Token (xoxb-...) and store it as a secret, never in code or a public repository.
  • Invite the bot to any channel it needs to post in: /invite @your-bot.
  • When you add scopes later, reinstall the app so the token gets them.

    Test it:

    curl -s -H "Authorization: Bearer $SLACK_BOT_TOKEN" https://slack.com/api/auth.test

    Slack token types and prefixes

    Slack token prefixes: xoxb, xoxp, xapp, xoxe, xwfp, xoxc and xoxd
    PrefixTokenActs as
    xoxb-Bot tokenYour app's bot user
    xoxp-User tokenThe user who approved the app
    xapp-App-level tokenThe app across all its installs
    xoxe.xoxb-, xoxe.xoxp-Rotating access tokenBot or user, expires after 12 hours
    xoxe-Refresh tokenUsed to get a new access token
    xwfp-Workflow tokenA workflow step, for at most 15 minutes
    xoxc-, xoxd-Web client sessionYou, as the Slack web app

    Slack's docs also describe configuration tokens for the App Manifest APIs and service tokens for apps built with the Deno Slack SDK.

    xoxb vs xoxp

再也不会在Slack上显示「离开」

云端运行。无需下载。即使笔记本关机也能24/7运行。

  • xoxb (bot) acts as the app. Messages come from the bot. It keeps working if the installing person leaves. Use it for almost everything.
  • xoxp (user) acts as a person, with that person's access. Writes look like they came from them. Use it only when an action must be done as the user, such as users.profile.set for their own status.
  • A user token also carries user scopes that the user approved. Slack's docs note that user token actions are performed as if by the user themselves.

    xoxe tokens and token rotation

    If you turn on token rotation in your app settings, oauth.v2.access returns an access token with an xoxe. prefix that expires after 43,200 seconds (12 hours), plus a refresh token starting with xoxe-. Call oauth.v2.access with grant_type=refresh_token before it expires to get a new pair.

    xapp app-level tokens

    App-level tokens start with xapp- and come from Basic Information in your app settings. They are for app-wide APIs, most often Socket Mode connections, not for posting messages.

    Which token can set presence?

    再也不会在Slack上显示「离开」

    云端运行。无需下载。即使笔记本关机也能24/7运行。

    users.setPresence sets the calling user's presence to away or auto, so with a user token it changes the user's own dot; a bot token changes the bot's. No token can force a user to active. Code and fields are in our Slack presence API guide.

    FAQ

    How do I get a Slack bot token?

    Create an app at api.slack.com/apps, add bot scopes, install it to your workspace, and copy the Bot User OAuth Token from OAuth & Permissions.

    What is the difference between xoxb and xoxp?

    xoxb acts as your app's bot. xoxp acts as the user who approved the app.

    Do Slack bot tokens expire?

    Not unless you turn on token rotation; then access tokens expire after 12 hours and you refresh them.

    What is an xoxe token?

    With rotation on, xoxe. prefixes a short-lived access token and xoxe- starts the refresh token.

    What are xoxc and xoxd tokens?

    The web client's session token and cookie; see Slack xoxc and xoxd tokens.

    Always Active

    别再晃动鼠标了。

    数百名远程工作者再也不用担心Slack状态。设置一次,永远保持绿色。

    Related Articles

    Guide

    Slack Jira Integration: Setup, /jira Commands and Notifications

    Install the Jira Cloud for Slack app, type /jira connect in a channel to send a Jira space's updates there, /jira notify for personal notifications as DMs, and create work items from any message with More actions. Every /jira command, Jira automation to Slack, and fixes when previews or notifications stop.

    Slack Green Team5 min read
    Guide

    How to Create a Slack Workspace, on Desktop or Phone

    Go to slack.com/get-started, enter your email, type the confirmation code, and click Create a Workspace. It is free to start, you become the Primary Owner, and it takes about five minutes. Steps for desktop, iPhone and Android, and what to set up next.

    Slack Green Team5 min read
    Guide

    Slack Sidebar Sections: Create, Sort, Share and Fix Them

    Slack sidebar sections are custom groups of channels, DMs and apps in your sidebar. Only you see them, and they need a paid plan. How to create one on desktop and mobile, move many channels at once, sort and filter each section, share a section with your team, and get disappeared sections back.

    Slack Green Team5 min read
      Slack Bot Token: How to Get One, xoxb vs xoxp