Canvases
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
GET | |
POST | |
GET | |
PATCH | |
DELETE | |
POST | |
GET | |
POST | |
GET | |
GET | |
POST | |
POST | |
GET | |
POST | |
GET | |
POST | |
POST | |
POST | |
POST | |
POST |
List all canvases
Canvases: agent-built sandboxed browser apps, filed into channels.
Source is versioned per publish and built server-side; the canvas app renders the published build's artifact from the isolated artifact origin.
Required API key scopes
canvas:readQuery parameters
- channelstring
- kindstringOne of:
"component""freeform""grid" - limitinteger
- offsetinteger
- orderingstringOne of:
"-created_at""-updated_at" - searchstring
Response
Example request
GET /api /projects /:project_id /canvasesExample response
Status 200
Create canvases
Create a new, empty canvas in a channel; give it source by publishing a project.
Required API key scopes
canvas:writeRequest parameters
- namestring
- channel_idstring
- kindDefault:
freeform - descriptionstringDefault:
- template_idstringDefault:
freeform
Response
Example request
POST /api /projects /:project_id /canvasesExample response
Status 201
Status 403 The sandbox token is not bound to this task or space.
Retrieve canvases
Canvases: agent-built sandboxed browser apps, filed into channels.
Source is versioned per publish and built server-side; the canvas app renders the published build's artifact from the isolated artifact origin.
Required API key scopes
canvas:readPath parameters
- idstring
Response
Example request
GET /api /projects /:project_id /canvases /:idExample response
Status 200
Update canvases
Update canvas metadata, including the space it belongs to.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- namestring
- descriptionstring
- channel_idstring
- pinnedboolean
- generation_task_idstring | null
Response
Example request
PATCH /api /projects /:project_id /canvases /:idExample response
Status 200
Status 403 Only the canvas creator can change the name, description, space, or pin state.
Delete canvases
Canvases: agent-built sandboxed browser apps, filed into channels.
Source is versioned per publish and built server-side; the canvas app renders the published build's artifact from the isolated artifact origin.
Required API key scopes
canvas:writePath parameters
- idstring
Example request
DELETE /api /projects /:project_id /canvases /:idExample response
Status 204 No response body
Create canvases actions
Invoke one registered action verb as the viewer.
The canvas must declare the verb in capabilities.posthog.actions (the reviewed permission boundary); the write itself runs with the viewer's own permissions, exactly as if they acted in the app.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- verbstring
- payloadobject
Response
Example request
POST /api /projects /:project_id /canvases /:id /actions /invokeExample response
Status 200
Status 400 Unknown verb, or the payload failed the verb's schema.
Status 403 The verb is not declared in the canvas's capabilities, actions are disabled for the team, or the caller is a sandbox.
Retrieve canvases builds
Read the canvas's build lifecycle: live pointers plus recent builds.
A publish queues a build; poll this until it is ready (the live pointer advances) or failed (fix the error diagnostics and publish again — the last good build stays live). Send the response's ETag back as If-None-Match to make the poll revalidate without a body.
Required API key scopes
canvas:readPath parameters
- idstring
Query parameters
- scopestring
- version_idstring
Response
Example request
GET /api /projects /:project_id /canvases /:id /buildsExample response
Status 200
Status 304 Not modified — the client's cached lifecycle is current.
Create canvases build action
Apply a lifecycle action (retry, pin, unpin, cancel) to one build.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- action
- build_idstring
Response
Example request
POST /api /projects /:project_id /canvases /:id /builds /actionExample response
Status 200
Status 429 The team's build capacity is exhausted; retry shortly.
List all canvases comments
The comment threads on this canvas, newest first. Open threads only unless include_resolved is set.
Required API key scopes
canvas:readcomment:readPath parameters
- idstring
Query parameters
- cursorstring
- include_resolvedbooleanDefault:
false - limitintegerDefault:
50
Response
Example request
GET /api /projects /:project_id /canvases /:id /commentsExample response
Status 200
Retrieve canvases comments
One comment thread on this canvas: the root comment and its replies, oldest first.
Required API key scopes
canvas:readcomment:readPath parameters
- idstring
- root_comment_idstring
Query parameters
- comment_idstring
- content_offsetintegerDefault:
0 - cursorstring
- limitintegerDefault:
50
Response
Example request
GET /api /projects /:project_id /canvases /:id /comments /:root_comment_idExample response
Status 200
Create canvases connectors
Call one declared connector tool as the viewer.
The canvas must declare the provider and tool in capabilities.connectors (the reviewed permission boundary); the call runs with the viewer's own connection, so two viewers of the same canvas see their own data.
Required API key scopes
canvas:writeuser:readPath parameters
- idstring
Request parameters
- approval_tokenstring
- providerstring
- toolstring
- argumentsobject
Response
Example request
POST /api /projects /:project_id /canvases /:id /connectors /callExample response
Status 200
Status 400 The arguments failed the tool's schema.
Status 403 The provider or tool is not declared in the canvas's capabilities, connectors are not enabled for the team, or the caller is a sandbox.
Create canvases draft
Stage a complete source project as a draft version and build it, without publishing.
The draft gets the same validation, versioning, and server-side build as
a publish, but the canvas's head and live build never move, so nothing
changes for viewers. Promote the version with promote to make it live.
The response reports how the draft's declared capabilities widen the
current head's, so growth in access can be reviewed before it ships.
No version guard applies: a draft conflicts with nothing.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- project
- promptstring
Response
Example request
POST /api /projects /:project_id /canvases /:id /draftExample response
Status 200
Status 400 The source project failed validation.
Status 429 The team's build capacity is exhausted; retry shortly.
Retrieve canvases drafts
The canvas's staged draft versions, newest first, each with its latest build status.
A draft is a version that was built but never made the head. Preview one
with source?version_id=, then make it live with promote.
Required API key scopes
canvas:readPath parameters
- idstring
Example request
GET /api /projects /:project_id /canvases /:id /draftsExample response
Status 200
Create canvases edit
Publish file edits against the canvas's current source project.
Diff-aware alternative to sending the complete project: operations
replace text inside a file, write, delete, or rename files, applied in
order to the head the caller read. expected_current_version_id is mandatory here —
relative edits against an unverified base could silently merge into
someone else's newer work.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- operationsarray
- capabilities
- promptstring
- namestring
- expected_current_version_idstring | null
Response
Example request
POST /api /projects /:project_id /canvases /:id /editExample response
Status 200
Status 400 An operation did not apply (a missing file, or old_string matched no place or several), or the edited project failed validation.
Status 403 Only the canvas creator can supply a name when editing.
Status 409 The canvas moved past expected_current_version_id (a concurrent publish or a revert).
Status 429 The team's build capacity is exhausted; retry shortly.
Retrieve canvases layout
Read a grid canvas's layout document and its current_version_id.
Always call this before editing: pass the returned version id as
expected_current_version_id on publish/patch so concurrent edits are
not overwritten. A grid canvas with no versions yet returns the
default empty layout with a null version id.
Required API key scopes
canvas:readPath parameters
- idstring
Query parameters
- include_componentsboolean
- version_idstring
Response
Example request
GET /api /projects /:project_id /canvases /:id /layoutExample response
Status 200
Status 304 Not modified — the client's cached layout is current.
Status 400 The canvas is not a grid canvas.
Create canvases layout patch
Apply surgical operations to the grid canvas's current layout.
The default write path for both the editor and agents: add, move,
resize, fill, or remove one placement without resending the layout.
expected_current_version_id is mandatory so an agent filling a box
and a user rearranging widgets cannot overwrite each other.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- operationsarray
- promptstring
- expected_current_version_idstring | null
Response
Example request
POST /api /projects /:project_id /canvases /:id /layout /patchExample response
Status 200
Status 400 An operation targeted a missing placement, or the edited layout failed validation.
Status 409 The canvas moved past expected_current_version_id.
Create canvases layout publish
Publish a complete layout document as the grid canvas's new head version.
Layout is data, not code: the new version is live immediately, with no
build. Validation errors reject the publish (400) and leave the canvas
untouched; a stale expected_current_version_id is rejected with 409.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- layout
- promptstring
- expected_current_version_idstring | null
Response
Example request
POST /api /projects /:project_id /canvases /:id /layout /publishExample response
Status 200
Status 400 The canvas is not a grid canvas, or the layout failed validation.
Status 409 The canvas moved past expected_current_version_id.
Create canvases promote
Make a draft version the canvas's live head.
A draft whose build is ready goes live immediately, with no rebuild; otherwise a fresh build is queued. Returns that build.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- version_idstring
- expected_current_version_idstring | null
Response
Example request
POST /api /projects /:project_id /canvases /:id /promoteExample response
Status 200
Status 409 The canvas moved past expected_current_version_id (a concurrent publish or a revert).
Status 429 The team's build capacity is exhausted; retry shortly.
Create canvases publish
Publish a complete source project as the canvas's new head version.
Validation errors reject the publish (400) and leave the canvas
untouched; a stale expected_current_version_id is rejected with 409.
A successful publish queues a server-side build.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- project
- promptstring
- namestring
- expected_current_version_idstring | null
Response
Example request
POST /api /projects /:project_id /canvases /:id /publishExample response
Status 200
Status 400 The source project failed validation.
Status 403 Only the canvas creator can supply a name when publishing.
Status 409 The canvas moved past expected_current_version_id (a concurrent publish or a revert).
Status 429 The team's build capacity is exhausted; retry shortly.
Create canvases publish current version
Queue a build for the current source version without changing source or metadata.
Required API key scopes
canvas:writePath parameters
- idstring
Request parameters
- expected_current_version_idstring
Response
Example request
POST /api /projects /:project_id /canvases /:id /publish-current-version