Embed a form on your website with one script tag

Updated 2026-10-30

Paste one script tag where you want the form. Set data-form to your form's slug. The script adds an iframe. It keeps the height in step with the form. It works on any page that lets you add HTML.

The snippet

html
<script src="https://aiformapi.com/embed.js" data-form="k3p9x2m7qa"></script>

Replace k3p9x2m7qa with your form's slug. The slug is the last part of the public link: in https://aiformapi.com/f/k3p9x2m7qa it is k3p9x2m7qa. The slug also comes back when you create a form.

The dashboard shows the right snippet on the form page, with a copy button. Use that one if your forms are on a different host later.

Attributes

AttributeNeededWhat it does
data-formYesThe slug of the form.
data-titleNoThe title of the iframe, which screen readers read out. The default is Form.
data-originNoThe address that serves the form, such as https://aiformapi.com. The default is the address the script was loaded from. Set it only if the script and the forms are on different hosts.

A complete page

html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Join us on Friday</title>
  </head>
  <body>
    <main style="max-width: 640px; margin: 2rem auto; padding: 0 1rem;">
      <h1>Friday dinner</h1>
      <p>Tell us if you can come.</p>

      <script src="https://aiformapi.com/embed.js" data-form="k3p9x2m7qa"></script>
    </main>
  </body>
</html>

How it behaves

  • The script inserts an iframe right after the script tag.
  • The iframe shows the form from AI Form API. It is not a copy, so changes you make to the form show up at once.
  • The height adjusts to fit the form.
  • Answers go to AI Form API. Your page does not see them.

Other ways to share a form

WayWhen to use it
The public linkEmail, chat, QR code, social posts.
The embed scriptYou want the form inside your own page.
The APIYou build your own screen. Read the schema with GET /v1/public/forms/{slug} and send answers to POST /v1/public/forms/{slug}/responses. Both paths are in openapi.json.

Let visitors use their own AI agent

Agent fill is a form setting. Open your embedded page and check how it looks before you publish. If you want the same idea on a form that you built yourself, see agent-fill.js.