Add your first form
Submitry has no form builder. You create the form in your own HTML and tell Submitry how to treat the submissions. Submitry has no special HTML attributes. The action address and the name of each field are all it needs.
The easiest way is the admin screen: add the site, create the form, and copy the HTML from its Embed tab. The commands on this page do the same from a terminal (macOS, Linux or Windows Terminal) and are useful for scripts. Replace the values in capitals.
TOKEN='YOUR_ADMIN_TOKEN'WORKER='https://submitry.your-account.workers.dev'Tell Submitry about your form fields
Section titled “Tell Submitry about your form fields”You build the form once, in your page builder. You do not have to build it a second time in Submitry. In the admin screen a new form needs only a name, and it accepts every field it receives. You then choose how Submitry learns the fields:
- Import from HTML. Copy the form from your page builder (or in the browser: right click, Inspect, Copy element), paste it into Import from HTML and press Read fields. You see a preview first. Submitry takes the field names, whether a field is required, email or number fields and maximum lengths. It also finds a hidden honeypot field and a Cloudflare Turnstile widget and offers to switch them on. Other rules (patterns, minimum and maximum values, the options of a dropdown) are listed as notes and are not checked.
- Suggest from submissions. Point your form at the action address, send a test submission, then press Suggest from submissions. Submitry looks at the last 50 submissions and proposes fields from their names, types and lengths. It never shows what was submitted. Names that start with an underscore are included too. If a field is called
_all,_form,_siteor_id, you see a warning, because mail templates fill those names themselves and cannot use your field as a placeholder.
In both cases you decide what is added. Existing field rules are only replaced when you tick Overwrite. Fields you declare are checked (for example required); fields you do not declare are still stored.
A form without declared fields accepts up to 100 fields and 256 KB per submission. Values longer than 10,000 characters are cut and file uploads are ignored.
1. Create the client website
Section titled “1. Create the client website”Each client website uses one license seat. List every address the site is served from. Visitors on other websites cannot use your form.
curl -X POST $WORKER/admin/sites \ -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' \ -d '{"name":"Acme GmbH","hostnames":["acme.de","www.acme.de"]}'The answer contains the site id. Wildcards such as *.acme.pages.dev are allowed as extra addresses, but at least one normal address is required.
2. Create the form
Section titled “2. Create the form”This example stores the message, mails the office, and sends a confirmation to the visitor.
curl -X POST $WORKER/admin/forms \ -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{ "site_id": "SITE_ID", "name": "Contact", "config": { "fields": { "name": { "required": true }, "email": { "required": true, "type": "email" }, "message": { "required": true, "maxLength": 5000 } }, "protect": { "honeypot": "website", "turnstile": true, "rateLimit": { "max": 5, "windowSeconds": 600 } }, "actions": [ { "id": "office", "type": "email", "provider": "tosend", "from": "[email protected]", "to": ["[email protected]"], "replyToField": "email", "subject": "New message from {{name}}", "text": "{{_all}}" }, { "id": "thanks", "type": "email", "provider": "tosend", "from": "[email protected]", "toField": "email", "subject": "We received your message", "text": "Thank you for contacting {{_site}}. We will reply soon." } ], "response": { "successMessage": "Thank you!", "successRedirect": "https://acme.de/thanks" } }}'The answer contains the form id and the action_url. Use that address in the next step.
3. Connect your HTML form
Section titled “3. Connect your HTML form”<form action="https://submitry.your-account.workers.dev/f/FORM_ID" method="post"> <label>Name <input name="name" required></label> <label>Email <input name="email" type="email" required></label> <label>Message <textarea name="message" required></textarea></label>
<!-- Honeypot: must match "honeypot" in the settings. Humans never see it. --> <div style="position:absolute;left:-9999px" aria-hidden="true"> <input name="website" tabindex="-1" autocomplete="off"> </div>
<!-- Turnstile --> <script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script> <div class="cf-turnstile" data-sitekey="YOUR_TURNSTILE_SITE_KEY"></div>
<button>Send</button></form>- The
nameof each input must match the field names in the settings. - The honeypot field name must match
protect.honeypot. Bots fill it in, humans do not. A filled honeypot looks like a success to the bot, and nothing is stored. - Turnstile needs a free site key from the Cloudflare dashboard under Turnstile, and the matching secret saved as a Turnstile connection in the admin screen, or as
TURNSTILE_SECRET_KEY(see Installation). The widget adds the fieldcf-turnstile-responseby itself. - Checkbox groups with the same
nameare joined with commas.
What the visitor sees
Section titled “What the visitor sees”A normal HTML form ends on one of these:
| Setting | Result |
|---|---|
successRedirect set to an address on your site |
The visitor lands on your thank-you page. |
| Nothing set | A plain page with your successMessage. |
If something goes wrong and errorRedirect is set, the visitor returns to your page with ?submitry_error=CODE added. Redirects only work to your own site addresses.
Using fetch instead
Section titled “Using fetch instead”Send Accept: application/json and you get JSON back, so you can show the message on the page without leaving it.
const res = await fetch(form.action, { method: 'POST', headers: { Accept: 'application/json' }, body: new FormData(form),})const result = await res.json() // { ok, code, message, fields? }On a validation problem the status is 422 and fields lists which field failed and why (required, invalid_email, too_long).
Looking at submissions
Section titled “Looking at submissions”# All submissions of a form (add ?format=csv for a spreadsheet)curl -H "Authorization: Bearer $TOKEN" "$WORKER/admin/forms/FORM_ID/submissions"
# One submission with the result of each email and webhookcurl -H "Authorization: Bearer $TOKEN" "$WORKER/admin/submissions/SUBMISSION_ID"
# Send a failed email againcurl -X POST -H "Authorization: Bearer $TOKEN" "$WORKER/admin/submissions/SUBMISSION_ID/replay"To change a form later, send the full settings again with PUT $WORKER/admin/forms/FORM_ID.