Cairn Developers

DEVELOPERS · PREVIEW

Bot Web API

Apps call Cairn’s Web API with a bot token to post and update cards and open modals. Method names, arguments, responses and error codes follow the Slack Web API.

This specification is a preview. External developers cannot register apps or issue bot tokens yet (only first-party apps run today). Details may change before registration opens.

Requests

  • The endpoint is POST https://oss-cairn.com/api/app-api/<method> (laid out like Slack’s https://slack.com/api/<method>). Self-hosted deployments use their own host
  • Send application/x-www-form-urlencoded (the default of Bolt and @slack/web-api) or application/json. With form encoding, send blocks / view as JSON strings. Bodies are limited to 1 MB
  • Pass the token as Authorization: Bearer <token> or as a token body field (the header wins)
curl -X POST https://oss-cairn.com/api/app-api/chat.postMessage \
  -H "Authorization: Bearer $CAIRN_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "3b1f...-channel-uuid",
    "text": "Lunch vote",
    "blocks": [{ "type": "section", "text": { "type": "mrkdwn", "text": "*Where shall we go?*" } }]
  }'

Responses

As in Slack, the HTTP status is always 200 and success is indicated by ok. On failure, error holds an error code and response_metadata.messages holds details when available.

{
  "ok": true,
  "channel": "3b1f...-channel-uuid",
  "ts": "9c2e...-message-uuid",
  "message": {
    "type": "message",
    "text": "Lunch vote",
    "user": "<bot user UUID>",
    "bot_id": "<installation UUID>",
    "app_id": "<app UUID>",
    "ts": "9c2e...-message-uuid",
    "blocks": [ ... ]
  },
  "cairn": { "message_id": "9c2e...-message-uuid" }
}

The exception is rate limiting: above 120 calls per minute per token, Cairn returns HTTP 429 with Retry-After: 60 (Bolt waits and retries).

Methods

MethodScopeArgumentsDescription
auth.test——Verifies the token (Bolt calls it on start). Returns team_id, user_id (the bot), bot_id, app_id and more
chat.postMessagechat:writechannel, text, blocks, client_msg_idPosts to a channel the bot is in
chat.updatechat:writechannel, ts, text, blocksUpdates a message posted by the same installation’s bot
chat.deletechat:writechannel, tsDeletes a message posted by the same installation’s bot
users.infousers:readuserID, display name and avatar of an active workspace member
conversations.memberschannels:readchannelIDs of active members of a channel the bot is in. Not paginated; next_cursor is always empty
views.open—trigger_id, viewOpens a modal (see Modals)
views.update—view_id, view, hashReplaces an open modal

chat.postMessage / chat.update / chat.delete

  • text is the fallback used for notifications, search, quotes and clients that cannot draw the card. If omitted, Cairn builds it from the blocks’ headers and text. When nothing can be built (e.g. a card with only buttons) you get no_text, so pass text
  • client_msg_id (a UUID) becomes the message ID; a retry with the same ID returns the existing message instead of posting again, so retries never double-post
  • thread_ts is not supported. Threads in Cairn are separate channels, so pass the thread’s channel ID as channel
  • chat.update does not mark the message as edited. Omitting text keeps the fallback text; sending only text without blocks removes the card and turns it into a regular message (as in Slack)
  • For chat.update / chat.delete, pass the message UUID (the ts from the post response) as ts
  • Like messages from people, bot messages trigger mention notifications and are searchable

users.info / conversations.members

  • Only active workspace members are returned; deactivated members are treated as absent
  • The user from users.info has id, team_id, name, real_name, profile.display_name, profile.image_72 and so on. Email addresses are not returned
  • conversations.members does not include the bot itself

Error codes

errorMethodsMeaning
not_authedAllNo token was sent
invalid_authAllThe token is not valid
token_revokedAllThe token was revoked or the app was uninstalled
ratelimitedAllRate limit exceeded (HTTP 429)
missing_scopeAllA scope is missing; needed / provided are included
unknown_methodAllThe method is not supported
invalid_form_dataAllThe body could not be read or exceeded 1 MB
internal_errorAllAn error on Cairn’s side
channel_not_foundchat.*, conversations.membersNo such channel, or it belongs to another workspace
not_in_channelchat.*, conversations.membersThe bot has not been added to the channel
is_archivedchat.*, conversations.membersThe channel (or the thread’s parent) is archived
method_not_supported_for_channel_typechat.*, conversations.membersDMs are not supported
no_textchat.postMessage, chat.updateNeither text nor blocks, or no fallback text can be built from the blocks
msg_too_longchat.postMessage, chat.updatetext exceeds 40,000 characters
invalid_blockschat.postMessage, chat.updateThe blocks are not accepted; reasons in response_metadata.messages
invalid_blocks_formatchat.postMessage, chat.updateblocks is not valid JSON
invalid_argumentschat.*, views.*Invalid arguments (thread_ts, a non-UUID client_msg_id, an invalid view, …)
client_msg_id_conflictchat.postMessageThe client_msg_id is already used in another channel or by another sender
message_not_foundchat.update, chat.deleteNo such message, or it was deleted
cant_update_messagechat.updateNot a message from this bot
cant_delete_messagechat.deleteNot a message from this bot
user_not_foundusers.infoNot an active member
invalid_trigger_idviews.openThe trigger_id is invalid or already used
expired_trigger_idviews.openThe trigger_id expired (6 seconds)
not_foundviews.updateNo such modal, or it was closed
hash_conflictviews.updateThe view changed since the given hash
view_is_submittingviews.updateThe view cannot be replaced while a submission is being delivered
Reason texts in response_metadata.messages are currently in Japanese. Branch on the error code.