Change a page block by block
const url = 'https://app.lyra-docs.com/api/v1/pages/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/edits';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"edits":[{"op":"insert","markdown":"## Risks\n\n- The importer is slow on big pages","afterBlockId":"b2c1"},{"op":"replace","blockId":"a9f0","markdown":"We launch on the **12th**."}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.lyra-docs.com/api/v1/pages/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/edits \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "edits": [ { "op": "insert", "markdown": "## Risks\n\n- The importer is slow on big pages", "afterBlockId": "b2c1" }, { "op": "replace", "blockId": "a9f0", "markdown": "We launch on the **12th**." } ] }'Applies edits in order, by the block ids that GET /api/v1/pages/{pageId}/markdown?withIds=true shows, live and without touching what others are typing elsewhere. insert adds Markdown after or before a block, or at the end; replace swaps one block for new Markdown and keeps its id; delete removes a block; replace_all replaces the whole page. For tables, set_cells, insert_row and delete_row change cells and rows; rows and columns count from 0. The answer lists, for each edit, the top-level blocks it added or changed, the blocks other than plain text it made, and warnings. Lyra saves the page as a version first.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The page’s id
Header Parameters
Section titled “Header Parameters”Any unique string, up to 200 characters. Send the same key when you retry, and Lyra answers with the first answer instead of doing it twice.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Add Markdown after or before a block, or at the end of the page
object
Replace one block with new Markdown, keeping its id
object
Delete one block
object
Replace everything on the page with new Markdown
object
Change cells of a table
object
object
One line of Markdown
Add a row to a table, after afterRow or at the end
object
One line of Markdown per column; missing columns are left empty
Remove a row from a table
object
Example
{ "edits": [ { "op": "insert", "markdown": "## Risks\n\n- The importer is slow on big pages", "afterBlockId": "b2c1" }, { "op": "replace", "blockId": "a9f0", "markdown": "We launch on the **12th**." } ]}Responses
Section titled “Responses”OK
object
What one edit did.
object
The top-level blocks the edit added or changed
How many blocks other than plain text the Markdown made, by type, such as {“card”: 3}
object
A line of Markdown that Lyra read differently from what it looks like you meant, such as a block it does not have or a container that is never closed.
object
The line of the Markdown it is about, counting from 1
Example
{ "edits": [ { "op": "insert", "warnings": [ { "line": 4, "message": "Lyra has no block named callout, so this line shows as text. Its blocks are card, columns, column, timeline, item, arrow, stat, choice." } ] } ]}Headers
Section titled “Headers”How many requests the token can send in a minute
How many it has left this minute
Seconds until the count starts again
The id of this request. Send it to support if something goes wrong.
The request does not match the schema: a missing field, a wrong type or a value out of range.
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "invalid_request", "message": "The request is not valid.", "issues": [ { "instancePath": "/title", "message": "Too big: expected string to have <=500 characters" } ] }}The token is missing, wrong, revoked or expired.
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "unauthorized", "message": "Please sign in." }}The token’s person can see this, but can’t do this to it.
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "forbidden", "message": "You don't have access to do that." }}It doesn’t exist, or the token’s person can’t see it. The code names what, such as page_not_found.
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "page_not_found", "message": "This page doesn't exist or you don't have access to it." }}A request with the same Idempotency-Key is still running.
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "request_in_progress", "message": "A request with this key is still running." }}The page, file or Markdown is too large: page_too_large, file_too_large, or markdown_too_complex for Markdown too long or too deeply nested to read in one go.
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "file_too_large", "message": "Files can be up to 50 MB." }}The request is well formed but Lyra can’t do it, such as a block id that isn’t on the page (block_not_found), or an Idempotency-Key used before with a different body (idempotency_key_reused).
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "block_not_found", "message": "Block 'a9f0' is not on this page" }}Too many requests. Each token can send 120 requests a minute. Wait for the seconds in Retry-After.
What went wrong.
object
object
A stable code to check in your code, such as page_not_found
A sentence for people, which can change
For invalid_request, each part of the request that was wrong
Example
{ "error": { "code": "rate_limited", "message": "Too many requests. Try again in 21 seconds." }}Headers
Section titled “Headers”Seconds to wait before sending again