Skip to main content

Embed an asset in a web page

Get the embed that plays an asset or a collection with POST /v1/assets/{asset_id}/embed, then put it in your pages: the loader script with its id, or embed_url in an iframe — with the player's options, and the organization's say over who may watch.

A web page plays an asset or a collection through its embed: an identifier the Videas player opens, which the organization manages in Videas. The API answers it:

  • POST /v1/assets/{asset_id}/embed — an asset’s: a video, a sound, a picture, a document or a video hosted elsewhere;
  • POST /v1/collections/{collection_id}/embed — a collection’s, which plays its items one after the other.

The key needs Embed the library through the API (assets.library.embed). To find what to embed, it also needs Read the library through the API (assets.library.read): an integration that embeds is created with both.

Get the embed

curl -X POST https://api.videas.com/v1/assets/0192a6b2-4f1a-7b90-8e0d-51c3a7f2b046/embed \
  -H "Authorization: Bearer $VIDEAS_API_KEY"
{
  "id": "0192a6f0-6a7b-7c8d-9e0f-1a2b3c4d5e6f",
  "asset_id": "0192a6b2-4f1a-7b90-8e0d-51c3a7f2b046",
  "collection_id": null,
  "access": "public",
  "active": true,
  "embed_url": "https://app.videas.com/embed/0192a6f0-6a7b-7c8d-9e0f-1a2b3c4d5e6f/",
  "script_url": "https://app.videas.com/embed.js",
  "created_at": "2026-09-26T09:40:18Z"
}

The answer is the asset’s default embed. It is a 201 when the call has just created it — public and active — and a 200 when the asset already had one. The call is idempotent: sent again, it answers the same embed, so a request whose answer was lost is simply sent again.

Field
id The embed’s identifier — what the loader script takes. Stable for as long as the organization keeps this embed: store it with your page.
asset_id The asset it plays, or null when it plays a collection.
collection_id The collection it plays, or null when it plays an asset.
access Who the embed itself opens to: public, domain_restricted or token_required — below.
active Whether it plays today: false when the organization switched it off or its expiry has passed.
embed_url The address of the page that plays it, to put in an <iframe>.
script_url The address of the loader script, which draws the player where it stands.
created_at When the embed was created (RFC 3339).

embed_url and script_url are on the organization’s own Videas address, and are null only while it has none yet.

The same call in Node.js (18 or later) and in Python:

const response = await fetch(
  `https://api.videas.com/v1/assets/${assetId}/embed`,
  {
    method: 'POST',
    headers: { Authorization: `Bearer ${process.env.VIDEAS_API_KEY}` },
  },
)
const embed = await response.json()
if (!response.ok) throw new Error(`${embed.code}: ${embed.message}`)
import os

import requests

response = requests.post(
    f"https://api.videas.com/v1/assets/{asset_id}/embed",
    headers={"Authorization": f"Bearer {os.environ['VIDEAS_API_KEY']}"},
)
response.raise_for_status()
embed = response.json()

What can be embedded is what a player renders: an asset of type video, audio, image, document or third_party, and a collection. An archive, a file, subtitles or other is refused with a 400. A collection goes through POST /v1/collections/{collection_id}/embed, never the asset route, and a folder is never embedded: either is a 404 on the asset route, as an asset of another organization is.

Put it in a page

The loader script

<script src="https://app.videas.com/embed.js"
        data-embed="0192a6f0-6a7b-7c8d-9e0f-1a2b3c4d5e6f" async></script>

src is the embed’s script_url and data-embed its id. The script puts the player where it stands — the full width of its container, 400 pixels high, unless told otherwise. A page may hold several players, each with its own tag.

The player’s options are data-* attributes on the same tag:

Attribute
data-width, data-height Its size, in any CSS unit; a bare number is pixels.
data-aspect-ratio Its shape, as a CSS ratio — 16 / 9 — instead of a height: it takes the container’s width and keeps that shape.
data-auto-play="1", data-muted="1", data-loop="1" Start playing on load — most browsers only allow it muted —, start muted, play again from the start at the end.
data-start-at="90" Start at this many seconds.
data-controls="0" Hide the controls.
data-primary-color="0055ff" The player’s accent color, without its #.
data-start-index="2" For a collection, the item it opens on, counted from 0.
data-embed-mode="popover" Show a button instead of the player, which opens it over the page — data-trigger-label names the button.

An iframe

<iframe src="https://app.videas.com/embed/0192a6f0-6a7b-7c8d-9e0f-1a2b3c4d5e6f/"
        width="640" height="360" style="border:0" allowfullscreen
        referrerpolicy="no-referrer-when-downgrade"></iframe>

src is the embed’s embed_url. The same options are query parameters, in snake_case: ?auto_play=1&muted=1&start_at=90. Add allow="autoplay" to the tag when you ask for auto_play. Keep referrerpolicy: it lets Videas’ statistics name the page the video was watched on.

The organization keeps control

The embed is the organization’s. From Videas, it may restrict it to some sites, put it behind a credential, switch it off or give it an expiry — and the API answers the embed as it stands, never changes it and never makes a second one beside it. access and active say what a visitor meets:

access A visitor of your page
public watches it, on any site.
domain_restricted watches it only on the sites the organization listed for it; elsewhere the player refuses to show.
token_required watches it only with a credential the organization handed you, in data-token="…" on the script or ?token=… on the iframe.
  • A list of sites the organization set for all its embeds, or for those of one workspace, applies as well, and access does not report it: a page on another site is refused even with public.
  • The list of access values may grow: read a value you do not know as closed to your visitors.
  • A credential is readable in your page’s source: it says which partner a page belongs to, and the organization revokes it per partner. It does not hide the video from someone who copies it.
  • An embed switched off keeps its id: the player shows nothing playable, and plays again the day the organization switches it back on, with no change to your page.

Keep it in step

Store the embed’s id with your page, and ask again when the page is saved or edited, not on every view: the answer moves only when the organization deletes the embed or makes another one the default, and then the call answers the new one — created afresh if the organization deleted the last.

Status When
200 The asset already had a default embed; this is it.
201 It had none; this one was just created.
400 An asset of a type no player renders, or a query parameter: the endpoint takes none.
403 The key does not carry assets.library.embed.
404 No such asset — or collection — in the organization.
409 The organization made another embed the default at the same moment: send the request again.

Choose what to embed

A page builder lets a person pick the asset to embed. The library’s read gives everything such a picker needs — Read the library details each:

  • GET /v1/assets?status=ready — only what plays, and search= the words typed in a search box;
  • GET /v1/workspaces and GET /v1/workspaces/{workspace_id}/folders — the tree to browse, and ?parent= a folder’s assets;
  • GET /v1/collections — the collections, each embedded by its own route.

Next steps