For AI agents: the complete documentation index is available at /docs/llms.txt, the full documentation bundle is available at /docs/llms-full.txt, and this page is available as Markdown at /docs/recipes/browser.md.

Submit from a browser

Use your form's public submission ID, not its management ID. The hosts and IDs below are placeholders.

Sandbox first

Add your site's origin, such as http://localhost:3000, to Allowed origins on the form. Sandbox reads the draft configuration. Serve the page over HTTP; opening a file directly produces an opaque null origin and fails the allowlist check.

<form action="https://forms.example.com/s/v1/sandbox/sub_REPLACE_ME" method="post">
  <label>Email <input name="email" type="email" required></label>
  <label>Message <textarea name="message" required></textarea></label>
  <button type="submit">Send</button>
</form>

The default encoding is application/x-www-form-urlencoded. With Accept: text/html, a successful navigation shows an HTML result page with status 200, or uses a configured success redirect with status 303. File uploads are rejected.

Use fetch

This example sends JSON and receives JSON. Match the fields to your form's schema.

const response = await fetch(
  'https://forms.example.com/s/v1/sandbox/sub_REPLACE_ME',
  {
    method: 'POST',
    credentials: 'omit',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email: '[email protected]', message: 'Hello' }),
  },
);
if (response.status !== 201) throw new Error(`Submission failed: ${response.status}`);
const receipt = await response.json();
console.log(receipt.receiptId);

The browser sends Origin and handles the JSON preflight. An allowed preflight returns 204. Do not set Origin yourself or embed a server API key.

Move to production

Add the HTTPS origin of your live site, such as https://www.example.com, and publish the configuration. Replace sandbox with production in either example. Production must be enabled and uses the published configuration. Production ignores HTTP allowlist entries, except the deployment's own origin when FormRoost itself runs locally over HTTP.

Origins match scheme, hostname, and port. A rule such as https://*.example.com matches subdomains, not the bare example.com. An unlisted origin returns 403. A bearer key cannot bypass this check.

These minimal examples assume Turnstile and minimum-completion timing are off. If enabled, include the reserved anti-spam fields. See configuration and publish and server submissions.