Skip to content

API quickstart

Render a video from HTML with the REST API, wait for it, and download it.

1. Create an API key

In the dashboard, open API key and create a key. It starts with ms_ and is shown once. Keep it on your server: anyone with the key can spend your workspace’s credits.

export MOSIO_API_KEY=ms_...

2. Write the video

A Mosio video is one HTML document, a Hyperframes composition: a root element that sets the size and length, and one paused GSAP timeline. Save this as promo.html:

<!doctype html>
<html lang="id">
  <head>
    <meta charset="UTF-8" />
    <script src="vendor/gsap.min.js"></script>
    <style>
      @font-face { font-family: "Bebas Neue"; src: url("vendor/BebasNeue-400.woff2"); }
      html, body { width: 1080px; height: 1920px; margin: 0; overflow: hidden; background: #17110d; }
      #root { position: relative; width: 100%; height: 100%; color: #fff4e6; text-align: center; }
      #name { position: absolute; left: 80px; right: 80px; top: 640px; font: 200px/1 "Bebas Neue", sans-serif; }
      #price { position: absolute; left: 80px; right: 80px; top: 1100px; font: 160px/1 "Bebas Neue", sans-serif; color: #ff6b2c; }
    </style>
  </head>
  <body>
    <div id="root" data-composition-id="main" data-start="0" data-duration="8"
         data-width="1080" data-height="1920" data-fps="30">
      <div id="name">Es Kopi Gula Aren</div>
      <div id="price">Rp18.000</div>
    </div>
    <script>
      const tl = gsap.timeline({ paused: true });
      tl.from("#name", { yPercent: 40, opacity: 0, duration: 0.8, ease: "power3.out" }, 0.3)
        .from("#price", { scale: 0.6, opacity: 0, duration: 0.6, ease: "back.out(1.6)" }, 1.4);
      window.__timelines = window.__timelines || {};
      window.__timelines["main"] = tl;
    </script>
  </body>
</html>

Design your own video has the rules, the fonts and assets you can load, your own photos and footage, and the brand’s logo.

3. Render it

Send the HTML to POST /v1/compositions (here with jq, which turns the file into a JSON string):

jq -n --rawfile html promo.html \
  '{html: $html, title: "Es Kopi Gula Aren", idempotency_key: "kopi-senja-001"}' |
curl https://app.mosio.me/v1/compositions \
  -H "x-api-key: $MOSIO_API_KEY" \
  -H "content-type: application/json" \
  -d @-

The response comes back straight away, with status: "queued":

{
  "id": "vid_6f1c2b9e-0c1a-4b7e-9d0e-2f3a4b5c6d7e",
  "status": "queued",
  "recipe": "composition",
  "project_id": "prj_3f9a0c1d2e4b5a69",
  "created_at": "2026-10-20T10:15:01.105Z",
  "finished_at": null,
  "duration_seconds": null,
  "output_url": null,
  "error": null
}

Mosio checks the HTML before it spends anything. A composition that cannot render yet comes back as invalid_composition, with details.problems listing what to fix. The video costs credits equal to its data-duration, here 8.

Sending the same idempotency_key again returns the same video instead of rendering a second one. Reusing a key with a different body is refused with 409.

4. Wait for it

Poll every few seconds until status is done (or failed):

curl https://app.mosio.me/v1/videos/vid_6f1c2b9e-0c1a-4b7e-9d0e-2f3a4b5c6d7e \
  -H "x-api-key: $MOSIO_API_KEY"

A 15-second video usually finishes in under a minute.

5. Download

When status is done, output_url is a short-lived link to the MP4. Download it right away, or fetch the video again later for a fresh link.

curl -L -o video.mp4 "<output_url>"

Next

  • The video also opens in the dashboard’s Studio, at /videos/<project_id>. To render a new version of the same video, send project_id with the new html; project_id alone renders it as it is now in Studio.
  • Every endpoint, field, and error: REST API.
Navigation

Type to search…

↑↓ navigate↵ selectEsc close