Canvas

Read a whole canvas as JSON blocks, Markdown or a heading outline.

Read a canvas as JSON blocks, Markdown or an outline

GET/api/v1/files/{fileId}

The canvas as JSON blocks (default), Markdown or a heading outline. Every block carries its blockId and a rev hash; the document rev comes back as ETag. Pass a block's rev as ifMatch, or the document's as If-Match, when you change it.

If nobody has the file open, OpenCanvas loads it from your load callback first.

Credentials
Host key, or a user token with canvas:read.
Least role
view on the file (effective permission min(scope, role)).
Operation id
readFile

Parameters

NameInTypeDescription
fileIdrequiredpathstringThe host's file id 1 to 1024 characters.
formatquerystringjson (default), markdown or outline One of json, markdown, outline.

Responses

200OK

Headers

HeaderDescription
ETagThe document (or block) revision, quoted.
Idempotency-Replayedtrue when this is the stored answer of an earlier request with the same Idempotency-Key
RateLimit-PolicyToken buckets that apply: "subject";q=<burst>;w=<seconds to refill>, and "file-writes" on writes
RateLimitThe bucket closest to empty: "<name>";r=<remaining>;t=<seconds until full>
Link<…?cursor=…&limit=…>; rel="next" when more follow

Body application/json

FieldTypeDescription
titleany-
revstring-
truncatedboolean-
markdownstring-
blocksarray-
outlinearray-
countsobject-

Example

{
  "blocks": [
    {
      "blockId": "b_01m87jv4rtz1wkrv27pzmqk64r",
      "node": {
        "attrs": {
          "blockId": "b_01m87jv4rtz1wkrv27pzmqk64r",
          "level": 2
        },
        "content": [
          {
            "text": "Launch plan",
            "type": "text"
          }
        ],
        "type": "heading"
      },
      "rev": "689ac3d33e18"
    },
    {
      "blockId": "b_01m87jv4rtkdxymn93jwtx35sk",
      "node": {
        "attrs": {
          "blockId": "b_01m87jv4rtkdxymn93jwtx35sk"
        },
        "content": [
          {
            "text": "Ship on Friday.",
            "type": "text"
          }
        ],
        "type": "paragraph"
      },
      "rev": "5641be1fd2cb"
    },
    {
      "blockId": "b_01m87jv4rtngbs1n2p5aypa4mz",
      "node": {
        "attrs": {
          "blockId": "b_01m87jv4rtngbs1n2p5aypa4mz"
        },
        "content": [
          {
            "attrs": {
              "checked": false
            },
            "content": [
              {
                "content": [
                  {
                    "text": "Write the release notes",
                    "type": "text"
                  }
                ],
                "type": "paragraph"
              }
            ],
            "type": "taskItem"
          }
        ],
        "type": "taskList"
      },
      "rev": "92c98e698f58"
    }
  ],
  "rev": "fc3a67f52c7b",
  "title": null,
  "truncated": false
}
400Bad Request: BAD_INPUT, PATCH_INVALID, CURSOR_INVALID, IDEMPOTENCY_KEY_INVALID, …

Body application/problem+json

FieldTypeDescription
typerequiredstringFormat uri-reference.
titlerequiredstring-
statusrequiredinteger-
detailstring-
coderequiredstringMachine code (BLOCK_NOT_FOUND, STALE_BLOCK, ROLE_FORBIDDEN, …)
freshanySTALE_BLOCK: the current state to retry against

Other members may appear; ignore the ones you do not know.

Example

{
  "type": "urn:opencanvas:problem:bad-input",
  "title": "Bad Request",
  "status": 400,
  "detail": "rows[0].values must be an object",
  "code": "BAD_INPUT"
}

Codes: BAD_INPUT.

401Unauthorized: UNAUTHENTICATED, TOKEN_INVALID, TOKEN_EXPIRED

Body application/problem+json

FieldTypeDescription
typerequiredstringFormat uri-reference.
titlerequiredstring-
statusrequiredinteger-
detailstring-
coderequiredstringMachine code (BLOCK_NOT_FOUND, STALE_BLOCK, ROLE_FORBIDDEN, …)
freshanySTALE_BLOCK: the current state to retry against

Other members may appear; ignore the ones you do not know.

Example

{
  "type": "urn:opencanvas:problem:unauthenticated",
  "title": "Unauthorized",
  "status": 401,
  "detail": "missing or wrong credentials",
  "code": "UNAUTHENTICATED"
}

Codes: UNAUTHENTICATED, TOKEN_INVALID, TOKEN_EXPIRED.

403Forbidden: ROLE_FORBIDDEN, SCOPE_REQUIRED, FILES_REQUIRED

Body application/problem+json

FieldTypeDescription
typerequiredstringFormat uri-reference.
titlerequiredstring-
statusrequiredinteger-
detailstring-
coderequiredstringMachine code (BLOCK_NOT_FOUND, STALE_BLOCK, ROLE_FORBIDDEN, …)
freshanySTALE_BLOCK: the current state to retry against

Other members may appear; ignore the ones you do not know.

Example

{
  "type": "urn:opencanvas:problem:scope-required",
  "title": "Forbidden",
  "status": 403,
  "detail": "SCOPE_REQUIRED: comment_add needs canvas:comment",
  "code": "SCOPE_REQUIRED"
}

Codes: SCOPE_REQUIRED, ROLE_FORBIDDEN, FILES_REQUIRED.

404Not Found: API_OFF, BLOCK_NOT_FOUND, NOT_FOUND, …

Body application/problem+json

FieldTypeDescription
typerequiredstringFormat uri-reference.
titlerequiredstring-
statusrequiredinteger-
detailstring-
coderequiredstringMachine code (BLOCK_NOT_FOUND, STALE_BLOCK, ROLE_FORBIDDEN, …)
freshanySTALE_BLOCK: the current state to retry against

Other members may appear; ignore the ones you do not know.

Example

{
  "type": "urn:opencanvas:problem:api-off",
  "title": "Not Found",
  "status": 404,
  "detail": "the API is not enabled for this host ([host.flags] api_v1)",
  "code": "API_OFF"
}

Codes: API_OFF.

429Too Many Requests: RATE_LIMITED, with Retry-After, RateLimit-Policy and RateLimit

Body application/problem+json

FieldTypeDescription
typerequiredstringFormat uri-reference.
titlerequiredstring-
statusrequiredinteger-
detailstring-
coderequiredstringMachine code (BLOCK_NOT_FOUND, STALE_BLOCK, ROLE_FORBIDDEN, …)
freshanySTALE_BLOCK: the current state to retry against

Other members may appear; ignore the ones you do not know.

Example

{
  "type": "urn:opencanvas:problem:rate-limited",
  "title": "Too Many Requests",
  "status": 429,
  "detail": "too many requests (subject limit); retry later",
  "code": "RATE_LIMITED"
}

Codes: RATE_LIMITED.

502Bad Gateway: HOST_UNAVAILABLE: your load or save callback failed

Body application/problem+json

FieldTypeDescription
typerequiredstringFormat uri-reference.
titlerequiredstring-
statusrequiredinteger-
detailstring-
coderequiredstringMachine code (BLOCK_NOT_FOUND, STALE_BLOCK, ROLE_FORBIDDEN, …)
freshanySTALE_BLOCK: the current state to retry against

Other members may appear; ignore the ones you do not know.

Example

{
  "type": "urn:opencanvas:problem:host-unavailable",
  "title": "Bad Gateway",
  "status": 502,
  "detail": "host answered 503 Service Unavailable",
  "code": "HOST_UNAVAILABLE"
}

Codes: HOST_UNAVAILABLE.

503Service Unavailable: UNAVAILABLE, ROOM_UNAVAILABLE, with Retry-After

Body application/problem+json

FieldTypeDescription
typerequiredstringFormat uri-reference.
titlerequiredstring-
statusrequiredinteger-
detailstring-
coderequiredstringMachine code (BLOCK_NOT_FOUND, STALE_BLOCK, ROLE_FORBIDDEN, …)
freshanySTALE_BLOCK: the current state to retry against

Other members may appear; ignore the ones you do not know.

Example

{
  "type": "urn:opencanvas:problem:unavailable",
  "title": "Service Unavailable",
  "status": 503,
  "detail": "the idempotency store is unavailable; retry",
  "code": "UNAVAILABLE"
}

Codes: UNAVAILABLE.

Errors

StatusCodeWhen
400BAD_INPUTThe request is not what the operation takes: the body is not a JSON object, a field is missing or has the wrong type, an op, mode, format or event type is unknown, or fileId is longer than 1,024 bytes. detail says which.
502HOST_UNAVAILABLEYour load or save callback failed or timed out, so the file could not be loaded or saved.

Also, like every operation on a file: API_OFF, UNAUTHENTICATED, TOKEN_INVALID, TOKEN_EXPIRED, SCOPE_REQUIRED, ROLE_FORBIDDEN, FILES_REQUIRED, RATE_LIMITED, UNAVAILABLE, INTERNAL.

Last changed .