Slaikydocs

    Build an app#webhooks

    Incoming webhooks

    A secret URL that posts into one channel as your app’s bot. No token and no server: one POST from any system.

    An incoming webhook is the simplest way in: a URL that posts into one channel as your app’s bot. Anything that can send an HTTP POST can use it, like a deploy script, a monitor or a form. There is nothing to host and no token to keep, only the URL.

    Make one

    On the app’s page, open Incoming webhooks, pick a Channel and press Create URL. Copy it now: it isn’t shown again. Make as many as you need, say one per channel or one per system.

    • The channel is one you are in, public or private. Direct messages can’t have one.
    • The app’s bot joins that channel.
    • The app gets the incoming-webhook permission (Post through incoming webhooks), shown under Permissions.
    • Whoever manages the app makes and removes its webhooks.

    The URL looks like https://app.slaiky.xyz/api/hooks/….

    Post

    Send JSON with a text. No Authorization header: the URL is enough.

    you run
    curl -s "$SLAIKY_WEBHOOK_URL" \
      -H 'content-type: application/json' \
      -d '{"text": "Deploy finished. *All green.*"}'
    your app → Slaikypost.mjs
    // Post into the webhook's channel as the app's bot. Node 22+, no packages.
    const res = await fetch(process.env.SLAIKY_WEBHOOK_URL, {
      method: 'POST',
      headers: { 'content-type': 'application/json' },
      body: JSON.stringify({ text: 'Deploy finished. *All green.*' }),
    });
    const answer = await res.json();
    console.log(JSON.stringify(answer));
    if (!answer.ok) process.exit(1);
    your app → Slaikypost.py
    # Post into the webhook's channel as the app's bot. Python 3, no packages.
    import json, os, urllib.error, urllib.request
    
    req = urllib.request.Request(
        os.environ["SLAIKY_WEBHOOK_URL"],
        data=json.dumps({"text": "Deploy finished. *All green.*"}).encode(),
        headers={"content-type": "application/json"},
    )
    try:
        with urllib.request.urlopen(req) as res:
            answer = json.load(res)
    except urllib.error.HTTPError as err:  # a refusal still answers JSON
        answer = json.load(err)
    print(json.dumps(answer))
    if not answer["ok"]:
        raise SystemExit(f"{answer['error']['code']}: {answer['error']['message']}")
    Slaiky → your app
    { "ok": true, "messageId": "7f3c0021-5a1e-4c2b-9d6f-1a2b3c4d5e14" }

    The message shows up in the channel at once, from the app’s bot, with its APP badge.

    The body

    FieldWhat it is
    textThe message, in Markdown, up to 40000 characters. Notifications and search show it.
    blocksOptional. Up to 50 layout blocks from the closed catalog.

    Send text, blocks or both. A body with neither is refused with 400 and bad_request; a wrong field, with 422 and invalid, naming it in fields. Other fields are ignored. With blocks, keep a text too: it is what people read where blocks don’t show.

    your app → Slaikybody
    {
      "text": "Deploy finished: api on main",
      "blocks": [
        { "type": "header", "text": "Deploy finished" },
        { "type": "section", "text": "*api* is live.", "fields": ["*Branch*\nmain", "*Commit*\n4f2c9e1"] },
        { "type": "context", "elements": ["Sent by CI"] }
      ]
    }

    A button in a webhook’s message reaches your app like a button in any of its messages (Commands, shortcuts and buttons).

    The URL is the secret

    Whoever has the URL can post as your bot in that channel. Keep it where you keep passwords: a secret store, or an environment variable on the machine that sends.

    Removing the app, or turning its bot off, stops all its webhooks too. So does taking away its incoming-webhook permission: its URLs then answer 403 with missing_scope. Posts to one URL are limited to 60 per 1 minute, and calls from one address to any webhook URL to 600 per 1 minute. Over a limit, the answer is 429 with Retry-After (Errors and rate limits).

    When to use a bot token instead

    A webhook only posts new messages, in its one channel. Use the bot token with the Web API when your code needs to:

    • post in several channels, in a thread, or to one person;
    • edit or delete what it posted;
    • read messages, react, or look people up;
    • hear events, commands and clicks (Socket Mode, or events over HTTP).

    Both can live in one app. A webhook’s messages are its bot’s, so chat.update with the bot token can edit one later, by the messageId the webhook answered.

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