<!-- AANCER developer pages, part 13 of 16. All parts: https://aancer.ai/dev/llms.txt -->

## Common errors

| Code | Status | Message | Fix |
|---|---|---|---|
| `VALIDATION` | 400 | definition is required | Wrap the hook in `{"definition": ...}` |
| `HOOK_FILTER_INVALID` | 400 | /id: must match ^[a-z0-9][a-z0-9._-]{0,63}$ | Lower-case id |
| `HOOK_FILTER_INVALID` | 400 | /id: a hook with this id already exists | Choose another id, or use PUT |
| `HOOK_EVENT_UNKNOWN` | 400 | /event/name: unknown event '...' | Use a catalog name |
| `HOOK_FILTER_INVALID` | 400 | /filter: at most 8 clauses (OR = two hooks) | Split into two hooks |
| `HOOK_FILTER_INVALID` | 400 | /filter/0/path: path must start with payload., resource. or be actor.role | |
| `HOOK_FILTER_INVALID` | 400 | /filter/0/value: in needs an array value / value is required | |
| `HOOK_LIMIT_EXCEEDED` | 422 | At most 100 hooks per workspace. | Retire unused hooks |
| `HOOK_HANDLER_NOT_FOUND` | 422 | Workflow '...' does not exist. / Agent '...' does not exist. | Create it first |
| `HOOK_HANDLER_FORBIDDEN` | 422 | Workflow '...' belongs to another workspace. | Use a handler in the hook's workspace |
| `HOOK_HANDLER_INACTIVE` | 422 | the workflow is not published with an Event trigger | Publish it with the AANCER Event trigger, then enable |
| `HOOK_INVALID` | 400 | /dataClassification: sovereign, internal or permitted | Use one of the three values |
| warning `HANDLER_INACTIVE` |  | the workflow is not published with an Event trigger; deliveries will fail until it is. | Publish it with the AANCER Event trigger, then enable |
| `HOOK_MANAGED_BY_PACK` | 409 | This hook is managed by pack '...'; edit the pack. | Ship a new pack version |
| `DELIVERY_NOT_RETRYABLE` |  | A '...' delivery cannot be retried. | Only failed or dead-lettered deliveries |
| `HOOK_DISABLED` | 409 | A disabled hook cannot replay; enable it first. | |
| `HOOK_REPLAY_WINDOW_INVALID` | 400 | The replay window is limited to 30 days. | Choose `from` and `to` within 30 days |
| `HOOK_REPLAY_TOO_LARGE` | 400 | More than 1000 events match; narrow the window. | Narrow the window |
| delivery `lastError` |  | HANDLER_INACTIVE: Workflow '...' listens to '...', not '...'. | Make the trigger event and the hook event match |
| `PACK_SCHEMA_INVALID` | 422 | /items/.../spec: must NOT have additional properties | For example `dataClassification` in a pack spec. Remove it |

## Limits and editions

- 100 hooks per workspace, 8 filter clauses per hook, 20 concurrent deliveries per hook.
- Replay reaches events the installation still keeps, up to 30 days per replay.
- Hooks are controlled by permissions: `hooks.view_own`, `hooks.manage_own`. Firing a workflow also needs the workflow to be allowed to run.
- Check your edition on [aancer.ai/pricing](https://aancer.ai/pricing).


---

Source: https://aancer.ai/developers-apps

---
title: Embedded apps | AANCER Developers
description: Add your own web application inside AANCER: the app manifest, single sign-on by one-time code, the bridge protocol, sandbox, navigation and approval.
---

## Embedded apps

An embedded app is a web application that you host yourself, on its own https origin, and that AANCER shows inside its own interface. Customers and partners use it to bring their own tools into AANCER: a shift planner, an order board, a quality checklist, an internal form. The app appears as an entry in the **Dashboards** navigation (and, if you like, as a card on Home), so people reach it next to their dashboards, agents and workflows.

AANCER shows the app in a sandboxed `<iframe>` and talks to it through a `postMessage` protocol called the **bridge** (`aancer-bridge/2`). Through the bridge the app can learn who the user is, read and write named datasets, query a BI model, move the user to another page and show a short notice. Each of these is a **capability**: it works only if the manifest declares it, an administrator approves it, and the user's own permissions in that workspace allow it.

AANCER can also sign the user in to your app without sending any platform token to the browser. The frame gets a one-time code that is valid for 60 seconds. Only your server, holding the app secret and a PKCE verifier, can exchange it for a short-lived token, which it checks against an introspection endpoint.

You ship the app as one `app` item in a signed pack. None of your code runs on the AANCER platform.

## Quick start

1. Host your app at its own origin, for example `https://planner.example.com`. It must not be the same origin as AANCER.
2. Send this header on the embedded page, with your AANCER address:

   ```text
   Content-Security-Policy: frame-ancestors https://aancer.example.com
   ```

3. Write the pack manifest:

   ```json
   {
     "v": 2,
     "kind": "bundle",
     "id": "acme.shift-board",
     "version": "1.0.0",
     "title": "Shift board",
     "publisher": { "name": "Acme Example Ltd", "keyId": "pub-0123456789ab" },
     "requires": { "platform": ">=1.0.0" },
     "parameters": [ { "id": "target_workspace", "type": "workspace", "label": "Workspace", "required": true } ],
     "items": [
       {
         "kind": "app",
         "schemaVersion": 2,
         "id": "shift-board",
         "scope": "workspace",
         "workspace": "{{param.target_workspace}}",
         "spec": {
           "id": "shift-board",
           "title": "Shift board",
           "icon": "Table",
           "group": "Operations",
           "order": 31,
           "url": "https://planner.example.com/board.html",
           "origin": "https://planner.example.com",
           "sso": { "mode": "none" },
           "capabilities": ["read:dataset:shift_plan"],
           "egress": { "hosts": [] },
           "embed": { "sandbox": ["allow-scripts", "allow-same-origin"] }
         }
       }
     ]
   }
   ```

4. In the page, say hello to the shell and read the dataset:

   ```js
   const PLATFORM = 'https://aancer.example.com';
   const bridge = await AancerBridge.connect({ platformOrigin: PLATFORM });
   const result = await bridge.call('read:dataset', { datasetId: 'shift_plan', limit: 100 });
   render(result.rows);
   ```

   `AancerBridge` is the small helper `bridge.js` from the examples repository (MIT licence). You can also write the messages yourself; see Bridge protocol below.

5. Sign the pack, import and activate it, then approve the app under **Manage app**. The app appears in the Dashboards navigation of that workspace.

## File layout

The pack carries only the manifest. Your app is a normal web application on your own server.

```text
acme-shift-planner/                # the pack
  manifest.json                    # one item of kind "app" (spec inline, or $ref to content/app.json)

shift-planner-app/                 # your app, deployed at https://planner.example.com
  server.mjs                       # serves the pages, redeems the sign-in code, checks tokens
  public/
    index.html                     # the embedded page
    app.js                         # your app logic
    bridge.js                      # bridge helper (frame side)
```

## Field reference

JSON Schema: [app.schema.json](https://aancer.ai/dev/schemas/app.schema.json). `$defs/link` and `$defs/card` cover navigation links and Home cards.

### App item

| Field | Type | Required | Rules |
|---|---|---|---|
| `kind` | string | yes | `"app"` |
| `schemaVersion` | integer | yes | `2` |
| `id` | string | yes | `^[a-z0-9][a-z0-9._-]{0,63}$`. Keep it equal to `spec.id` |
| `scope` | string | no | `workspace` (the app shows in one workspace) or `install` (every workspace). Default `install` |
| `workspace` | string | if scope is `workspace` | a workspace id or `{{param.<id>}}` |
| `spec` | object | yes | the app spec, inline or `{"$ref": "content/app.json"}` |

### App spec

| Field | Type | Required | Rules |
|---|---|---|---|
| `id` | string | yes | `^[a-z0-9][a-z0-9._-]{0,63}$`. Approvals, the app secret and network rules are keyed by it. One active pack per app id |
| `title` | string | yes | 1 to 80 characters. The navigation label and frame title |
| `icon` | string | no | at most 40 characters, an icon name such as `Clock`, `Table` or `Calendar` |
| `group` | string | no | at most 40 characters. The heading the app is listed under in the navigation |
| `order` | integer | no | 0 or more, default 100. Sorting is by group, order, then title |
| `url` | string | yes | https only, 9 to 2048 characters. No user or password, no `#fragment`. The only placeholder is `{{workspace}}` |
| `origin` | string | yes | exactly the origin of `url`: scheme, host and port, no trailing slash |
| `sso` | object | yes | `{ "mode": "code" or "none", "scopes"?: ["profile", "workspace"] }` |
| `capabilities` | string[] | yes | up to 20, unique. See Capabilities. `[]` is valid |
| `egress` | object | no | `{ "hosts": [...] }`: up to 20 extra hosts, `api.example.com` or `*.example.com`. Never `*` |
| `embed` | object | no | `{ "sandbox": [...], "height"?: "full" or "auto" }`: `sandbox` takes up to 5 of `allow-scripts`, `allow-forms`, `allow-same-origin`, `allow-popups`, `allow-downloads` |
| `csp` | object | no | `{ "connectSrc": [...] }`: up to 10 https origins the frame may connect to |
| `workspace` | string | no | a workspace id or `{{param.<id>}}` |

No other fields are allowed.

`url` rules in detail:

- `{{workspace}}` is replaced by the URL-encoded workspace id, but only if the `workspace` identity scope is approved. Otherwise it becomes an empty string.
- The host must not be a loopback, link-local or cloud metadata address. An IP address as host needs the operator to allow private origins; use a DNS name.
- The app origin must differ from the AANCER origin. Use a separate host name such as `planner.example.com`.

### Sign-in modes and scopes

| `sso.mode` | What happens | Default scopes |
|---|---|---|
| `code` | the frame receives a one-time code; your server redeems it and gets the user's identity | `profile`, `workspace` |
| `none` | no sign-in; the app uses the bridge only | none |

| Scope | Gives your app |
|---|---|
| `profile` | user id (`sub`), e-mail, display name |
| `workspace` | workspace id and the user's role label |

The role is a label for display. Do not use it to decide what a user may do. The bridge already applies the user's real permissions.

### Capabilities

| Capability | Lets the app | User permission needed in the workspace |
|---|---|---|
| `read:me` | read the user's identity (within the approved scopes) | none |
| `read:dataset:<id>` | read rows of dataset `<id>` | `datasets.view_own` |
| `write:dataset:<id>` | append or upsert rows in dataset `<id>` | `datasets.write_own` |
| `query:model:<id>` | run a query on BI model `<id>` | `dashboards.view_own` |
| `navigate` | move the user to another AANCER page | none |
| `notify` | show a short notice in AANCER | none |

Dataset ids in capabilities match `[a-z][a-z0-9_]{0,63}` (no dashes). Model ids match `[a-z][a-z0-9_.-]{0,63}`.

A capability works in a session only if it is declared in the manifest, approved by an administrator, and granted when the session starts.

### Sandbox

The frame is `<iframe src="<url>" sandbox="..." referrerpolicy="no-referrer" allow="">`. The default sandbox is `["allow-scripts", "allow-forms", "allow-same-origin"]`. Keep `allow-scripts` and `allow-same-origin`, or the bridge cannot work. Top-level navigation and modal dialogs are never allowed. Add `allow-popups` if your app opens links in a new tab, and `allow-downloads` if it offers file downloads.

## Your server's headers

The embedded page must allow AANCER to frame it:

```text
Content-Security-Policy: frame-ancestors https://aancer.example.com
```

- Accepted sources: the exact AANCER origin, its host, or `*.example.com` / `https://*.example.com` matching the AANCER host. `'none'` refuses.
- Do not send `X-Frame-Options: DENY` or `SAMEORIGIN`.
- The AANCER server checks this header when the app is activated and when it opens, with a HEAD request; it sends a GET only when HEAD answers 404 or 405. Redirects are judged as they are, not followed. The result is cached for 5 minutes per origin.

If the check fails because the header is missing or does not allow AANCER, an approved app opens in a new browser tab at its own URL instead of the frame. The bridge does not exist there. If the app cannot be reached, the user sees a retry card.

We also recommend `default-src 'self'`, `Cache-Control: no-store`, `X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer`.

Next part: https://aancer.ai/dev/parts/pages/14-bridge-protocol.md
