Skip to main content

Identity

  • Script tag: <script src="https://preview.getaptly.com/api/ai/app-builder/sdk.js"></script>
  • Global: window.aptly — auto-init on script load
  • API base: https://core-api.getaptly.com

State (read-only after init)


Methods

aptly.requestToken(opts?)

aptly.fetch(path, options?)

aptly.startEmulation(token, opts?)

aptly.action(actionId, payload?)

Named action wrappers (generated from aptly.actions)


Canonical pattern (always use this)


Dev testing (pick one, remove before deploy)

Option A — startEmulation (recommended): real identity, requires dev token from Settings → Profile → Developer Tools
Option B — window.APTLY_DEV (mock, no network): set BEFORE script tag
Option C — URL params: no code change

Rate limits


Config scoping

App code always reads aptly.config.KEY — Aptly merges before delivery.

Scopes


Error reference


Rules for LLM code generation

  1. Always use requestToken({ version: 2 }) — not requestToken().
  2. Always handle error?.code === 'RATE_LIMITED' with setTimeout(init, error.retryAfterMs).
  3. Never set Authorization header manually — aptly.fetch does it.
  4. aptly.config is flat — read keys directly, no scope logic needed.
  5. aptly.board is null unless the app is embedded as a board tab.
  6. startEmulation + dev block must be removed before deploy.
  7. SDK script tag goes in <head>, not <body>.