Slack 数据 API:工作区聊天、成员与文件
Slack 的 Android 客户端先按邮箱或域名查找工作区(/v1/workspaces/lookup),再在 /v1/workspaces/{workspaceId}/sessions 登录(token、member_id、member_email),随后用 /v1/workspaces/{workspaceId}/boot 填充首页——me、workspace、channels、direct_messages、prefs、dnd 与 plan_features——侧边栏圆点来自 /v1/workspaces/{workspaceId}/badge-counts。
会话视图分页 /v1/channels/{channelId}/timeline(messages、has_more、pin_count),频道标题来自 /v1/channels/{channelId}/details。资料卡读取 /v1/members/{memberId}/card 获取 email、title、phone、pronouns 与 presence;文件页列出 /v1/channels/{channelId}/shared-files;搜索运行 /v1/workspace-search/{module}。/v1/channels/{channelId}/messages、/v1/me/presence 与 /v1/me/notification-pause 等写入携带同一工作区会话令牌,/v1/realtime/socket-tickets 签发实时总线地址。文中路径是对数据的示意性建模,并非公开的开发者 API。
Slack(包名 com.Slack,版本 26.09.30.0)是 Salesforce 的 Android 工作区聊天客户端,覆盖频道、私信、文件、搜索与 huddle。本页按应用界面整理了一套示意性数据接口:先在 /v1/workspaces/lookup 按邮箱或域名查找工作区,再经 /v1/workspaces/{workspaceId}/sessions 用密码或魔法链接登录(token、member_id、member_email),随后用 /v1/workspaces/{workspaceId}/boot(me、workspace、channels、direct_messages、prefs、dnd、plan_features)填充首页,侧边栏角标来自 /v1/workspaces/{workspaceId}/badge-counts。频道时间线在 /v1/channels/{channelId}/timeline 分页(messages、has_more、pin_count),资料卡走 /v1/members/{memberId}/card(full_name、email、title、presence),共享文件走 /v1/channels/{channelId}/shared-files,全文搜索走 /v1/workspace-search/{module}。发消息、设置在线状态与暂停通知等写入携带工作区会话令牌,/v1/realtime/socket-tickets 返回实时消息总线地址。
应用截图
API 端点一览
按邮箱或域名查找工作区
POST
/v1/workspaces/lookuposint把邮箱或工作区域名解析为工作区 id、名称、URL 与 SSO 标志,供登录页在密码、魔法链接或 SAML 跳转前使用。
认证方式: 无需鉴权——登录前的公开工作区发现。后续请求携带登录时签发的会话令牌。
- workspace_id
- workspace_name
- workspace_url
- email_domains
- sso_enabled
- password_signin_allowed
- device_check_required
- sso_providers
- icons
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/workspaces/lookup HTTP/1.1 Content-Type: application/json { "email": "[email protected]" }{ "ok": true, "workspace_id": "W7Q2K9D", "workspace_name": "Example Corp", "workspace_url": "https://example-corp.example.com/", "email_domains": [ "example.com" ], "sso_enabled": true, "password_signin_allowed": false, "device_check_required": false, "sso_providers": [ { "name": "Okta", "type": "saml" } ], "icons": { "small": "https://cdn.example.com/ws/w7q2k9d_68.png", "large": "https://cdn.example.com/ws/w7q2k9d_132.png" } }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据登录流程中“查找你的工作区”步骤重建SSO 提供方列表与单点登录选择页一致
登录并签发工作区会话令牌
POST
/v1/workspaces/{workspaceId}/sessionsosint对工作区成员鉴权,返回会话令牌以及后续已登录请求携带的成员与工作区标识。
认证方式: 邮箱加密码(或魔法链接验证码)。返回的令牌用于之后所有已登录请求。
- workspace_id
- token
- member_id
- member_email
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/workspaces/W7Q2K9D/sessions HTTP/1.1 Content-Type: application/json { "email": "[email protected]", "password": "<redacted>" }{ "ok": true, "workspace_id": "W7Q2K9D", "token": "sess_example_7f3a9c21", "member_id": "M4H8P2L", "member_email": "[email protected]" }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据密码 / 魔法链接登录页重建令牌与成员 id 组合与登录后应用持久化的内容一致
引导已登录客户端会话
POST
/v1/workspaces/{workspaceId}/bootopendata登录后填充首页:已登录成员、工作区、私信与频道列表、免打扰窗口、用户偏好、套餐功能开关以及可选的轮换会话令牌。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- me
- workspace
- cache_version
- direct_messages
- channels
- dnd
- prefs
- emoji_cache_ts
- starred
- plan_features
- rotated_token
- other_workspaces
- unchanged_channel_ids
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/workspaces/W7Q2K9D/boot HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "cache_version": "v12", "since": 1759000000 }{ "ok": true, "me": { "id": "M4H8P2L", "handle": "alex.rivera", "full_name": "Alex Rivera", "workspace_id": "W7Q2K9D", "timezone": "America/Los_Angeles", "presence": "active" }, "workspace": { "id": "W7Q2K9D", "name": "Example Corp", "subdomain": "example-corp" }, "cache_version": "v12", "direct_messages": [ { "id": "DM91X2", "member_id": "M0A1B2C" } ], "channels": [ { "id": "CH55Y7", "name": "platform" } ], "dnd": { "enabled": false, "next_start": 0, "next_end": 0 }, "prefs": { "muted_channels": [], "highlight_words": [] }, "emoji_cache_ts": 1758900000, "starred": [ "CH55Y7" ], "plan_features": [ "enterprise_search" ], "rotated_token": "sess_example_rotated", "other_workspaces": [ { "id": "W7Q2K9D", "name": "Example Corp" } ], "unchanged_channel_ids": [] }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据登录后首页的首次渲染重建字段分组与侧边栏分区(频道、私信、星标)对应
读取未读、提及与线程计数
POST
/v1/workspaces/{workspaceId}/badge-countsopendata返回各频道、群组私信与私信的未读/提及计数,以及驱动侧边栏圆点与应用图标角标的线程、稍后处理徽章。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- channels
- group_dms
- direct_messages
- threads
- saved
- app_badge
- fetched_at
- has_unreads
- mention_count
- latest_ts
- last_read_ts
- history_stale
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/workspaces/W7Q2K9D/badge-counts HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "include_threads": true, "include_files": true }{ "ok": true, "channels": [ { "id": "CH55Y7", "has_unreads": true, "mention_count": 2, "latest_ts": "1759000123.000200", "last_read_ts": "1758996400.000100", "history_stale": false } ], "group_dms": [], "direct_messages": [ { "id": "DM91X2", "has_unreads": false, "mention_count": 0, "latest_ts": "1758980000.000050", "last_read_ts": "1758980000.000050", "history_stale": false } ], "threads": { "has_unreads": true, "mention_count": 1, "unread_count": 4 }, "saved": { "unread_count": 0 }, "app_badge": 3, "fetched_at": "1759000400.000000" }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据侧边栏未读圆点与提及徽标重建app_badge 与桌面图标角标数一致
签发实时消息连接凭证
POST
/v1/realtime/socket-ticketsopendata签发短时有效的 WebSocket 地址(含备用地址与 TTL),供 Android 客户端用于实时消息、输入状态与在线状态总线。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- primary_url
- fallback_url
- ttl_seconds
- region
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/realtime/socket-tickets HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "workspace_id": "W7Q2K9D" }{ "ok": true, "primary_url": "wss://rt.example.com/socket?ticket=<redacted>", "fallback_url": "wss://rt-backup.example.com/socket?ticket=<redacted>", "ttl_seconds": 3600, "region": "us-east" }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据实时输入提示与即时消息送达行为重建网络切换后使用备用地址重连的行为
分页读取频道或私信消息时间线
POST
/v1/channels/{channelId}/timelineopendata分页返回频道、私有群组或私信的消息时间线(messages、has_more、pin_count、unread_count_display),供会话视图渲染。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- messages
- has_more
- pin_count
- oldest_ts
- latest_ts
- is_limited
- unread_count_display
- deleted_ts
- next_cursor
- author_id
- text
- ts
- client_msg_id
- thread_ts
- reply_count
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/channels/CH55Y7/timeline HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "limit": 50, "before_ts": null, "inclusive": true }{ "ok": true, "messages": [ { "type": "message", "author_id": "M4H8P2L", "text": "Ship the billing hotfix after standup", "ts": "1759000123.000200", "client_msg_id": "8c3e1a90-4b11-4d2e-a7c4-0f8e6b1d2a33", "thread_ts": null, "reply_count": 0 } ], "has_more": true, "pin_count": 1, "oldest_ts": "1758800000.000001", "latest_ts": "1759000123.000200", "is_limited": false, "unread_count_display": 3, "deleted_ts": [], "next_cursor": "Y3Vyc29yOjE3NTg3OTk5MDA=" }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据会话视图向上滚动分页重建置顶数与“N 条新消息”横幅对应 pin_count / unread_count_display
加载侧边栏频道元数据
POST
/v1/channels/{channelId}/detailsopendata返回频道记录(id、name、topic、description、成员标志、unread_count、member_count),用于绘制频道标题与侧边栏名册。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- channel
- id
- name
- created
- creator_id
- is_private
- is_archived
- is_member
- is_shared
- is_external
- topic
- description
- member_count
- unread_count
- last_read_ts
- latest_ts
- workspace_id
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/channels/CH55Y7/details HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "include_counts": true }{ "ok": true, "channel": { "id": "CH55Y7", "name": "platform", "created": 1609459200, "creator_id": "M4H8P2L", "is_private": false, "is_archived": false, "is_member": true, "is_shared": false, "is_external": false, "topic": { "value": "On-call + incidents", "set_by": "M4H8P2L", "set_at": 1758000000 }, "description": { "value": "Platform engineering", "set_by": "M4H8P2L", "set_at": 1609459300 }, "member_count": 42, "unread_count": 3, "last_read_ts": "1758996400.000100", "latest_ts": "1759000123.000200", "workspace_id": "W7Q2K9D" } }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据频道标题栏与频道详情页重建详情页展示的主题 / 描述 / 成员数
向频道或线程发消息
POST
/v1/channels/{channelId}/messagesopendata把撰写的消息(或线程回复)发到频道或私信,并返回规范的 ts、频道 id 与 message 载荷,供输入框在本地落盘。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- ts
- channel_id
- message
- text
- client_msg_id
- thread_ts
- also_send_to_channel
- author_id
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/channels/CH55Y7/messages HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "text": "Ship the billing hotfix after standup", "client_msg_id": "8c3e1a90-4b11-4d2e-a7c4-0f8e6b1d2a33", "thread_ts": null, "also_send_to_channel": false }{ "ok": true, "ts": "1759000123.000200", "channel_id": "CH55Y7", "message": { "type": "message", "author_id": "M4H8P2L", "text": "Ship the billing hotfix after standup", "ts": "1759000123.000200", "client_msg_id": "8c3e1a90-4b11-4d2e-a7c4-0f8e6b1d2a33" } }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据消息输入框与线程“同时发送到频道”选项重建乐观发送时使用 client_msg_id 去重
读取成员资料卡
POST
/v1/members/{memberId}/cardosint返回资料卡背后的成员记录:id、工作区、全名、email、title、phone、pronouns、状态、时区、管理员/访客标志与在线状态。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- member
- id
- workspace_id
- handle
- deactivated
- full_name
- display_name
- title
- phone
- pronouns
- status
- timezone
- tz_offset
- avatar
- role
- presence
- has_2fa
- locale
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/members/M4H8P2L/card HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "include_locale": true }{ "ok": true, "member": { "id": "M4H8P2L", "workspace_id": "W7Q2K9D", "handle": "alex.rivera", "deactivated": false, "full_name": "Alex Rivera", "display_name": "alex", "email": "[email protected]", "title": "Product Manager", "phone": "+14255550123", "pronouns": "they/them", "status": { "text": "In a huddle", "emoji": ":headphones:", "expires_at": 1759004000 }, "timezone": "America/Los_Angeles", "tz_offset": -25200, "avatar": { "small": "https://cdn.example.com/avatars/alex_72.png", "large": "https://cdn.example.com/avatars/alex_192.png" }, "role": { "is_admin": false, "is_owner": false, "is_guest": false, "is_bot": false }, "presence": "active", "has_2fa": true, "locale": "en-US" } }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据点击消息头像打开的成员资料卡重建资料卡上的状态、本地时间与代词行
列出频道内共享文件
POST
/v1/channels/{channelId}/shared-filesopendata分页返回频道或工作区文件页(id、title、filetype、mimetype、上传者、频道、paging.total),用于渲染共享文档、图片与画布。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- files
- paging
- id
- created
- title
- name
- filetype
- mimetype
- owner_id
- channel_ids
- size
- download_url
- permalink
- is_external
- comments_count
- total
- pages
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/channels/CH55Y7/shared-files HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "page": 1, "per_page": 20, "types": "all" }{ "ok": true, "files": [ { "id": "FL31Z8", "created": 1758900123, "title": "Q3 billing hotfix.pdf", "name": "q3-billing-hotfix.pdf", "filetype": "pdf", "mimetype": "application/pdf", "owner_id": "M4H8P2L", "channel_ids": [ "CH55Y7" ], "size": 248832, "download_url": "https://files.example.com/FL31Z8/q3-billing-hotfix.pdf", "permalink": "https://example-corp.example.com/files/FL31Z8", "is_external": false, "comments_count": 1 } ], "paging": { "per_page": 20, "total": 54, "page": 1, "pages": 3 } }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据频道的文件页重建page / total 计数与文件列表无限滚动一致
搜索消息、文件与人员
POST
/v1/workspace-search/{module}opendata运行应用内搜索模块(消息、文件、人员、频道),返回 query、items、pagination 与 filter_suggestions,供搜索页使用。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- query
- module
- filters
- items
- pagination
- filter_suggestions
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/workspace-search/messages HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "query": "billing hotfix", "per_page": 20, "page": 1 }{ "ok": true, "query": "billing hotfix", "module": "messages", "filters": "in:#platform", "items": [ { "id": "1759000123.000200", "channel": { "id": "CH55Y7", "name": "platform" }, "author": "alex.rivera", "text": "Ship the billing hotfix after standup", "ts": "1759000123.000200" } ], "pagination": { "total_count": 12, "page": 1, "per_page": 20, "page_count": 1 }, "filter_suggestions": { "from": [ "M4H8P2L" ], "in": [ "CH55Y7" ] } }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据搜索页的消息 / 文件 / 人员切换重建from: / in: 筛选标签对应 filter_suggestions
设置成员手动在线状态
POST
/v1/me/presenceopendata写入已登录成员的手动在线状态(away 或 auto),同事会在资料卡与私信标题上看到。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- ok
- presence
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/me/presence HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "presence": "away" }{ "ok": true, "presence": "away" }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据“我”页中“设为离开”开关重建
暂停通知(请勿打扰)
POST
/v1/me/notification-pauseopendata按分钟开启请勿打扰,返回暂停标志、结束时间与剩余秒数,供暂停通知控件使用。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- paused
- ends_at
- remaining_seconds
- indefinite
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/me/notification-pause HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json { "minutes": 60 }{ "ok": true, "paused": true, "ends_at": 1759004000, "remaining_seconds": 3600, "indefinite": false }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据“暂停通知”时长选择器重建铃铛图标旁显示的剩余时间倒计时
读取工作区成员构成
POST
/v1/workspaces/{workspaceId}/member-censusopendata返回工作区人口统计(正式成员、多频道与单频道访客、管理员、所有者、机器人、已邀请、在线、活跃),供工作区目录与管理界面使用。
认证方式: Authorization: Bearer <工作区会话令牌>,由工作区登录调用签发
- members
- full
- guests_multi_channel
- guests_single_channel
- admins
- owners
- bots
- deactivated
- invited
- online
- active
依据应用界面重构的示意示例,并非实时抓包。
POST /v1/workspaces/W7Q2K9D/member-census HTTP/1.1 Authorization: Bearer <session-token> Content-Type: application/json {}{ "ok": true, "members": { "full": 412, "guests_multi_channel": 18, "guests_single_channel": 6, "admins": 9, "owners": 2, "bots": 27, "deactivated": 41, "invited": 5, "online": 86, "active": 390 } }依据应用界面推导;端点细节为示意说明,并非实际抓包。
依据工作区目录顶部的人数统计重建访客类型拆分与管理员成员筛选一致
数据类别
- 工作区身份
- 会话引导
- 未读计数
- 频道元数据
- 消息
- 成员资料
- 文件
- 搜索
- 在线状态
- 请勿打扰
数据使用场景与案例
工作区目录叠加
拉取 /v1/members/{memberId}/card(full_name、email、title、phone、pronouns、timezone)以及 /v1/workspaces/{workspaceId}/member-census(正式成员、访客、管理员、在线、活跃),让 HR 或 IT 目录与 Slack 工作区人口保持同步,而无需抓取人员页。
频道未读对账
轮询 /v1/workspaces/{workspaceId}/badge-counts 获取各频道 has_unreads、mention_count、latest_ts 与 last_read_ts,并在 history_stale 翻转时分页 /v1/channels/{channelId}/timeline,让副收件箱或值班机器人只呈现仍有未读的会话。
共享文件盘点
按频道遍历 /v1/channels/{channelId}/shared-files(id、title、filetype、mimetype、owner_id、channel_ids、paging.total),构建留存或 DLP 清单,键为文件页展示的同一文件 id。
搜索驱动的知识沉淀
用 /v1/workspace-search/messages 重放事故关键词查询,保存 query、items 与 pagination,让复盘 wiki 引用应用内搜索页返回的同一批命中。
常见问题
Slack Android 应用如何鉴权数据调用?
公开的 /v1/workspaces/lookup 解析工作区及其 SSO 选项,随后 /v1/workspaces/{workspaceId}/sessions 返回会话令牌、member_id 与 member_email。之后的首页引导、时间线、资料卡、文件与发消息等调用都以 Bearer 方式携带该令牌。
哪些数据驱动未读角标与首页?
/v1/workspaces/{workspaceId}/boot 在登录后填充 me、workspace、channels、direct_messages、prefs 与 dnd。/v1/workspaces/{workspaceId}/badge-counts 随后返回各频道 has_unreads、mention_count、latest_ts 与 last_read_ts,以及线程与稍后处理徽章;实时更新经 /v1/realtime/socket-tickets 签发的连接推送。
能否读取频道消息、文件与成员资料?
可以。/v1/channels/{channelId}/timeline 分页返回含 ts、text、author_id 的 messages 与 has_more;/v1/channels/{channelId}/shared-files 返回文件 id、title、filetype、mimetype 与 paging;/v1/members/{memberId}/card 返回 full_name、email、title、phone、pronouns 与 presence。均需已登录的工作区令牌。
这是 Slack 的公开 Web API 吗?
不是。本页路径是对应用界面(登录、首页、频道、资料卡、文件与搜索)背后数据的示意性建模,并非任何生产接口的复刻,也不是 Slack 文档化的开发者平台。
相关主题
- slack 数据 api
- slack android 数据模型
- slack 频道消息时间线
- slack 未读角标
- slack 成员资料卡
- slack 共享文件
- slack 工作区搜索
- slack 工作区会话令牌
- slack 请勿打扰
- slack 工作区成员统计
需要集成这个 App 的数据 API?
我们可为任意指定 App 交付定制集成——源码交付 USD 500 起,或托管 API 按调用计费。告诉我们您需要的数据即可。
- 每个项目均签 NDA 与 SOW
- 3–7 天交付
- 验收通过后才付款
- 仅在授权范围内作业