Upload a file
const url = 'https://app.lyra-docs.com/api/v1/pages/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/files';const form = new FormData();form.append('file', 'file');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
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/files \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form file=@fileUploads one file, up to 50 MB, to a page, as multipart/form-data with the file in a field named file. People who can see the page can see the file. Put the markdown from the answer on a line of its own in the page to show it: images as images, and MP4, WebM, MOV, MP3, WAV and OGG files as players. On Lyra Cloud, an organization that has used all the file storage its plan allows gets 403 storage_limit_reached.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The page’s id
Request Bodyrequired
Section titled “Request Bodyrequired”object
The file to upload
Responses
Section titled “Responses”Created
A file uploaded to a page.
object
Where to download it, with the same token
Put this on a line of its own in a page to show the file
Example
{ "id": "0193a7c6-4444-7aaa-8bbb-000000000005", "name": "diagram.png", "contentType": "image/png", "sizeBytes": 48213, "url": "https://app.lyra-docs.com/api/files/0193a7c6-4444-7aaa-8bbb-000000000005", "markdown": ""}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." }}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