Skip to content

Databases and files

These examples use LYRA_TOKEN from the quickstart. Each endpoint is in the reference too.

A database’s id is the id of its page: open it in Lyra and take the last part of the link. The examples use a Tasks database with the properties Name, Status, Due, Owner and Tags.

Terminal window
export DATABASE_ID="<the database's id>"

Start by reading the database’s properties, so you know their names, types and options:

Terminal window
curl -s "https://app.lyra-docs.com/api/v1/databases/$DATABASE_ID" \
-H "Authorization: Bearer $LYRA_TOKEN"
{
"id": "01a237d5-be0f-7655-966b-0d75eb39f10c",
"title": "Tasks",
"properties": [
{ "id": "01a237d5-be19-7540-ba55-0424bb0d3fa8", "name": "Name", "type": "title" },
{ "id": "01a237d5-be1b-738e-9588-1c460d05a98b", "name": "Tags", "type": "multi_select" },
{ "id": "01a237d8-70d9-744d-b7ae-7c59f1c54816", "name": "Status", "type": "status", "options": ["Not started", "In progress", "Done"] },
{ "id": "01a237d8-70fd-73ec-b340-2f58c71c1200", "name": "Due", "type": "date" },
{ "id": "01a237d8-7118-7684-9b5b-29a9138ef0f4", "name": "Owner", "type": "person" }
],
"views": [{ "id": "01a237d5-be1c-7783-b786-deafaade4c83", "name": "Table", "type": "table" }]
}

Give each row a title and its values by property name. One request adds up to 100 rows, all or none.

Terminal window
curl -s -X POST "https://app.lyra-docs.com/api/v1/databases/$DATABASE_ID/rows" \
-H "Authorization: Bearer $LYRA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{ "title": "Write the launch post", "values": { "Status": "In progress", "Due": "2026-12-10", "Owner": ["sam@example.com"] } },
{ "title": "Record the demo", "values": { "Status": "Not started", "Due": "2026-12-08", "Tags": ["video"] } },
{ "title": "Book the venue", "values": { "Status": "Done" } }
]
}'
{
"rowIds": [
"01a237d9-1f94-71ad-bf0e-ee9e19bb08f2",
"01a237d9-1fa0-7321-bf0d-8743e780075a",
"01a237d9-1fae-72ad-9bb5-95402c492807"
]
}

How to write each type of value:

Property type Write Read back
Text, URL, email, phone "text" "text"
Number 42 42
Checkbox true or false true or false
Select, status The option’s label: "Done" "Done"
Multi-select A list of labels: ["video", "launch"] The same
Date "2026-12-10", or {"start": "2026-12-08", "end": "2026-12-10"} for a range "2026-12-10T00:00:00.000Z", or {"start", "end"} for a range
Person A list of emails or user ids of people in the organization A list of names
Relation A list of row ids A list of {id, title}

Filter, sort and page through rows. Filters and sorts name properties by name or id:

Terminal window
curl -s -X POST "https://app.lyra-docs.com/api/v1/databases/$DATABASE_ID/query" \
-H "Authorization: Bearer $LYRA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"filter": {
"op": "and",
"items": [{ "propertyId": "Status", "operator": "not_equals", "value": "Done" }]
},
"sorts": [{ "propertyId": "Due", "direction": "asc" }],
"limit": 25
}'
{
"rows": [
{
"id": "01a237d9-1fa0-7321-bf0d-8743e780075a",
"values": { "Name": "Record the demo", "Tags": ["video"], "Status": "Not started", "Due": "2026-12-08T00:00:00.000Z", "Owner": [] }
},
{
"id": "01a237d9-1f94-71ad-bf0e-ee9e19bb08f2",
"values": { "Name": "Write the launch post", "Tags": [], "Status": "In progress", "Due": "2026-12-10T00:00:00.000Z", "Owner": ["Sam"] }
}
],
"nextCursor": null
}
  • A filter is a group: op is and or or, and items holds conditions or more groups, so you can nest them.
  • Operators: equals, not_equals, contains, not_contains, starts_with, ends_with, is_empty, is_not_empty, gt, gte, lt, lte, any_of, none_of, all_of, and within for dates, with a value of past_week, past_month, past_year, this_week, this_month, next_week, next_month or next_year.
  • search keeps only rows whose text contains some words.
  • viewId reads through a view, with its own filter and sorts added to yours.
  • Up to 8 sorts. When nextCursor isn’t null, there are more rows. See Paging.

Send only the values that change. One request changes up to 100 rows. If Lyra refuses one of them, such as a property the database doesn’t have, none of the rows change:

Terminal window
curl -s -X PATCH "https://app.lyra-docs.com/api/v1/databases/$DATABASE_ID/rows" \
-H "Authorization: Bearer $LYRA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"updates": [{"rowId": "01a237d9-1fa0-7321-bf0d-8743e780075a", "values": {"Status": "In progress"}}]}'
{ "updated": 1 }

Read one row with GET /databases/{databaseId}/rows/{rowId}.

Move up to 500 rows to the trash at once. People can restore them from the trash in Lyra.

Terminal window
curl -s -X POST "https://app.lyra-docs.com/api/v1/databases/$DATABASE_ID/rows/trash" \
-H "Authorization: Bearer $LYRA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"rowIds": ["01a237d9-1fa0-7321-bf0d-8743e780075a"]}'
{ "trashed": 1 }

trashed counts the rows that were in this database. Ids of rows from other databases are left alone.

Upload a file to a page as multipart/form-data, in a field named file. Files can be up to 50 MB.

Terminal window
curl -s -X POST "https://app.lyra-docs.com/api/v1/pages/$PAGE_ID/files" \
-H "Authorization: Bearer $LYRA_TOKEN" \
-F "file=@diagram.png"
{
"id": "01a237f9-fddb-73db-97b2-2291af5034d3",
"name": "diagram.png",
"contentType": "image/png",
"sizeBytes": 93,
"url": "https://app.lyra-docs.com/api/files/01a237f9-fddb-73db-97b2-2291af5034d3",
"markdown": "![diagram.png](/api/files/01a237f9-fddb-73db-97b2-2291af5034d3)"
}

Uploading doesn’t show the file on the page yet. To show it, put markdown on a line of its own in the page, for example with an insert edit:

Terminal window
curl -s -X POST "https://app.lyra-docs.com/api/v1/pages/$PAGE_ID/edits" \
-H "Authorization: Bearer $LYRA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"edits": [{"op": "insert", "markdown": "![diagram.png](/api/files/01a237f9-fddb-73db-97b2-2291af5034d3)"}]}'

With no afterBlockId or beforeBlockId, an insert goes at the end of the page.

Download a file from its url with the same token. Downloads take a Range header to fetch part of a file:

Terminal window
curl -s -o diagram.png "https://app.lyra-docs.com/api/files/01a237f9-fddb-73db-97b2-2291af5034d3" \
-H "Authorization: Bearer $LYRA_TOKEN"