Docs
Schedule demo Open app

Create an embed token

POST https://app.eraser.io/api/embedTokens

Create a URL that shows a read-only Eraser file or diagram in an iframe. Viewers don't need an Eraser account.

Call this from your server, never from the browser – the request carries your API token. See Embedding files and diagrams for choosing what to show, how long an embed lasts, and how to revoke one.

Example request

curl --location 'https://app.eraser.io/api/embedTokens' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "fileId": "abc123",
    "content": [{ "type": "diagram", "id": "def456" }],
    "expiresIn": "1h",
    "theme": "dark"
}'

Example response

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "embedUrl": "https://app.eraser.io/embed?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expiresAt": 1790000000000
}

Showing the embed

Put embedUrl in an iframe's src:

<iframe src="EMBED_URL" width="100%" height="600" style="border: 0" title="Architecture diagram"></iframe>

Request body

fileId string required

ID of the file to embed, or of the file that holds the diagram or figure to embed – the part of the file's URL after /workspace/, or the id returned by List files. Private, archived, template and reference files can't be embedded.

content object[] 2 fields

What to show. Leave it out to embed the whole file, or list a diagram to embed just that diagram. Takes 1–20 items; an empty array is rejected. Several items are shown together, where they sit in the file.

type string required

"diagram" and "figure" show one diagram or figure. "canvas" shows everything on the file's canvas.

  • canvas
  • figure
  • diagram
id string

Required for "figure" and "diagram". Embedding files and diagrams explains where to find each one.

expiresIn string | integer

When the embed stops working. Either a duration from now – a whole number followed by s, m, h, d or w, such as "6h" – or an absolute time as a Unix timestamp in milliseconds. Defaults to "1d".

theme string

Select "light" or "dark" theme. Defaults to "light".

  • light
  • dark
footer string

Whether to show the footer with the Eraser logo and the file title. "auto" (default) shows it on file embeds and hides it on diagram and figure embeds. When the footer is hidden, the file title isn't sent to the viewer at all.

  • auto
  • always
  • never
titleLink boolean

Whether the file title in the footer links to the file in Eraser. Defaults to true. The link only works for viewers who can already open the file in Eraser.

Responses

200 – The embed URL

token string

The signed embed token. embedUrl already contains it, so most integrations never use it on its own.

embedUrl string

The URL to put in an iframe. Anyone who has it can view the embed until it expires.

expiresAt integer

When the embed stops working, as a Unix timestamp in milliseconds.

200 response
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "embedUrl": "https://app.eraser.io/embed?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expiresAt": 1790000000000
}

400 – Invalid request body, or a figure or diagram ID that isn't in the file

401 – Missing or invalid bearer token

403 – The token is deleted, belongs to an organization rather than a team, or lacks the embedToken:create scope

404 – No embeddable file with this ID in the token's team – it doesn't exist, belongs to another team, or is private, archived, a template or a reference

429 – More than 20,000 requests in an hour from this token. Retry after the number of seconds in the Retry-After header.

500 – Internal server error