Slaikydocs

    Build an app#web-api

    Calling the Web API

    One POST per method, with your bot token and a JSON body. How to post, reply in a thread, upload a file and read every answer.

    The Web API is how your app speaks first: posting, reacting, opening a DM, uploading a file. There are 61 methods, and every one is called the same way. You need a bot token (slk-bot-…, see Apps, bots and tokens).

    The request

    Every call is a POST to https://app.slaiky.xyz/api/methods/<method>, with two headers and a JSON object:

    • Authorization: Bearer slk-bot-…: the bot token. It also names the workspace, so there is no workspace header.
    • Content-Type: application/json, and a JSON body with the method’s arguments ({} when it takes none).

    Check your token with auth.test. It answers with the bot, its app and the permissions it holds:

    you run
    curl -s https://app.slaiky.xyz/api/methods/auth.test \
      -H "authorization: Bearer $SLAIKY_BOT_TOKEN" \
      -H 'content-type: application/json' \
      -d '{}'
    Slaiky → your appanswer (shortened)
    {
      "ok": true,
      "bot": { "id": "7f3c0004-5a1e-4c2b-9d6f-1a2b3c4d5e03", "handle": "deploybot", "name": "Deploy bot", "isBot": true },
      "appId": "7f3c0002-5a1e-4c2b-9d6f-1a2b3c4d5e01",
      "workspaceId": "7f3c0003-5a1e-4c2b-9d6f-1a2b3c4d5e02",
      "scopes": ["chat:write", "channels:read", "channels:history", "channels:join", "app_mentions:read"]
    }

    A few methods take something else: apps.manifest.* take a configuration token, and tooling.tokens.rotate and oauth.v2.access take no token at all (Manifests, Other workspaces).

    The answer

    Every answer is JSON with ok. When it worked, ok is true and the method’s own keys sit next to it (message, channel, files…). When it did not, the HTTP status says what kind of no it is, and error says why:

    Slaiky → your apprefusal
    {
      "ok": false,
      "error": {
        "code": "missing_scope",
        "message": "This app needs the pins:write permission for that",
        "needed": "pins:write"
      }
    }

    Program against code: it never changes. message is for people, in the language your Accept-Language header asks for. Some refusals add a key: needed (the permission that would do), fields (each argument that is wrong, on 422 invalid), retryAfter (on 429). Every code is on Errors.

    Post a message

    chat.postMessage takes a channel and a text in Markdown. The same call in three languages, each file tested against a real server:

    your app → Slaikypost-message.sh
    curl -s "${SLAIKY_API:-https://app.slaiky.xyz/api/methods}/chat.postMessage" \
      -H "authorization: Bearer $SLAIKY_BOT_TOKEN" \
      -H 'content-type: application/json' \
      -d "{\"channel\": \"${SLAIKY_CHANNEL:-#general}\", \"text\": \"Deploy finished. *All green.*\"}"
    your app → Slaikypost-message.mjs
    // Post a message as your bot. Node 22+, no packages.
    const API = process.env.SLAIKY_API ?? 'https://app.slaiky.xyz/api/methods';
    
    const res = await fetch(`${API}/chat.postMessage`, {
      method: 'POST',
      headers: { authorization: `Bearer ${process.env.SLAIKY_BOT_TOKEN}`, 'content-type': 'application/json' },
      body: JSON.stringify({ channel: process.env.SLAIKY_CHANNEL ?? '#general', text: 'Deploy finished. *All green.*' }),
    });
    const answer = await res.json();
    console.log(JSON.stringify(answer));
    if (!answer.ok) process.exit(1);
    your app → Slaikypost_message.py
    # Post a message as your bot. Python 3, no packages.
    import json, os, urllib.request
    
    API = os.environ.get("SLAIKY_API", "https://app.slaiky.xyz/api/methods")
    TOKEN = os.environ["SLAIKY_BOT_TOKEN"]
    
    
    def call(method, body):
        req = urllib.request.Request(
            f"{API}/{method}",
            data=json.dumps(body).encode(),
            headers={"authorization": f"Bearer {TOKEN}", "content-type": "application/json"},
        )
        try:
            with urllib.request.urlopen(req) as res:
                return json.load(res)
        except urllib.error.HTTPError as err:  # a refusal still answers JSON
            return json.load(err)
    
    
    answer = call("chat.postMessage", {"channel": os.environ.get("SLAIKY_CHANNEL", "#general"), "text": "Deploy finished. *All green.*"})
    print(json.dumps(answer))
    if not answer["ok"]:
        raise SystemExit(f"{answer['error']['code']}: {answer['error']['message']}")
    you run
    export SLAIKY_BOT_TOKEN=slk-bot-…
    SLAIKY_CHANNEL='#deploys' node post-message.mjs

    A new app may join public channels (channels:join), so its first post to one joins it. Messages can also carry buttons and layout: Messages.

    Channels by id or by name

    channel takes a conversation’s id, or #name for a channel (public or private). Direct messages and group DMs have no name: use the id an event gives you (channelId) or the one conversations.open answers.

    Names change when someone renames a channel. Ids never do, so store ids.

    A private channel or a DM the bot is not in doesn’t exist for it: the answer is 404 not_found. To post in a public channel it is not in, the app needs channels:join (it joins) or chat:write.public (it posts without joining); with neither, the answer is missing_scope. More on this in Where the bot can act.

    Reply in a thread

    Add threadId: the id of the thread’s first message. Add alsoInChannel: true to show the reply in the channel too.

    your app → Slaikychat.postMessage
    {
      "channel": "7f3c0009-5a1e-4c2b-9d6f-1a2b3c4d5e08",
      "threadId": "7f3c0007-5a1e-4c2b-9d6f-1a2b3c4d5e06",
      "text": "Deploy is green."
    }
    Slaiky → your appanswer (shortened)
    {
      "ok": true,
      "message": {
        "id": "7f3c0021-5a1e-4c2b-9d6f-1a2b3c4d5e14",
        "channelId": "7f3c0009-5a1e-4c2b-9d6f-1a2b3c4d5e08",
        "parentId": "7f3c0007-5a1e-4c2b-9d6f-1a2b3c4d5e06",
        "body": "Deploy is green.",
        "createdAt": "2026-11-10T12:00:02.000Z"
      }
    }

    When you answer an event, the thread is event.message.parentId ?? event.message.id: a message written inside a thread already has a parentId. The id of a reply is refused, and so is a message from another conversation.

    Upload a file

    A file takes three calls. Both methods need files:write, which a new app holds; sharing the file in a conversation also needs chat:write.

    1. files.getUploadURL with filename, length (its exact size in bytes, up to 50 MB) and, if you know it, mime. It answers uploadUrl and fileId.
    2. A POST of the raw bytes to uploadUrl, within 5 minutes. The URL works once, and only for exactly length bytes.
    3. files.completeUpload with files: [{ "id": fileId }] and a channel (with text and threadId if you like). It answers the files and the message that shares them. Without channel, the file is kept but not shared, and message is null.

    Every file is checked for viruses before anyone can open it. A harmful one is refused at step 2 with 422 file_harmful, and nothing is kept. If the check can't finish yet, the file comes back with "scan": "checking" and step 3 answers 409 file_checking until it is done: try again in a minute. A file shown with "scan": "blocked" was found harmful later and can't be opened.

    your app → Slaikyupload.mjs
    // Upload a file and share it in a channel as your bot. Node 22+, no packages.
    const API = process.env.SLAIKY_API ?? 'https://app.slaiky.xyz/api/methods';
    const TOKEN = process.env.SLAIKY_BOT_TOKEN;
    
    async function call(method, body) {
      const res = await fetch(`${API}/${method}`, {
        method: 'POST',
        headers: { authorization: `Bearer ${TOKEN}`, 'content-type': 'application/json' },
        body: JSON.stringify(body),
      });
      const data = await res.json();
      if (!data.ok) throw new Error(`${method}: ${data.error.code} ${data.error.message}`);
      return data;
    }
    
    const bytes = new TextEncoder().encode('Deploy 412: all checks green.\n');
    
    // 1. Ask where to send the bytes, saying exactly how many there are.
    const { uploadUrl, fileId } = await call('files.getUploadURL', { filename: 'deploy.log', length: bytes.length, mime: 'text/plain' });
    
    // 2. Send them there, raw. No token: the URL is the secret, and it works once.
    const sent = await fetch(uploadUrl, { method: 'POST', headers: { 'content-type': 'text/plain' }, body: bytes });
    if (!sent.ok) throw new Error(`upload: ${sent.status} ${await sent.text()}`);
    
    // 3. Share the file in a channel, with a message.
    const answer = await call('files.completeUpload', {
      files: [{ id: fileId }],
      channel: process.env.SLAIKY_CHANNEL ?? '#general',
      text: 'The deploy log.',
    });
    console.log(JSON.stringify(answer));

    Rate limits

    Calls are limited per bot: 120 per 10 seconds, across all methods. Calls that do what a person does (post, edit, react, upload, change a channel) also count against the limit a person has for that action.

    Over a limit, the answer is 429 with a Retry-After header in seconds. The body says the same, and scope names the limit you hit:

    Slaiky → your app429
    {
      "ok": false,
      "error": { "code": "rate_limited", "message": "Too many attempts. Try again in 4 seconds.", "retryAfter": 4, "scope": "botApi" }
    }

    Wait that long, then send the same call again.

    Where to next

    Updated . Every method, scope, event and limit here is generated from the server’s own code.