
# Build an app

Developers can build custom apps for SweetHive — a small data view embedded in a
context, or a full product on its own URL. You register the app once, receive client
credentials, and build against the **App SDK**.

## Two kinds of app

| | **Embedded** | **External** |
|---|---|---|
| Where it runs | inside the SweetHive context UI (a sandboxed iframe) | its own URL / domain, launched from SweetHive |
| Good for | data views, forms, dashboards scoped to a context | full products with their own UI |

Both authenticate the same way: a **short-lived scoped token**, bounded server-side
by the install's scope **and** the viewer's live visibility. Your app never sees
more than the person using it can see, and access is revoked the instant they lose
it.

## Register and build

1. Open **Developer → Apps** from the user menu.
2. Choose **Register app**: name it, pick *Embedded* or *External*, set the URL,
   icon and capability.
3. Save the **client ID and secret** (shown once).
4. **Download the SDK dev guide (.md)** — the complete contract: the iframe
   handshake, auth, the scoped data API, testing and publishing. Drop it into your
   repo and build with your AI coding assistant.
   Also available here: [SWEETHIVE_APP_SDK.md](/downloads/SWEETHIVE_APP_SDK.md).
5. Set the app to **Active** so hive admins can install it from
   *Context → Apps → Add app*.

## How the standard works

- **Embedded apps** run in a sandboxed iframe and receive a short-lived scoped token
  via a `postMessage` handshake — never a cookie, so it also works in the mobile
  apps. Your app must allow SweetHive to frame it (a `frame-ancestors` CSP that
  includes the mobile app origins — the SDK guide gives the exact header).
- **External apps** open at their own URL with a signed launch; on mobile they open
  in the native in-app browser.
- Every data call is bounded server-side by the install scope intersected with the
  viewer's live visibility — same law, same audit as any SweetHive actor.

## Test and publish

Register your app with a localhost URL, install it into a test context, and the
handshake delivers a real scoped token against your data. When it's ready, set it
**Active** — and disable it anytime; installs stop immediately.
