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 akind, 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; legacyallternit_*tokens still work) with thecomputescope (or*). A token without it gets403; - a paired device’s token (
allternit_runtime_…, whatgizzi loginstores). It acts as the device’s owner, with no organization.
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
Aplan 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/artifactswithoutkind=plannever 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 withGET /api/v2/artifacts?kind=plan, newestupdated_atfirst. - Status. Summaries and artifacts of kind
plancarryplan: {status},open(also when never set),approvedordone. Set it withPATCH /api/v2/artifacts/{id}and{ "plan_status": "approved" }. It needsownerand doesn’t add a version. Other kinds answer422 not_a_plan, and a value other than the three answers422 invalid_plan_status. Gizzi setsapprovedwhen you approve the plan anddonewhen 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 beart_followed by up to 64 letters, digits,_or-. Query strings, extra path parts and escapes are dropped, and anything else is ignored.
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, createsguard-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_formatistext/html. The HTML is a finished report with no script: Guard removes scripts, event handlers and active content before it sends the body.template_idhas the formguard.<family>.<template>, for exampleguard.recon.domain-dossier. It is at most 128 characters.meta.guardholdstemplate_id,family,artifact_kind,guard_artifact_id, aheader(case_title,scope_summary,run_id,sha256,template_version),counts, the list of optionalredactedclasses (private_ip,local_path,email,sensitive) andsource: "Allternit Guard".metais 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.
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
AnArtifactSummary 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:
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
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
idyou already own, you get that artifact back unchanged with200. If someone else owns theid, you get409 id_conflict. Client ids areart_followed by letters, digits,_or-, at most 128 characters. Legacy imports useart_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.connectorsgets422 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
Adashboard 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
Anops 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
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:
base_version: 4. Viewers only see the shared version, so asking them for any other version gets 404.
Sharing
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 return422 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.
Public link
{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 inartifact_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:
shapeIdis the layer’s shape id, or the artboard’s own id when the comment is about the whole frame (shapeIdequalsartboard).artboardis the artboard’s shape id andlabelthe name shown in the thread. When present,shapeId,artboardandlabelmust be strings of at most 200 characters, otherwise400.- 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: itsanchoris at most 4 KB. Docs have no Commenter level, so a viewer of a doc can’t comment.
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 inartifact_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 sendsagent: { 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_idisagent:<session_id or none>:<slug of name>, andkindis"agent"(people are"user").- The row stores
name,task(at most 200 characters),anchor(at most 4 KB of JSON),cost_usdandsession_id. stateworks as for people.leftdeletes 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 whoseanchor has an artboard id. There is no separate claims table.
-
Claim.
POST /presencewithagent.anchor.artboardset. If another live agent session holds that artboard, the reply is409, and nothing is written:“Another live agent session” means an agent row other than the caller’s own, seen in the last 45 seconds, whosesession_iddiffers (or any other agent row when the caller sends nosession_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), orstate: "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 /presencestill returns{ enabled: false, users: [] }, so nobody sees the claims, but a second agent’s claim or artboard suggestion still gets409 artboard_claimed. -
Artboard ids compare without tldraw’s
shape:prefix, soheroandshape:heroare the same frame.anchor.artboardmust be a string of 1 to 200 characters, otherwise400.
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 inartifact_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
artboardis the artboard’s id, andnameits name (optional, for display).layersis the artboard’s full new layer list in stacking order (first at the bottom), asCanvasLayerobjects from the design body format. Every layer’sartboardmust equalartboard, 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.frameoptionally patches the artboard:fill(string),wandh(1 to 100,000) andprops(object). Other fields are dropped. Left out, the artboard is unchanged.beforeis{ 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:
layersandbeforeat most 2 MB of JSON each, and at most 2000 layers each, otherwise400 change_too_large. A request is at most 16 MB. - While another live agent session holds the artboard (see frame claims), the
POSTis refused with409 artboard_claimedand the sameholder. 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 carrycontrols: 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
400with codebad_controlsand a message naming the control. Unknown fields are dropped. - A controls-only change is fine:
layersequal tobefore.layers, pluscontrols. - 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’smeta. The stored suggestion keeps the values the agent sent.
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 iscmd/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.
Navigation presentation
The shared client usessrc/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.
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.