Browse and search developers

Embed SDK

Embed SDK overview

What the Formit embed SDK does, where embed.js is served from, how it loads a form in an iframe, and how embed ids differ from form ids.

On this page
  1. Where the script is served from
  2. Embed ids are not form ids
  3. How it works
  4. Requirements and limits

The Formit embed SDK is a small JavaScript file, embed.js, that puts a published Formit form on any web page. It does not contain the form itself. It reads an embed id from your page, fetches that embed’s settings from the Formit API, and loads the live form in an iframe using one of six display modes.

Where the script is served from

In production the script is served from https://embed.formitai.com/embed.js. The snippet the app gives you adds a version query (currently ?v=7) so that copying a fresh snippet bypasses old cached copies. The file is served with Cache-Control: public, max-age=60 and Access-Control-Allow-Origin: *, so pages using an older snippet pick up script updates within about a minute.

Embed ids are not form ids

A form can have several embeds. Each embed is a saved configuration with a name, a display mode and design settings, and it has its own id. The snippet uses this embed id, not the form id. The two are different values, and pasting a form id into data-formit-embed does not work.

Embed idForm id
Where you get itThe Get the code dialog for an embed under Share > Embed in a web pageThe form’s public link and the builder
Used indata-formit-embed and the FormitEmbed.create* functionsPublic form URLs, webhook payloads (form_id)
ControlsMode, size, launcher style, URL parameter handlingThe questions and the published version

Mode and design settings are read from the server each time the page loads. When you change an embed and click Apply changes, sites already using that embed id show the new settings on their next page load, with no snippet change.

How it works

  1. The script defines window.FormitEmbed and scans the page for elements with data-formit-embed.
  2. For each one, it requests the public embed configuration from the Formit API at /api/v1/public/embeds/<embedId>. This returns the embed id, the form id, the mode, the config and the form’s public URL.
  3. It builds the iframe URL from the public URL, adding display parameters and any URL parameters you configured, then renders the iframe for the mode.
  4. Inside the iframe, the form sends postMessage events (ready, submit, close, height, question) that the SDK passes to your callbacks.

The form itself loads from Formit’s public form host (form.formitai.com), or from your organization’s branded subdomain if you have set one. The iframe is created with allow="camera; microphone; clipboard-write" and lazy loading.

Requirements and limits

  • The form must be published. For an unpublished form the configuration request returns 404 and the element shows "Unable to load form embed."
  • If your site uses a Content Security Policy, allow embed.formitai.com as a script source, the Formit API origin for connect-src, and the form host for frame-src. Check the browser network panel for the exact origins your page uses.
  • On hosts other than localhost, embed.js also loads the Microsoft Clarity tag (www.clarity.ms) on the host page for embed analytics. Account for this in your CSP and consent setup.
  • Embed errors are reported to the Formit API so the team can see failed mounts.

Ready?

Build your first AI form in minutes.

No credit card. Generate from a prompt, enable follow-ups, and publish a link or embed the same day.