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

## Install and approve

### In the UI

1. **Platform Settings > Extensions > Trust keys > Add trust key**, once per publisher.
2. **Import pack**, then **Activate**, and pick the workspace.
3. Open the pack and choose **Manage app**, then **Approve**. The administrator sees and approves the origin, every capability and the identity scopes.
4. **Create app secret**. It is shown once. Give it to the person who runs your app server, for example as the `APP_SECRET` environment variable.
5. Users open the app from the Dashboards navigation.

The activation also runs the frame check. A warning `APP_EMBED_REFUSED` names the reason: `no_csp` (no `frame-ancestors`), `not_allowed` (AANCER is not among the sources), `xfo` (an `X-Frame-Options` header blocks framing), `unreachable` (the app did not answer) or `egress` (the installation's network rules do not allow the origin).

### With the REST API

Every app manage call (approve, secret, withdraw, frame check, extra hosts) carries the app's `workspaceId`.

| Step | Call | Permission |
|---|---|---|
| Add trust key | `POST /api/extensions/trust-keys {keyId, label, publicKeyPem}` | `extensions.manage` |
| Import | `POST /api/extensions/packs/import` (raw bytes) | `extensions.manage` |
| Activate | `POST /api/extensions/packs/{packId}/activate {version, parameters: {target_workspace: "ws-ops"}}` | `extensions.manage` or `extensions.manage_own` |
| List apps | `GET /api/apps?workspaceId=ws-ops` | `apps.view_own` |
| Approve | `POST /api/apps/{id}/approve {workspaceId?, origins: [origin], capabilities: [...], scopes: [...]}` | `apps.manage_own` in the workspace, or `extensions.manage` for install-scoped apps |
| Create or rotate the secret | `POST /api/apps/{id}/introspect-secret/rotate` returns `201 {secret, previousValidUntil}` | same as approve |
| End the previous secret now | `POST /api/apps/{id}/introspect-secret/previous/end` | same |
| Withdraw approval | `POST /api/apps/{id}/approval/withdraw` | same |
| Run the frame check again | `POST /api/apps/{id}/embed-check/run` | same |
| Allow or remove an extra host | `POST /api/apps/{id}/egress/approve {host}`, `DELETE /api/apps/{id}/egress/{host}` | same |

After a rotation the previous secret stays valid for one hour by default, so you can update your server without downtime.

### Updates

Bump the pack `version`. A new origin, a new capability or a new identity scope must be approved again. Fewer or equal requests need no new approval. Open sessions of the old version end with `app_updated`. Retiring the pack removes approvals, the secret and network rules; a later pack with the same app id starts unapproved.

### Testing

Import and activate the pack in an EVAL or test installation. Open the app, then check: the frame loads (header correct), `hello-ack` arrives (origin correct), each `call` returns `ok: true` (capability approved and user permission present). For sign-in apps, check that your server gets `active: true` from introspection.

## Common errors

Import and manifest errors (path `/items/<itemId>/spec/...`):

| Message | Fix |
|---|---|
| https only (`APP_URL_INVALID`) | Use https |
| origin must equal the URL origin (`APP_URL_INVALID`) | Set `origin` to scheme, host and port of `url`, no trailing slash |
| the app origin must differ from this platform's own address (`APP_URL_INVALID`) | Host the app on its own host name |
| the host is hard-blocked (loopback, link-local or metadata) (`APP_URL_INVALID`) | Use a real DNS name |
| placeholder {{x}} is not allowed (only {{workspace}}) (`APP_URL_INVALID`) | Only `{{workspace}}` |
| credentials in the URL are not allowed / fragments are not allowed | Remove `user:pass@` and `#...` |
| unknown capability '...' (`APP_CAPABILITY_UNKNOWN`) | Use the capability list. Dataset ids have no dashes |
| a bare wildcard is not allowed (`APP_EGRESS_WILDCARD`) | `api.example.com` or `*.example.com` |
| sandbox token '...' is not allowed | Only the five tokens listed |
| must have required property 'sso' | Add `sso` |
| warning `APP_WORKSPACE_PLACEHOLDER_EMPTY` | Add `"workspace"` to `sso.scopes`, or drop `{{workspace}}` from the URL |
| `APP_ID_TAKEN`: The app id '...' is already used by the active pack '...' | Retire that pack, or use another app id |

Runtime errors:

| Code | Message | Fix |
|---|---|---|
| `FEATURE_NOT_LICENSED` | Embedded apps are not included in the licence of this installation. | The installation needs the Embedded apps licence feature |
| `APP_NOT_FOUND` | App '...' is not active in this workspace. | Activate the pack for this workspace |
| `APP_ORIGIN_UNAPPROVED`, `APP_CAPABILITIES_CHANGED` | App '...' has changes an administrator must approve first. | Approve under Manage app |
| `APP_SECRET_MISSING` | App '...' has no app secret yet. | Create the app secret |
| `APP_EMBED_REFUSED` | The app has not allowed this platform to embed it (frame-ancestors). Reason `no_csp`, `not_allowed`, `xfo`, `unreachable` or `egress` | Fix the header, remove `X-Frame-Options`, or allow the origin in the network rules |
| `APP_INTROSPECT_UNAUTHORIZED` (401) | Introspection is not authorised. | Send HTTP Basic with the app id and the current app secret |
| `SSO_NOT_ENABLED` (409) | This app does not use sign-in by one-time code. | Set `sso.mode: "code"` |
| `APP_SESSION_INVALID` | The app session is not valid. | Reopen the app |
| `APP_PKCE_REQUIRED` | A PKCE challenge is required: a codeChallenge of 43 base64url characters. | Send an S256 challenge |
| `APP_AUTHORIZE_RATE_LIMITED` | Too many sign-in codes were requested for this app session. | Renew only when introspection says inactive |
| `CAPABILITY_NOT_DECLARED` | The app did not declare '...'. | Declare it and ship a new version |
| `CAPABILITY_FORBIDDEN` | '...' is not approved for this app session. / Your seat lacks ... in this workspace. | Approve it, or give the user the permission |
| `APP_WRITE_MODE_INVALID` | Apps may only append or upsert. | Use `append` or `upsert` |
| `APP_WRITE_ROWS_INVALID` | rows must be a non-empty array. | |
| `NAVIGATE_REFUSED` | | Use an AANCER path such as `/dashboards/...` |
| `BRIDGE_UNAVAILABLE` | | AANCER could not be reached; retry |
| token `invalid_client` (401) | Client authentication failed: send HTTP Basic with the app id and the app secret. | Check `APP_ID` and `APP_SECRET` |
| token `invalid_grant` (400) | The code is not valid (unknown, expired, already used, or not issued for this app and verifier). | Get a new code through `authorize` |
| token `invalid_request` (400) | code and code_verifier are required; the verifier is 43 to 128 unreserved characters. | |
| token `unsupported_grant_type` (400) | Only grant_type=authorization_code is supported. | |
| token `429` | Too many failed attempts from this address. | Wait a minute, then retry with the correct app secret |
| token `503` | The sign-in service is briefly unavailable. | Retry |

## Limits and editions

- Up to 20 capabilities and 20 extra hosts per app. The sign-in code lives 60 seconds; tokens live 5 minutes by default.
- Embedded apps need the Embedded apps licence feature. Without it, apps do not show and their calls are refused.
- Users need `apps.view_own`. Approving needs `apps.manage_own`, or `extensions.manage` for install-scoped apps.
- Check your edition on [aancer.ai/pricing](https://aancer.ai/pricing).


---

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

---
title: REST API and MCP server | AANCER Developers
description: The AANCER REST API for packs, agents, dashboards, hooks and apps, and the MCP server that lets Claude, ChatGPT and others use your agents.
---

## REST API and MCP

AANCER has two programmable surfaces. The **REST API** under `/api` manages everything on these pages: packs, agents, templates, skills, dashboards, hooks and embedded apps. The **MCP server** at `/mcp/v1` lets external AI clients, such as Claude, ChatGPT or your own agent, find and ask AANCER agents and use tools an administrator has approved. AANCER can also act as an MCP client: administrators register external MCP servers and approve their tools one by one, so agents and workflows can use them.

Packs are always created on your machine, signed with the `aancer-pack` CLI, and installed through the REST API or the admin screens. No MCP tool creates, validates or installs a pack.

## Quick start

Import and activate a pack:

```bash
export AANCER=https://aancer.example.com
curl -X POST "$AANCER/api/extensions/packs/import" \
  -H "Authorization: Bearer $TOKEN" \
  --data-binary @acme.business-skills-1.0.0.ancpack

curl -X POST "$AANCER/api/extensions/packs/acme.business-skills/activate" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"version":"1.0.0"}'
```

Ask an AANCER agent over MCP:

```bash
curl -X POST "$AANCER/mcp/v1" \
  -H "Authorization: Bearer $MCP_TOKEN" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"my-client","version":"1.0"}}}'
```

## REST API basics

- Base address: `https://<your installation>/api`.
- Authentication: the browser session, or a bearer token issued by the identity provider your installation uses for sign-in.
- Bodies are JSON unless stated. Pack import takes the raw `.ancpack` bytes.
- Errors have the shape `{ "error": "<message>", "code": "<CODE>", "details"?: [...] }`. Validation details are `{ itemId?, path, message }` with paths like `/items/<itemId>/spec/<field>`.
- Every call checks the caller's permissions in the workspace. A missing permission returns 403 `{ "error": "Permission denied", "permission": "<name>" }`, without a `code`.
- Coming in this release: a machine-readable OpenAPI 3.1 description of the API at `GET https://<your installation>/api/openapi.json`. It needs a signed-in user (401 otherwise). Each operation names the permission it needs in `x-aancer-permission`. Request bodies are described generically (object or binary), not field by field.

## Endpoint reference

### Packs and extensions

| Method and path | Permission | Body and answer |
|---|---|---|
| `POST /api/extensions/packs/import` | `extensions.manage` | raw `.ancpack` bytes. Add `?activate=1` to activate in the same call. `201` new or `200` known, with `{ packId, version, title, state, signer, items[], parameters[], upgradeFrom, warnings[], certification?, revocation?, keptBehind? }` |
| `POST /api/extensions/packs/validate` (coming in this release) | `extensions.manage` | the same upload as an import. Runs exactly the import's checks and stores nothing. Valid: `200 { "valid": true, "summary": ... }` with the summary an import shows. Refused: the same status and error body an import would give. Import size limit applies (`413 PACK_TOO_LARGE`); 10 calls per user per minute (`429` with `Retry-After`) |
| `POST /api/extensions/packs/{packId}/activate` | `extensions.manage` or `extensions.manage_own` | `{ version, parameters?: { <id>: "<value>" or null } }`. `null` unbinds an optional parameter. Answer `{ packId, activeVersion, previousVersion, objects, warnings? }` |
| `POST /api/extensions/packs/{packId}/rollback` | `extensions.manage` | `{ version }` |
| `POST /api/extensions/packs/{packId}/retire` | `extensions.manage` | |
| `GET /api/extensions/packs` | `extensions.view` | filter with `state`, `kind`, `workspaceId` |
| `GET /api/extensions/packs/{packId}` | `extensions.view` | detail with every version |
| `GET /api/extensions/objects` | `extensions.view` | installed objects; filter with `kind`, `workspaceId`, `state`, `packId` |
| `GET /api/extensions/schemas` | `extensions.view` | supported kinds and schema versions |
| `GET /api/extensions/export-key` | signed in | `{ available }`: whether this installation can sign exports |
| `POST /api/extensions/packs/{packId}/revocation-override` | `extensions.manage` | `{ version, reason }`: keep a withdrawn version running |
| `DELETE /api/extensions/packs/{packId}/revocation-override` | `extensions.manage` | `{ version }`: end that decision |
| `GET /api/extensions/trust-keys` | `extensions.view` | list of trusted keys |
| `POST /api/extensions/trust-keys` | `extensions.manage` | `{ keyId, label?, publicKeyPem }`, answers `201` |
| `DELETE /api/extensions/trust-keys/{keyId}` | `extensions.manage` | answers `204` |
| `POST /api/extensions/packs/scan-dir` | `extensions.manage` | import packs from the server folder |

To test a pack, import it into a developer, EVAL or test installation: import is installation-wide, checks everything and changes nothing until you activate. A pack that contains workflow templates also passes the template permission check on activate and rollback.

### Other areas

| Area | Base path | Details |
|---|---|---|
| Agents | `/api/agents` | [Agents](/developers/agents) |
| Workflow templates | `/api/automations/templates/authored` | [Templates](/developers/templates) |
| Workflows | `/api/automations` | [Templates](/developers/templates) |
| Skills | `/api/skills` | [Skills](/developers/skills) |
| Datasets, models, widgets, dashboards | `/api/models`, `/api/widgets`, `/api/dashboards`, `/api/charts/pin` | [Dashboards](/developers/dashboards) |
| Event hooks | `/api/event-hooks`, `/api/events/catalog` | [Hooks](/developers/hooks) |
| Embedded apps | `/api/apps` | [Embedded apps](/developers/apps) |
| Connectors | `/api/admin/connectors` | [Connectors](/developers/connectors) |
| Themes and branding | `/api/extensions/themes`, `/api/branding` | [Themes](/developers/themes) |

Next part: https://aancer.ai/dev/parts/pages/16-mcp-server.md
