App platform

Blocks

Blocks are UI as JSON. Kweko asks your backend for them, checks them and draws them with its own components, so they look native, work on phones and follow the member's theme and language.

The blocks request

When a member opens a place where your app contributes blocks (a lead tab, a card on the lead panel, a dock widget…), Kweko sends a signed POST to your backend URL plus the app's blocks path (/kweko/blocks unless you changed it):

Request body
{
  "context": {
    "extension_point": "lead.panel.card",
    "contribution_id": "stock",
    "installation_id": "ins_01j8za1c2d3e4f5g6h7j8k9m0n",
    "workspace": { "id": "ws_…", "name": "Acme", "currency": "UZS", "timezone": "Asia/Tashkent" },
    "member": { "id": "mb_…", "name": "Aziz Rahimov", "locale": "uz", "role": "manager" },
    "theme": { "mode": "light" },
    "locale": "uz",
    "issued_at": "2026-09-27T09:41:12Z",
    "entity": { "type": "lead", "id": "ld_…" },
    "action_token": "kwk_act_…"
  },
  "extension_point": "lead.panel.card",
  "contribution_id": "stock"
}

Headers: Kweko-App (your app id), Kweko-Timestamp and Kweko-Signature, signed like webhooks with your client secret. Verify the signature over the raw body and reject timestamps older than 5 minutes before you trust the context.

Answer within 1 second with 200 and:

Response
{
  "blocks": [
    { "type": "heading", "text": "Stock" },
    { "type": "key_value", "items": [ { "label": "Office chair Ergo", "value": { "type": "text", "text": "12 in stock" } } ] },
    { "type": "button", "label": "Reserve", "style": "primary", "action": { "id": "reserve" }, "confirm": "Reserve 2 items?" }
  ],
  "cache_ttl": 30
}

cache_ttl (0 to 3600 seconds) lets Kweko reuse the blocks. A slow, failing or invalid answer is not shown: Kweko shows an error in place of your blocks (app_slow, app_error, invalid_blocks).

Actions

When a member presses a button or submits a form in your blocks, Kweko posts to your actions path (/kweko/actions unless changed), signed the same way, with 10 seconds to answer:

Request body
{ "context": { … }, "contribution_id": "stock", "action_id": "reserve", "values": { "qty": "2" } }

values holds the form fields by name. Composer contributions receive action_id composer.submit with values.text. Answer with any of:

KeyEffect
blocksReplace the blocks
toast{"text": "Reserved", "tone": "success"}, text up to 300 characters
navigateAn in-app path such as /leads/ld_…
refreshRecord types to reload, for example ["lead"] (up to 10)
open_frame{"path": "/kweko/reserve", "title": "Reserve"}: open one of your pages as a frame

Acting for the member

Every blocks and actions request carries context.action_token (kwk_act_…). When your backend then calls the Kweko API because of what the member did, send it next to your installation access token:

http
POST /v1/notes
Authorization: Bearer <installation access token>
Kweko-On-Behalf-Of: kwk_act_…
  • The call runs as Your app for Member name in the record's history and the audit log.
  • It may do only what both your granted scopes and the member's role allow, on records the member can see. A viewer's token can read, never write.
  • The token lives 5 minutes and belongs to one installation and one member. Use it for the work that follows a click; for background jobs use the access token alone.
  • A tampered, expired or foreign token answers 401 invalid_action_token. A member who was deactivated since answers 403 member_unavailable. The token is never accepted on its own as a bearer token.

apiHeaders({ accessToken, actionToken }) in @kweko/sdk/server builds the headers.

Images

An image block's url must be https://. Kweko never sends it to the member's browser: it rewrites it to a signed link on Kweko's own image proxy, which fetches the file from your server (no cookies, 5 second timeout, no redirects to another host, public addresses only) and serves it back.

  • PNG, JPEG, GIF and WebP up to 2 MB, detected from the file's bytes, not its Content-Type. SVG and anything else is refused and the image is not shown.
  • The link works only for members of the workspace it was made for, while your app is installed and turned on. Browsers may cache an image for 5 minutes.

Refreshing blocks

When data changes on your side, ask Kweko to refetch a contribution on every screen that shows it:

http
POST /v1/apps/ui/refresh
Authorization: Bearer <installation access token>
Content-Type: application/json

{ "contribution_id": "stock", "entity_type": "lead", "entity_id": "ld_…" }

entity_type and entity_id are optional: without them every open copy of the contribution refetches. The push carries no data; each screen asks your backend again as its own member. Answers 202. Needs ui:extend, a Blocks contribution of your app, and at most about 1 refresh per second per installation (bursts of 10, then 429 with Retry-After). refreshUI() in @kweko/sdk/server sends it.

App data on records

Your app can keep small JSON values on leads, contacts and companies, for example a sync status or an external id, without a custom field the workspace has to create:

MethodPathNotes
GET/v1/{leads,contacts,companies}/{id}/app-dataYour keys on the record ({ "data": [{ "key", "value", "updated_at" }] })
GET/v1/{leads,contacts,companies}/{id}/app-data/{key}One key, 404 when not set
PUT/v1/{leads,contacts,companies}/{id}/app-data/{key}Body { "value": … }, any JSON except null
DELETE/v1/{leads,contacts,companies}/{id}/app-data/{key}204
  • Keys are a-z, 0-9 and _, up to 40 characters. A value is up to 8 KB of JSON (payload_too_large); an app keeps up to 50 keys per record (422 app_data_limit).
  • Each app sees only its own keys. Reading needs the record's read scope, writing its write scope, and an action token narrows both to what the member can do.
  • A record another workspace owns, or one the caller can't see, answers 404.

Block types

Generated from the API's validator: each type accepts only these keys (besides type).

TypeKeys
texttext, tone
headingtext
key_valueitems
badgetext, tone
buttonlabel, style, action, confirm, optimistic, disabled
button_groupbuttons
listitems
tablecolumns, rows
inputname, label, input_type, placeholder, value, required, hint
selectname, label, options, multiple, value, required, placeholder
checkboxname, label, value
togglename, label, value
formblocks, submit
imageurl, alt, width, height
dividernone
alerttone, title, text, action
progressvalue, label
chartkind, title, series, stacked
emptytext, action
open_framelabel, path

Tones (tone) are default, muted, neutral, success, warning, danger and info. Charts (kind) are area, line, bar or donut. A button_group holds up to 3 buttons, and form holds input blocks in blocks with a submit button.

Rules and limits

Kweko validates every response before it reaches a browser. A response that breaks a rule is not shown at all:

  • Only the types and keys above. No HTML, scripts, styles or event handlers anywhere.
  • Links and images must be https://. navigate and open_frame paths must be relative to Kweko or your app, starting with a single /.
  • At most 64 KB, 200 blocks, nesting 6 deep, 50 table rows, 500 points per chart series and 4000 characters of text.