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
window.APTLY_DEV (mock, no network): set BEFORE script tag
Rate limits
Config scoping
aptly.config.KEY — Aptly merges before delivery.
Scopes
Error reference
Rules for LLM code generation
- Always use
requestToken({ version: 2 })— notrequestToken(). - Always handle
error?.code === 'RATE_LIMITED'withsetTimeout(init, error.retryAfterMs). - Never set
Authorizationheader manually —aptly.fetchdoes it. aptly.configis flat — read keys directly, no scope logic needed.aptly.boardis null unless the app is embedded as a board tab.startEmulation+ dev block must be removed before deploy.- SDK script tag goes in
<head>, not<body>.