Overview

Artifacts v2 is the one store every Allternit surface reads and writes: Desktop, ai.allternit.com, the phone layout, the m.allternit.com PWA, cloud computers and gizzi. An artifact is something the assistant (or a person) made that you would show someone. Each one has a kind, an immutable list of versions, and sharing settings. The design contract is docs/design/artifacts-v2.md in allternit-platform.
This is a different API from the sectioned Artifacts API under /api/v1/artifacts, which lives on your data-plane node. Artifacts v2 is served by the hosted Cloud API under the separate /api/v2 prefix.

Base URL

Authentication

Every route except the public link route takes one of:
  • a Clerk session JWT (Authorization: Bearer <jwt>). This is the only caller that carries an organization, a role and an email;
  • an Allternit API key (alt_…, created under ACI › Operator keys; legacy allternit_* tokens still work) with the compute scope (or *). A token without it gets 403;
  • a paired device’s token (allternit_runtime_…, what gizzi login stores). It acts as the device’s owner, with no organization.
See Authentication.

Kinds

When a create leaves out body_format, the kind’s default is used. The server also accepts well-formed kinds it doesn’t know (lower-case, at most 32 characters) so newer clients keep working. Apps show an unknown kind as a page when the body is HTML and as code otherwise. runtime_version is 2 for current artifacts. 1 marks legacy artifacts imported from the old local stores. A create with runtime_version: 1 must set origin.legacy_source.

Plan kind

A plan artifact is a chat’s plan. Gizzi writes it when the agent finishes planning.
  • One per chat. The id is art_plan_<session id> and the body is the plan as Markdown. A create with an id that exists returns the first plan, so a second plan request for the same chat doesn’t add a row. A revised plan is a new version of the same artifact.
  • Left out of lists. GET /api/v2/artifacts without kind=plan never returns a plan. That includes title search and the lists of org members. Old clients that don’t know the kind never show plans. Ask for them with GET /api/v2/artifacts?kind=plan, newest updated_at first.
  • Status. Summaries and artifacts of kind plan carry plan: {status}, open (also when never set), approved or done. Set it with PATCH /api/v2/artifacts/{id} and { "plan_status": "approved" }. It needs owner and doesn’t add a version. Other kinds answer 422 not_a_plan, and a value other than the three answers 422 invalid_plan_status. Gizzi sets approved when you approve the plan and done when every todo of the approved plan is completed.
  • Not an app. Installing a plan as an app answers 422 kind_not_installable.
  • Deep link. Allternit Desktop opens allternit://artifact/<id> in its main window at /?artifact=<id>, the same address the web app reads. The id must be art_ followed by up to 64 letters, digits, _ or -. Query strings, extra path parts and escapes are dropped, and anything else is ignored.
The database stores the status in the nullable plan_status column (migration 166), with an index on the owner’s plans for the Plans list.

guard-report kind

Allternit Guard, the local security workbench, creates guard-report artifacts when an operator shares a report. See Guard. A guard-report is always private when created, and it needs an API token with the compute scope.
  • body_format is text/html. The HTML is a finished report with no script: Guard removes scripts, event handlers and active content before it sends the body.
  • template_id has the form guard.<family>.<template>, for example guard.recon.domain-dossier. It is at most 128 characters.
  • meta.guard holds template_id, family, artifact_kind, guard_artifact_id, a header (case_title, scope_summary, run_id, sha256, template_version), counts, the list of optional redacted classes (private_ip, local_path, email, sensitive) and source: "Allternit Guard". meta is at most 16 KB.
  • Secrets are always removed before sending. The other redactions are the operator’s choice.
  • A later share of the same Guard artifact adds a version to the same artifact.
Allternit shows a guard-report in a viewer and offers Open in Docs, Open in Sheets, Open in Slides, Open in PDF and Open in Sign. Which of these work depends on the template. An older client that does not know the kind shows it as a page.

Access

Your access to an artifact is the highest of: If you have no access, every route answers 404, so it doesn’t reveal that the artifact exists. If you can see it but lack the level an action needs, you get 403. Viewers and commenters see shared_version, or the latest version when it is null (“always share latest”). Editors and the owner see every version. An outside email invite counts as accepted the first time its invitee opens the artifact while signed in with that email. From then on it no longer expires.

Objects

ArtifactSummary

Artifact

An ArtifactSummary plus:

List artifacts

Returns { "items": [ArtifactSummary], "next_cursor": string | null }, newest updated_at first.

Counts

GET /api/v1/artifacts/counts?scope=all|mine|shared (default all) answers how many artifacts of each kind the caller sees:
The counts use the same visibility rules as List artifacts: owned rows (unless scope=shared), and rows shared with the caller or their organization (unless scope=mine). Rows the caller archived from their library are not counted. Plans appear in byKind but not in total, because the default list leaves plans out. Any other scope is a 400.

Create an artifact

Returns 201 with the Artifact (version 1). Optional fields: id, icon, template_id, origin, capabilities, body_format, meta, runtime_version.
  • Idempotent create. If you send an id you already own, you get that artifact back unchanged with 200. If someone else owns the id, you get 409 id_conflict. Client ids are art_ followed by letters, digits, _ or -, at most 128 characters. Legacy imports use art_legacy_<source>_<localId>.
  • Body limit. A body can be at most 16 MiB. A larger one gets 413 body_too_large.
  • Organization. The artifact belongs to the creator’s active Clerk organization, and its sharing follows that organization. If the org has turned artifacts off, the create gets 403 artifacts_disabled. If the org has turned connectors off, capabilities.connectors gets 422 connectors_disabled.

Get, update and delete

PATCH returns the Artifact. title and icon need edit. shared_version (from 1 to current_version, or null), capabilities and plan_status need owner. Turning on ai or connectors for an artifact shared by link gets 422 link_not_allowed. DELETE is owner-only and permanent. There is no trash. Versions, shares and comments are deleted with the artifact. It returns 204.

Dashboard body

A dashboard artifact’s body is JSON with body_format application/vnd.allternit.dashboard+json. The server stores it like any other body; the apps parse and validate it. A tile that fails validation is skipped and the rest of the dashboard still draws.
A tool result is read as a table: an array of objects, { "columns": [], "rows": [[]] }, or JSON or CSV text. Dashboards run as the viewer: each call goes through the viewer’s own connectors, and a tool that is not read-only is refused (a SQL tool is allowed for a single read-only statement). The owner’s client sets capabilities.connectors to the connectors and tools the tiles call, so visibility: "link" is refused for a dashboard (see Sharing). Dashboards saved before this format, with application/vnd.allternit.openui, remain readable as text. New cards use the answer template contract. Tiles may also use the built-in read tools allternit__computers_list, allternit__computer_get and allternit__computer_history. They read the viewer’s own computers and need no connector.

Ops sheet body

An ops artifact’s body is JSON with body_format application/vnd.allternit.ops+json. It watches one running thing. The apps parse it the same forgiving way as a dashboard: a part that fails validation is skipped, and the rest still draws.
Reads run like dashboard tiles: as the viewer, through the viewer’s connectors, and read-only tools only. Action tools run only from their button, and the viewer approves every call. On save the server sets capabilities.connectors to every tool the body reads or acts with, so visibility: "link" is refused.

Versions

Appending needs edit and returns 201 with the Artifact. body_format defaults to the previous version’s. If base_version is not the current version, the server answers:
Fetch version 4, merge your change onto it, and append again with base_version: 4. Viewers only see the shared version, so asking them for any other version gets 404.

Sharing

Both routes are owner-only. PUT replaces the whole share list. Rows you leave out are removed, and rows you keep only change level. Both return a Sharing object:
link_url appears only when visibility is link. policy.reason explains why links are not allowed. The server sets the link base from ARTIFACTS_PUBLIC_BASE_URL (default https://ai.allternit.com/a).

Sharing rules

All of these failures return 422 with the code shown. The owner always has access, so a share naming the owner is dropped. If the same principal is listed twice, the higher level is kept.
This route returns {id, kind, title, icon, body, body_format, meta, version, updated_at, runtime_version, owner_name}. It works only while visibility is link and the policy still allows links. If an org turns off external sharing or artifacts, its links stop working at once. Viewers get shared_version, or the latest version when it is null. Every other case answers 404. Responses carry Cache-Control: private, no-store and X-Robots-Tag: noindex.

Organization settings

GET returns the settings for your active organization, plus org_id, updated_by, updated_at and can_edit. Personal accounts get the defaults with org_id: null. PUT changes only the fields you send. It needs the Clerk organization role admin (or org:admin). Everyone else gets 403. Admins can list what the org has shared outside with GET /api/v2/org/artifact-shared-outside. It returns {items: [{id, title, kind, owner_id, owner_name, by_link, outside_invites, allowed, updated_at}]} for artifacts that are public by link or have email invites, and needs the same admin role. allowed is whether the artifact is in allowed_external.

Page runtime

Pages that store data, call AI or use connectors have their own routes under /api/v2/artifact-runtime/{id}. See the Page runtime API.

Comments

Comments are threaded: a root comment plus replies one level deep. They are stored in artifact_comments. A comment has id, artifact_id, version, anchor, parent_id, author_id, author_name, author_image_url, agent_name, body, to_assistant, resolved_at and created_at. body is 1 to 4000 characters. anchor is an opaque object up to 16 KB; the app writes { kind: "text" | "cell" | "slide" | "element", ... }. A comment that mentions @gizzi or @allternit is stored with to_assistant: true. Comment anchors. The server stores anchor exactly as sent, every field kept, so the app can add fields without a server change. It checks only that it is an object up to 16 KB whose kind, when present, is text, cell, slide or element. On a Design canvas a comment pinned to a frame or layer uses the element kind:
  • shapeId is the layer’s shape id, or the artboard’s own id when the comment is about the whole frame (shapeId equals artboard).
  • artboard is the artboard’s shape id and label the name shown in the thread. When present, shapeId, artboard and label must be strings of at most 200 characters, otherwise 400.
  • The app draws a numbered pin for each open thread anchored on the canvas, at the layer’s top-right corner (or the frame’s, for a frame anchor). Resolved threads hide their pin. A reply inherits its root’s anchor.
  • A comment posted with agent_name (an agent’s question pinned to a frame) has a smaller limit: its anchor is at most 4 KB. Docs have no Commenter level, so a viewer of a doc can’t comment.
An agent posts under its own name by sending agent_name (gizzi’s artifact_comment does this). The comment is then stored with author_id: "assistant" and that agent_name, and author_name comes back as the agent name. On every read, author_name falls back to agent_name when the author has no profile name. agent_name is null for comments people write.

Presence

Presence is shared by every Cloud API instance. Each heartbeat upserts one row per artifact and user in artifact_presence (migration 086_artifact_presence.sql); the table holds only the current state and is not a viewing history. Send a heartbeat about every 15 seconds. GET returns the entries seen in the last 45 seconds, up to 200, ordered by user_id. left deletes the caller’s entry. Entries older than 10 minutes are deleted as a side effect of about one request in 50. When the owner’s organization turned presence off, GET returns { enabled: false, users: [] } and a person’s POST does nothing. Agent frame claims still work then (see frame claims).

Agent presence

An agent working on the artifact for the caller sends agent: { name, session_id?, task?, anchor?, cost_usd? } with the heartbeat. This needs edit access. The row is then the agent’s own, not the caller’s:
  • user_id is agent:<session_id or none>:<slug of name>, and kind is "agent" (people are "user").
  • The row stores name, task (at most 200 characters), anchor (at most 4 KB of JSON), cost_usd and session_id.
  • state works as for people. left deletes that agent’s row.
anchor says where the agent is working, in the same location fields a suggestion uses: { "kind": "block", "block": 3 } for a doc block (0-based), { "kind": "cell", "sheet": null, "address": "B4" } for a sheet cell, or { "kind": "artboard", "artboard": "shape:hero" } for a frame of a design canvas. The app draws the agent’s cursor or frame tag there. cost_usd is the agent session’s model cost so far, or absent when unknown. For people, kind is "user" and the agent fields are null.

Frame claims

On a design canvas, an agent claims an artboard before it changes it, so two agents never change the same frame. A claim is an agent presence heartbeat whose anchor has an artboard id. There is no separate claims table.
  • Claim. POST /presence with agent.anchor.artboard set. If another live agent session holds that artboard, the reply is 409, and nothing is written:
    “Another live agent session” means an agent row other than the caller’s own, seen in the last 45 seconds, whose session_id differs (or any other agent row when the caller sends no session_id). It can belong to another person’s agent on a shared design. Otherwise the heartbeat upserts as usual. The check and the write run under one lock per artboard, so two agents claiming at once can’t both win.
  • Keep it. Each heartbeat from the holder keeps the claim. It lasts as long as the heartbeats do (the 45-second TTL).
  • Release. A heartbeat with anchor: null (or without an artboard), or state: "left", releases it. A claim whose heartbeats stop lapses after 45 seconds.
  • An agent row holds one frame at a time: claiming another frame moves the claim.
  • Presence turned off. Claims hold even when the owner’s organization turned presence off, so agents still never change the same frame. The server writes and checks agent claim rows as usual, and a heartbeat that claims nothing deletes the agent’s row instead of storing it. GET /presence still returns { enabled: false, users: [] }, so nobody sees the claims, but a second agent’s claim or artboard suggestion still gets 409 artboard_claimed.
  • Artboard ids compare without tldraw’s shape: prefix, so hero and shape:hero are the same frame. anchor.artboard must be a string of 1 to 200 characters, otherwise 400.

Suggestions

Agents propose edits to doc and sheet artifacts, and frame changes to design canvases, as pending suggestions instead of writing a new version. The user accepts or rejects each one. Suggestions are stored in artifact_suggestions (migration 098_artifact_agent_watch.sql). A suggestion is { id, artifact_id, base_version, agent_name, session_id, change, reason, cost_usd, status, created_at, resolved_at }. id starts with sug_. cost_usd is a number or null. status is pending, accepted, rejected or stale. Resolving one sets resolved_by and resolved_at. change is one of four shapes: Which artifact takes which kind: Any other pair, including an HTML design (text/html), is 400 unsupported_kind.

Artboard changes

  • artboard is the artboard’s id, and name its name (optional, for display).
  • layers is the artboard’s full new layer list in stacking order (first at the bottom), as CanvasLayer objects from the design body format. Every layer’s artboard must equal artboard, layer ids are unique in the list, and they must not be used by layers on other artboards (422 layer_id_in_use). Layers are stored as sent.
  • frame optionally patches the artboard: fill (string), w and h (1 to 100,000) and props (object). Other fields are dropped. Left out, the artboard is unchanged.
  • before is { frame?, layers }: the artboard as the agent read it. gizzi fills it from the body.
  • The artboard must exist in the current body (422 unknown_artboard). A body that isn’t a v2 canvas yet isn’t checked.
  • Limits: layers and before at most 2 MB of JSON each, and at most 2000 layers each, otherwise 400 change_too_large. A request is at most 16 MB.
  • While another live agent session holds the artboard (see frame claims), the POST is refused with 409 artboard_claimed and the same holder. The holder’s own session, and anyone when no one holds the frame, can suggest.
  • controls (optional) adds generated sliders to the change; see controls.

Controls

An artboard change can carry controls: sliders, colour pickers and selects the user moves on the frame card before keeping the change. An agent sends them when the user is tuning something (spacing, radius, colour, density) instead of guessing one value.
  • At most 12 controls and 64 KB of JSON per change. An empty list stores no controls.
  • Any problem is 400 with code bad_controls and a message naming the control. Unknown fields are dropped.
  • A controls-only change is fine: layers equal to before.layers, plus controls.
  • The client applies controls. Moving one rewrites the previewed after state live (applyControl(change, controlId, value) in the app). Keep saves the tweaked state as the new version and records the final values in that version’s meta. The stored suggestion keeps the values the agent sent.
Applying is pure and client side. Remove every layer whose artboard is the change’s artboard, insert layers where the first removed one sat (or at the end when there were none), and patch the artboard with frame. The change is stale when the artboard no longer exists. While a change is pending the canvas shows the after state, marked “In review”. Keep saves a version with it and marks it accepted; Undo restores before and marks it rejected. A kept change can still be undone for 24 hours if the artboard still matches its layers. Limits: at most 50 changes per POST; find, replace, markdown and value at most 20,000 characters each; reason at most 500. The artifact must be a doc, a sheet or a design canvas, otherwise 400 unsupported_kind. The client applies accepted changes, not the server. To accept, the app applies the change to the current body, saves a new version (author the user, with meta.note), then sends PATCH with accepted. When a change no longer applies to the body (the text or cell moved on), the app marks it stale. Accept all applies the pending suggestions in order, saves one version, and resolves them with one POST .../resolve. The server never rewrites a body.

Errors

Errors use the standard Cloud API shape { "error", "message", "code" }. Artifact-specific codes are listed above. 401 means you are not signed in. 404 means the artifact doesn’t exist or you have no access.

Storage

The schema is cmd/allternit-cloud-api/migrations_pg/085_artifacts_v2.sql. It creates artifacts, artifact_versions, artifact_shares and org_artifact_settings, plus artifact_storage and artifact_consents (used by the page runtime) and artifact_comments for comments. 086_artifact_presence.sql adds artifact_presence, and 098_artifact_agent_watch.sql adds the agent presence columns, artifact_comments.agent_name and artifact_suggestions. The migration is idempotent and is applied to production by hand. The shared client uses src/styles/artifact-navigation.css for the Artifacts toolbar and inline mode selector. ArtifactsView keeps its title outside a nonwrapping, horizontally scrollable controls group; ModeDock uses nonshrinking buttons in the same single-row pattern. Both use --font-ui. Selection uses neutral translucent gradients and inset highlights rather than mode accent tokens, with solid surfaces for reduced transparency or increased contrast. This CSS is imported by the shared components used on Desktop, web and the phone PWA.

Library archive

GET /api/v2/artifacts accepts archived=true for the caller’s archive. Omitted or false returns saved work. This filter combines with scope, kind, title search, origin and cursor pagination. Updated servers include archive_supported: true in the list response.
Send false to restore. Success returns 204 No Content; repeated writes are idempotent. The caller must have at least view access. The server derives the user from authentication and rejects extra request fields. Missing or inaccessible artifacts return 404; invalid request bodies return 400. Archive is private library metadata per viewer. It does not change the artifact body, versions, updated time, ownership, grants or public link. Access checks still apply to archived lists. Deleting the artifact also deletes its library metadata. Deploy the Cloud API with Postgres migration 109_artifact_library_archive.sql before releasing archive clients. Clients must not interpret an older server’s unfiltered list as an archive.