API overview

Read and change OpenCanvas canvases from programs: bots, integrations and back-office jobs. Changes land in the live canvas as one transaction, show up for everyone editing it, and are saved to your application like any other edit.

Base URL

Every operation is under /api/v1 on your OpenCanvas server. The examples on these pages use https://canvas.example.com; use your own server's public address.

https://canvas.example.com/api/v1/files/{fileId}

fileId is your file id, the one you use in launch tokens and callbacks. OpenCanvas keeps no files of its own: your application owns users, permissions and files, and OpenCanvas loads and saves through your callbacks (integration guide).

Turn it on

The API is off until you turn it on for your host, in its entry of the hosts file:

[[host]]
id      = "acme"
api_key = "env:ACME_OC_API_KEY"   # the host key, for server-to-server calls

[host.flags]
api_v1 = true                     # the default from 0.2.0 (it was off in 0.1.2); false turns it off

With api_v1 = false, every /api/v1 call for that host answers 404 with the code API_OFF. User tokens also need a public base URL (OC_PUBLIC_URL, or [host.api] audience); see authentication.

Versioning

  • The path carries the major version. Within v1 changes are additive: new operations, new optional parameters, new fields in answers. Ignore fields you do not know.
  • A breaking change gets a new path (/api/v2), and v1 keeps working alongside it.
  • The OpenAPI 3.1 document is the contract. A running server serves it at GET /api/v1/openapi.json; it is checked in as [crates/oc-server/api/openapi.json](../../../crates/oc-server/api/openapi.json), and a test keeps it and the server's router identical. This reference is generated from it.
  • The 0.1 routes (/v1/files/{fileId}/patch and the others) still work and carry Deprecation and a Link to their successor. They are retired in v0.3; see 0.1 routes.

Your first call

Read a canvas as Markdown, then append a paragraph, with the host key. The If-Match header makes the change apply only if nobody changed the canvas since you read it.

Read, then append
curl -s "https://canvas.example.com/api/v1/files/doc_1?format=markdown" \
  -H "X-OpenCanvas-Host: acme" \
  -H "X-OpenCanvas-Key: $OC_API_KEY"

curl -s -X POST "https://canvas.example.com/api/v1/files/doc_1/blocks:batch" \
  -H "X-OpenCanvas-Host: acme" \
  -H "X-OpenCanvas-Key: $OC_API_KEY" \
  -H "Content-Type: application/json" \
  -H 'If-Match: "c465d27bcd7e"' \
  -H "Idempotency-Key: 5f0e7d4c-2b1a-4e8f-9c3d-6a7b8c9d0e1f" \
  -d '{"ops": [{"op": "append", "markdown": "Shipped on Friday."}]}'

Requests and answers

TopicHow it works
FormatJSON in UTF-8, Content-Type: application/json. Import and convert take the file itself as the body; export and convert answer the file.
CredentialsThe host key (X-OpenCanvas-Host and X-OpenCanvas-Key) or a user token you mint (Authorization: Bearer). See authentication.
ErrorsRFC 9457 problem details with a machine code. See errors.
RevisionsReads answer ETag: "<rev>". Send it back as If-Match on a batch, or a block's rev as ifMatch on one op, and a stale write fails with 412 STALE_BLOCK instead of overwriting.
ListslistBlocks and queryRows page with signed cursors. See pagination.
WritesEvery POST /api/v1/files/... takes Idempotency-Key, so a retry never applies twice. See idempotency.
LimitsToken buckets per caller and per file, announced in RateLimit headers. See rate limits.
ChangesStream them per file (events) or receive them by POST (webhooks).

How changes land

A write runs in the file's live room as one transaction: everyone editing the canvas sees it at once, and it is saved to your application by the same autosave as a person's edit (POST .../commit saves now). If nobody has the file open, OpenCanvas loads it from you, applies the change and saves it straight away.

Changes to existing blocks land directly, unless the call sends "mode": "suggest" or the host sets [host.api] default_mode = "suggest": then they become suggestions that a person accepts in the editor. A batch that deletes more than 5 blocks needs "confirm": true.

Operations

ResourceOperationSummary
CanvasGET /api/v1/files/{fileId}Read a canvas as JSON blocks, Markdown or an outline
BlocksGET /api/v1/files/{fileId}/blocksList top-level blocks
BlocksGET /api/v1/files/{fileId}/blocks/{blockId}Read one block (also nested ones)
BlocksGET /api/v1/files/{fileId}/blocks:findFind blocks whose text contains q (case-insensitive)
BlocksPOST /api/v1/files/{fileId}/blocks:batchChange blocks in one atomic transaction
BlocksPOST /api/v1/files/{fileId}/liveMake blocks live
BlocksGET /api/v1/files/{fileId}/referencesList the live blocks and block references
DatabasesGET /api/v1/files/{fileId}/databasesList databases with fields, row counts and views
DatabasesPOST /api/v1/files/{fileId}/databasesCreate a database block
DatabasesGET /api/v1/files/{fileId}/databases/{dbId}Describe one database
DatabasesGET /api/v1/files/{fileId}/databases/{dbId}/rowsQuery rows
DatabasesPOST /api/v1/files/{fileId}/databases/{dbId}/rows:upsertCreate or update rows (at most 200)
DatabasesPOST /api/v1/files/{fileId}/databases/{dbId}/fieldsAdd a field
BoardsPOST /api/v1/files/{fileId}/boardsCreate a board block with shapes
BoardsGET /api/v1/files/{fileId}/boards/{boardId}/shapesRead a board's shapes
BoardsPOST /api/v1/files/{fileId}/boards/{boardId}/shapesAdd shapes to a board
CommentsGET /api/v1/files/{fileId}/commentsList comment threads
CommentsPOST /api/v1/files/{fileId}/commentsStart a thread on a block or reply to one
MembersGET /api/v1/files/{fileId}/membersPeople with access (id, name, detail; never e-mail)
Export and importGET /api/v1/files/{fileId}/export/{format}Export the canvas
Export and importGET /api/v1/files/{fileId}/renderRender the canvas as read-only HTML
Export and importPOST /api/v1/files/{fileId}/importImport Markdown, HTML or CSV into the canvas
Export and importPOST /api/v1/convertStateless conversion
AutomationGET /api/v1/files/{fileId}/automationsList automation rules
AutomationPOST /api/v1/files/{fileId}/automations:testTest run a rule
AutomationGET /api/v1/files/{fileId}/automations/runsAutomation run history
AutomationPUT /api/v1/files/{fileId}/automations/{ruleId}Create or replace a rule
AutomationDELETE /api/v1/files/{fileId}/automations/{ruleId}Delete a rule
AutomationPOST /api/v1/files/{fileId}/automations/{ruleId}/enableSwitch a rule on or off
SearchPOST /api/v1/extractExtract search.json
SearchGET /api/v1/searchSearch across canvases
PluginsGET /api/v1/pluginsThe organisation's plugins
PluginsGET /api/v1/plugins/catalogBrowse the registries
PluginsGET /api/v1/plugins/catalog/{registry}/{pluginId}A plugin's details
PluginsPOST /api/v1/plugins/installInstall a plugin for the organisation
PluginsPOST /api/v1/plugins/uploadUpload a signed package
PluginsPOST /api/v1/plugins/refreshCheck the registries now
PluginsGET /api/v1/plugins/policyThe organisation's plugin policy
PluginsPUT /api/v1/plugins/policySet the plugin policy
PluginsGET /api/v1/plugins/requestsRequests for plugins
PluginsPOST /api/v1/plugins/requestsRequest a plugin
PluginsPOST /api/v1/plugins/requests/{requestId}/declineDecline a request
PluginsPOST /api/v1/plugins/requests/{requestId}/closeClose a request
PluginsPATCH /api/v1/plugins/{pluginId}Switch a plugin on or off, pin or unpin
PluginsDELETE /api/v1/plugins/{pluginId}Uninstall a plugin
PluginsPOST /api/v1/plugins/{pluginId}/updateApprove an update
PluginsPOST /api/v1/plugins/{pluginId}/rollbackRoll back to the previous version
LinksGET /api/v1/files/{fileId}/backlinksCanvases that link to this canvas
LinksDELETE /api/v1/links/files/{fileId}Drop a deleted file's links from the index
LinksPOST /api/v1/links/indexBackfill the link index from your files
LinksGET /api/v1/graphThe link graph between canvases
Events and syncGET /api/v1/files/{fileId}/eventsChange events of one file, as Server-Sent Events or (with a WebSocket upgrade) JSON text messages
Events and syncPOST /api/v1/files/{fileId}/sync-tokenA ticket for the room WebSocket, so a Yjs-native client syncs the CRDT directly
AdminPOST /api/v1/files/{fileId}/commitSave now (200 saved, 202 queued in the outbox, 409 conflict)
AdminPOST /api/v1/files/{fileId}/roleChange a user's role live (none disconnects them)
AdminDELETE /api/v1/files/{fileId}/sessionFinal save, disconnect everyone, drop every ticket
AdminPOST /api/v1/files/{fileId}/members:invalidateThe member list changed; drop cached answers
AdminPOST /api/v1/offline/revokeRevoke every offline copy of a person
OpenAPI documentGET /api/v1/openapi.jsonThis document
0.1 routes (deprecated)POST /v1/files/{fileId}/patchPatch blocks (0.1)
0.1 routes (deprecated)POST /v1/files/{fileId}/commitSave now (0.1)
0.1 routes (deprecated)POST /v1/files/{fileId}/roleChange a role (0.1)
0.1 routes (deprecated)DELETE /v1/files/{fileId}/sessionClose the session (0.1)
0.1 routes (deprecated)POST /v1/files/{fileId}/members/invalidateMembers changed (0.1)
0.1 routes (deprecated)POST /v1/files/{fileId}/importImport (0.1)
0.1 routes (deprecated)POST /v1/convertConvert (0.1)

No "try it" console

This reference has no console that sends requests from the page. The site is static (GitHub Pages) with no OpenCanvas server behind it, and a console would mean pasting a host key or a user token into a web page. Use the samples with your own server: every one of them can be copied, and the language you pick is remembered on your device.

Last changed .