## Full examples ### A sales dashboard pack `manifest.json`: ```json { "v": 2, "kind": "bundle", "id": "acme.sales-dashboard", "version": "1.0.0", "title": "Sales overview", "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": "dataset", "schemaVersion": 1, "id": "sales_orders", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/dataset.sales_orders.json" } }, { "kind": "dataset", "schemaVersion": 1, "id": "regions", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/dataset.regions.json" } }, { "kind": "model", "schemaVersion": 1, "id": "sales", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/model.sales.json" } }, { "kind": "widget", "schemaVersion": 1, "id": "revenue_by_region", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/widget.revenue_by_region.json" } }, { "kind": "widget", "schemaVersion": 1, "id": "revenue_this_month", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/widget.revenue_this_month.json" } }, { "kind": "dashboard", "schemaVersion": 1, "id": "sales-overview", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/dashboard.sales-overview.json" } } ] } ``` `content/dataset.sales_orders.json`: ```json { "id": "sales_orders", "title": "Sales orders", "columns": [ { "id": "order_id", "type": "string", "required": true }, { "id": "date", "type": "date", "required": true }, { "id": "region", "type": "string", "required": true, "maxLength": 32 }, { "id": "product", "type": "string" }, { "id": "amount", "type": "number", "min": 0 }, { "id": "units", "type": "integer", "min": 0 } ], "key": ["order_id"], "retention": { "maxAgeDays": 730, "maxRows": 500000 } } ``` `content/dataset.regions.json`: ```json { "id": "regions", "title": "Regions", "columns": [ { "id": "region", "type": "string", "required": true }, { "id": "manager_team", "type": "string" } ], "key": ["region"], "retention": { "maxRows": 1000 } } ``` `content/model.sales.json`: ```json { "id": "sales", "title": "Sales", "entities": { "orders": { "dataset": "sales_orders" }, "regions": { "dataset": "regions" } }, "dimensions": { "date": { "entity": "orders", "column": "date", "granularity": ["day", "month", "quarter"] }, "region": { "entity": "orders", "column": "region", "label": "Region" }, "team": { "entity": "regions", "column": "manager_team", "label": "Team" } }, "measures": { "revenue": { "entity": "orders", "agg": "sum", "column": "amount", "label": "Revenue", "format": "currency" }, "units": { "entity": "orders", "agg": "sum", "column": "units", "label": "Units", "format": "integer" }, "orders": { "entity": "orders", "agg": "count", "label": "Orders" } }, "filters": { "this_month": { "dimension": "date", "op": "in_period", "value": "current_month", "label": "This month" } }, "joins": [ { "id": "by_region", "left": { "entity": "orders", "column": "region" }, "right": { "entity": "regions", "column": "region" }, "type": "left" } ] } ``` `content/widget.revenue_by_region.json`: ```json { "id": "revenue_by_region", "type": "chart", "title": "Revenue by region", "source": { "model": "sales", "query": { "measures": ["revenue"], "dimensions": ["region"], "filters": ["this_month"], "limit": 50 } }, "interactions": { "emit": { "dimension": "region" }, "listen": true }, "chart": { "mark": "bar", "encoding": { "x": { "field": "region", "type": "nominal" }, "y": { "field": "revenue", "type": "quantitative" } } } } ``` `content/widget.revenue_this_month.json`: ```json { "id": "revenue_this_month", "type": "kpi", "title": "Revenue this month", "source": { "model": "sales", "query": { "measures": ["revenue"], "filters": ["this_month"] } }, "kpi": { "measure": "revenue", "format": "currency", "label": "Revenue" }, "interactions": { "listen": true } } ``` `content/dashboard.sales-overview.json`: ```json { "id": "sales-overview", "title": "Sales overview", "icon": "BarChart3", "group": "Sales", "order": 10, "filters": [ { "id": "period", "model": "sales", "filter": "this_month", "control": "period", "label": "Period" } ], "layout": [ { "widget": "revenue_this_month", "x": 0, "y": 0, "w": 4, "h": 4 }, { "widget": "revenue_by_region", "x": 4, "y": 0, "w": 8, "h": 8 } ] } ``` ### A form widget that starts a workflow (REST) ```http POST /api/widgets?workspaceId=ws-sales Content-Type: application/json { "definition": { "id": "discount_request", "type": "form", "title": "Request a discount", "form": { "card": { "type": "AdaptiveCard", "version": "1.5", "body": [ { "type": "Input.Text", "id": "customer", "label": "Customer", "isRequired": true }, { "type": "Input.Number", "id": "percent", "label": "Discount in percent", "min": 1, "max": 30 } ], "actions": [ { "type": "Action.Submit", "title": "Send" } ] }, "target": { "kind": "workflow", "flowId": "flow_discount_request" }, "onSuccess": { "message": "Submitted, request {{runId}}" } } } } ``` ### Pin a chart from chat `POST /api/charts/pin` turns a chat chart into a dataset, a model and a widget on a dashboard: ```json { "workspaceId": "ws-sales", "newDashboardTitle": "My sales", "title": "Units by region", "spec": { "mark": "bar", "encoding": { "x": { "field": "Region", "type": "nominal" }, "y": { "field": "Units Sold", "type": "quantitative", "aggregate": "sum" } } }, "rows": [ { "Region": "North", "Units Sold": 120 }, { "Region": "South", "Units Sold": 95 } ] } ``` ## Install and test ### As a pack Sign and import the pack (see [Packs](/developers/packs)), then activate it with `{"version":"1.0.0","parameters":{"target_workspace":"ws-sales"}}`. On activation the dashboard is created and published. When the pack is retired, objects are removed only if nobody changed them, and a dataset that holds rows is never removed automatically. ### With the REST API | Call | Permission | Notes | |---|---|---| | `POST /api/models`, `PUT /api/models/{id}` | `dashboards.edit_own` | `{definition}` | | `POST /api/models/{id}/query` | `dashboards.view_own` | run a model query, useful for testing | | `POST /api/widgets`, `PUT /api/widgets/{id}` | `dashboards.edit_own` | `{definition}`. Saving compiles the query, so an unknown measure fails here | | `POST /api/dashboards` | `dashboards.edit_own` | `{workspaceId, definition}`, returns a draft | | `PUT /api/dashboards/{id}/draft` | `dashboards.edit_own` | `{definition, ifVersion}` with the current `draftVersion` | | `POST /api/dashboards/{id}/publish`, `/rollback {version}`, `/retire` | `dashboards.publish_own` | | | `POST /api/dashboards/{id}/export` | `dashboards.publish_own` | returns a signed pack | | `POST /api/dashboards/assist` | `dashboards.edit_own` | `{modelId, intent}`, returns a proposal; nothing is saved | | `POST /api/dashboards/{id}/share` | `result.share` | read-only share link, 1 to 720 hours | | `POST /api/widgets/{widgetId}/actions/{actionId}` | `dashboards.view_own` and run rights | runs a widget action | | `POST /api/charts/pin` | `dashboards.edit_own` | see above | The workspace comes from `?workspaceId=` or the body's `workspaceId`. In the UI: **Work > Dashboards**, then Add widget, **Help me build**, Save draft, Publish, Share. In chat, use **Pin to dashboard**. ## Common errors | Code | Message | Fix | |---|---|---| | `VALIDATION` | definition is required | Wrap the object in `{"definition": ...}` | | `WIDGET_SPEC_INVALID` | /source: a chart widget needs a source (model + query) | Add `source` | | `WIDGET_SPEC_INVALID` | /source/query/measures: at least one measure | Name a measure of the model | | `WIDGET_SPEC_INVALID` | /chart/data: a chart fragment must not carry data; the platform injects the query result | Remove `data` | | `WIDGET_SPEC_INVALID` | /chart: no URLs, $schema or external resources allowed in a chart fragment | Remove `$schema`, `url` and links | | `WIDGET_SPEC_INVALID` | /chart/mark: a chart fragment needs a mark (or layer) / image marks are not allowed | Use an allowed mark | | `WIDGET_SPEC_INVALID` | /actions: a KPI widget only has toolbar actions | `"placement": "toolbar"` | | `WIDGET_SPEC_INVALID` | Action.OpenUrl is not allowed: form cards carry no external links | Stay in the card subset | | `WIDGET_SOURCE_FORBIDDEN` | Model '...' is not available in this workspace. | Create or import the model first | | `MODEL_ENTITY_UNKNOWN` | exactly one of dataset or connection / connection entities need a saved query / joins need dataset entities | Fix the entity | | `DATASET_NOT_FOUND` | Dataset '...' not found. | The model names a missing dataset | | `DASHBOARD_INVALID` | /layout/0: exceeds the 12-column grid / overlaps widget ... / widget placed twice | Fix `x`, `w` and overlaps | | `DASHBOARD_INVALID` | /icon: icon must be one of the allowed set | Use an icon from the list | | `DASHBOARD_INVALID` | /filters: filter '...' is not defined on model '...' | Add the filter to the model | | `DASHBOARD_VERSION_CONFLICT` | The dashboard draft changed since you loaded it. Reload and retry. | Send the new `draftVersion` | | `SHARE_CONTAINS_FORM` | Dashboard contains a form widget; forms cannot be shared anonymously. | Remove the form or share internally | | `EXPORT_CONTAINS_PERSONAL_DATA` | Widget '...' is bound to a dataset snapshot that carries personal data; it cannot be exported. | | | `FORM_TARGET_INVALID` | The target workflow is paused or not published. | Publish the workflow | ## Limits and editions - Datasets: up to 200 columns. Models: 3 entities, 100 dimensions, 100 measures, 3 joins. Queries: 5000 rows, 4 dimensions, 8 measures. - Dashboards: up to 40 widgets and 12 filters. Widgets: up to 5 actions. Forms: up to 40 inputs. - Widget actions are limited to 30 runs per minute per user and workspace. - Public share links need the public sharing licence feature. - Dashboards are controlled by permissions: `dashboards.view_own`, `dashboards.edit_own`, `dashboards.publish_own`. - Check your edition on [aancer.ai/pricing](https://aancer.ai/pricing). ## Event hooks A hook is a small JSON object, data and never code, that says: "when platform event X happens in this workspace, and these filter clauses all match, start workflow W or agent A". Events come from a fixed catalog of ten, such as `run.failed`, `approval.decided` and `dataset.rows.published`. Delivery is reliable: each event is recorded, the hook is evaluated, and the handler is started once per hook and event, with retries, dead letters, manual retry and replay. Hooks belong to a workspace, at most 100 per workspace. You create them under **Automations > Hooks**, with the REST API, or ship them in a signed pack as `kind: "hook"`. Hooks do not call URLs. To notify an external system, let the handler workflow do it with a connector step. ## Quick start Start a workflow when an approval is rejected. ```json { "id": "rejected_approvals", "title": "Rejected approvals", "event": { "name": "approval.decided", "version": 1 }, "filter": [ { "path": "payload.outcome", "op": "eq", "value": "rejected" } ], "handler": { "type": "workflow", "ref": "flow_notify_requester" } } ``` The workflow `flow_notify_requester` must be published with the **AANCER Event** trigger set to the event `approval.decided`. In its steps, use `{{trigger.payload.approvalId}}`, `{{trigger.payload.note}}` and so on. ## File layout ```text acme-approval-alerts/ manifest.json # one hook item, workspace scope content/ hook.json # the hook spec ``` Manifest item: ```json { "kind": "hook", "schemaVersion": 1, "id": "rejected_approvals", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/hook.json" } } ``` A pack hook must have a workspace. The workflow or agent it names must already exist in that workspace. Next part: https://aancer.ai/dev/parts/reference/10-field-reference.md