Submissions & protection
Limits, deadlines, one response per person, spam protection and what happens after submit.
Every rule the server enforces lives in the form's config. You declare it once;
the runtime shows the right screen and the server rejects anything that breaks it.
export const config = defineForm({
title: 'Developer Meetup',
timeZone: 'Asia/Taipei',
submissions: {
maxResponses: 100,
opensAt: '2026-10-01',
closesAt: '2026-10-30T18:00',
uniqueBy: 'email',
fullMessage: 'All 100 seats are taken.',
},
success: { title: 'You’re in', message: 'See you on Oct 30.' },
});Add only what the form needs. The defaults are sensible.
Submission policy
| Option | Effect |
|---|---|
maxResponses | Closes the form once this many responses are stored. |
opensAt | Shows a "not open yet" screen until then. |
closesAt | Closes the form after then. |
closed | true stops taking responses now, whatever the dates say. |
uniqueBy | A field name ('email') allows one response per value; 'device' allows one per browser. |
closedMessage / fullMessage / duplicateMessage | Replace the built-in sentences on the closed screens. |
maxResponses and uniqueBy are checked inside the same database transaction
that stores the response, so two people submitting at once can't both get the
last seat.
Dates and time zones
opensAt and closesAt take YYYY-MM-DD (from the start of that day, or until
its end), YYYY-MM-DDTHH:mm or YYYY-MM-DDTHH:mm:ss. These are wall-clock times
read in the form's timeZone, else the project's timeZone in
open-form.config.ts, else UTC. The server's own clock zone is never used, so a
deadline means the same on your laptop and in a UTC container. A timestamp with
an offset ('2026-10-30T18:00:00+09:00') or a Date object is an exact moment
and ignores the zone.
open-form init writes your computer's time zone into open-form.config.ts, and
open-form check warns when a form uses wall-clock dates with no zone set.
One response per person
-
A field (
uniqueBy: 'email'): values are compared trimmed and case-insensitive. An empty value doesn't count. A duplicate is found on submit, andduplicateMessageshows under the Submit button.open-form checkwarns when the field is optional or conditional, since responses that leave it blank or hidden aren't limited, and when no field has that name.The value isn't verified: anyone can type someone else's email, which uses up that person's one response, and a duplicate answer tells the sender that the value has already responded. Fine for a meetup RSVP; for forms where taking part is itself sensitive, leave
uniqueByoff or confirm addresses yourself (a webhook that emails a link) before counting a response. -
'device': a cookie remembers the browser, so a returning visitor sees the "already responded" screen before filling anything. It's lightweight, not identity: a different browser or cleared storage gets through.
Protection
Every form is protected by default. Override per form with protection, or set
project-wide defaults in open-form.config.ts (each form's own keys win).
| Option | Default | Effect |
|---|---|---|
honeypot | true | A hidden field bots fill in. Those submissions get the answer a new one would and nothing is stored. |
minimumCompletionTime | '2s' | The page gets a signed timing token on load; submissions sent faster are rejected. false disables it. |
rateLimit | { max: 10, window: '10m' } | Submissions with valid answers per IP per form, counted before the Turnstile check; an IPv6 address counts as its /64. Attempts, valid or not, are capped at five times max in the same window. false disables both. |
turnstile | false | { siteKey }, or true for the server's OPEN_FORM_TURNSTILE_SITE_KEY, adds a Cloudflare Turnstile check on submit, out of sight unless Cloudflare asks the respondent to tick a box. |
Durations accept '2s', '10m', '1h', '1d' or milliseconds. Behind a reverse
proxy, set trustProxy in
open-form.config.ts so the rate limit sees each visitor's IP — without it
everyone shares the proxy's count, and one person can use it up. open-form start
also reads OPEN_FORM_TRUST_PROXY, and the Next.js route assumes one proxy; see
Production.
Cloudflare Turnstile
The built-in checks stop simple bots. For bots that switch IPs, turn on Turnstile, Cloudflare's CAPTCHA alternative. Most people never see a puzzle.
-
In the Cloudflare dashboard, add a Turnstile widget for your form's hostname. It gives you a site key (public) and a secret key.
-
Set both where the server runs:
OPEN_FORM_TURNSTILE_SITE_KEY=0x4AAAAAAA… OPEN_FORM_TURNSTILE_SECRET=0x4AAAAAAA… -
Turn it on for each form with the Cloudflare Turnstile switch in Studio's Settings, or in code, for every form or only some:
open-form.config.ts export default defineConfig({ protection: { turnstile: true }, });
The site key is public, so it can also go in code instead of
OPEN_FORM_TURNSTILE_SITE_KEY: turnstile: { siteKey: '0x4AAAAAAA…' }. The
secret key never goes in code.
One widget covers every form: the server has a single secret, so a form that
sets its own siteKey must use the same widget's. Add each hostname your forms
are served from to the widget. Embedded forms run on your Open Form host, so
the sites that embed them don't need adding.
The check runs out of sight once the respondent reaches the last step, and is
usually done before they press Submit; if it isn't, the button reads
Verifying… until it is. Only when Cloudflare wants the person to do
something, like tick a box, does the check open in a dialog, in the form's
language. Passing it sends the form; Cancel closes it and sends nothing.
Themes style the dialog with .of-turnstile and .of-turnstile-title.
The server verifies the token with Cloudflare after the answers pass
validation, so fixing a mistake doesn't need a new check. A missing or rejected
token gets 400 human_check and nothing is stored.
The server fails closed: with Turnstile on but no OPEN_FORM_TURNSTILE_SECRET
or no site key, or when Cloudflare can't be reached, responses are refused with
503 and the server logs why. open-form check warns when either key isn't
set for a form that turns it on in code. Under
open-form dev without a secret, forms use Cloudflare's always-pass
test site key and secret
in place of yours, so you can try them locally without adding localhost to
your widget. They always pass without asking, so the dialog never opens. Set
OPEN_FORM_TURNSTILE_SECRET in .env to try your real keys under
open-form dev, or to see the dialog, use Cloudflare's test pair that always
asks: site key 3x00000000000000000000FF with secret
1x0000000000000000000000000000000AA.
The widget loads from challenges.cloudflare.com. If your site sends a
Content-Security-Policy, allow that origin in script-src and frame-src.
After submit
success sets the thank-you screen's title and message, or sends people to a
redirect URL. For a custom screen, render <Success> inside the form instead.
For an event, success.calendar adds Google Calendar and .ics buttons; see
defineForm.
drafts: true keeps unfinished answers in the respondent's browser and restores
them when they come back, with a notice and a Start over button that clears
them. A draft lasts 7 days from its last change; { expires: '1d' } changes the
duration. Drafts clear on submit, and when the form is closed, full or already
answered. Studio's Preview doesn't keep them. They're off by default because on a
shared computer the next person would see the previous person's answers.
prefill: ['name', 'email'] lets a link fill those fields in:
/f/meetup#name=Ada&email=ada%40example.com. A restored draft wins over the
link for the fields it holds. See
defineForm.
Closed screens
When a form isn't taking responses, respondents get a Notice screen instead of
the questions: closed, not open yet, full, or already responded
(uniqueBy: 'device'). Preview the ones that apply in Studio under
When closed (Not open yet only while opensAt is still ahead), and design
your own with a Notice component; see Layouts.
The server pipeline
Every response goes through the same steps, in the dev server, open-form start
and the Next.js route:
POST /api/forms/:id/submissions
│
├─ request guard same origin (or embed.origins), JSON only, body size limit
├─ form unknown or unpublished → 404
├─ policy config.submissions + Studio overrides
├─ window closed / opensAt / closesAt, in the form's time zone
├─ attempts per IP per form, valid or not: five times rateLimit.max
├─ timing token signed; checks minimumCompletionTime
├─ sanitize drop hidden (<When>) and unknown fields, coerce types
├─ validate the same rules the browser ran, custom validate included
├─ rate limit per IP (IPv6: per /64) per form; valid answers count, Turnstile or not
├─ turnstile protection.turnstile → token verified with Cloudflare
├─ honeypot filled → the answer a real submission gets, nothing stored
├─ store maxResponses + uniqueBy checked in one transaction
└─ webhooks sent in the background; the respondent doesn't wait| Status | When |
|---|---|
201 | Stored. Body: { id, number }. |
400 | too_fast (sent before minimumCompletionTime), invalid_token, expired_token (the page was open over 7 days; reloading it gets a new token), human_check (Turnstile token missing or rejected), or a malformed body. |
404 | not_found: no form with that id, or the form is unpublished. |
409 | duplicate: the uniqueBy value or device already responded. |
410 | closed, not_open or full. |
422 | Validation failed. Body: { errors }, mapped back to each field's step. |
429 | Rate limit or attempt cap reached. |
503 | turnstile is on but the server can't verify tokens: no OPEN_FORM_TURNSTILE_SECRET or site key, or Cloudflare unreachable. |
Requests from another site that isn't in embed.origins get 403, oversized
bodies 413, and non-JSON bodies 415. See the
HTTP API for every endpoint.
Changing the schedule in Studio
People who run an event often need to move a deadline or raise a limit without a
developer. Studio's Settings tab can edit opensAt, closesAt,
maxResponses, closed, the timeZone they're read in, whether the form
is published, and whether it uses
Cloudflare Turnstile, and nothing else. Turnstile can
only be switched on when the server has OPEN_FORM_TURNSTILE_SITE_KEY and
OPEN_FORM_TURNSTILE_SECRET.
- Under
open-form dev, saving rewrites those keys informs/<id>/index.tsx(the switch writesprotection.turnstile). - On a deployed server, saving stores overrides in the database. They apply immediately and win over the code. Only values that differ from the code are stored, so later deploys still change everything Studio didn't touch. Use code values removes them.
If a deployed form ignores a date you changed in code, it was probably changed
in Studio. Check Settings for "Changed in Studio, not in code". Settings such
as uniqueBy can only change in code, because changing them mid-collection
would leave existing responses inconsistent.