HTML forms
Post a plain HTML form, a fetch call or a curl request to a Form's endpoint, and control where the Visitor lands afterwards.
A plain HTML form needs no script. Set its action to the Form's endpoint and its method to POST.
<form action="https://us.insaneforms.com/f/<form-id>" method="POST">
<input name="email" type="email">
<textarea name="message"></textarea>
<button>Send</button>
</form>Copy the endpoint from the Form screen, or from the "Add it to your site" section of the Form's Settings. That section also has ready-made "HTML form", "Script tag" and "curl" snippets.
Fields
Insane Forms keeps every field the form sends, whatever its name. There is nothing to declare. A name is up to 200 characters, a value up to 100 KB, and a Submission up to 200 fields and 1 MB of text. Fields that share a name, such as checkboxes, are all kept, in order.
Do not use these names for your own inputs. The endpoint reads them and does not store them:
_gotcha, the hidden spam field. See Spam protection._altcha, the proof of work the drop-in script adds.cf-turnstile-response, the Turnstile token._files, the File references the drop-in script adds.
A Submission with no fields and no Files is rejected with 400 and "Empty submission". Field names and values must be valid text. A NUL character or a lone surrogate gets 400 and "Malformed body".
Content types
The endpoint accepts three content types:
application/x-www-form-urlencoded, the default for a plain form.multipart/form-data, needed when the form sends Files. Setenctype="multipart/form-data"on the form. See File uploads.application/json, forfetchcalls. The body must be a JSON object. An array value becomes one field per item, and a nested object is stored as a JSON string.
Any other content type gets 415 and "Unsupported content type".
What the Visitor sees
After a plain form post, the Visitor's browser receives a 303 redirect. It goes to the Form's Redirect URL, or, when none is set, to a thank-you page on the Region's hostname that reads "Thanks. Your message was sent."
The thank-you page offers a "Back to" link to the page the Visitor came from, when that page is on one of the Site's domains.
Set a Redirect URL
- Open the Form and select its Settings tab.
- Under "After submit", enter the address in "Redirect URL", for example
https://acme.test/thanks. It must start withhttps://and be at most 2048 characters. - Leave it empty to show the default thank-you page.
Send from JavaScript
Send an Accept: application/json header, or a JSON body, to get a JSON answer instead of a redirect:
const response = await fetch("https://us.insaneforms.com/f/<form-id>", {
method: "POST",
headers: { "content-type": "application/json", accept: "application/json" },
body: JSON.stringify({ email: "ada@example.com", message: "Hello" }),
});
const result = await response.json();
// { ok: true, id: "<submission-id>", redirect: "https://acme.test/thanks" }A rejection returns { "ok": false, "error": "..." } with the status code. The endpoint allows requests from any origin and answers OPTIONS preflight requests with 204.
With curl:
curl -X POST https://us.insaneforms.com/f/<form-id> \
-H "accept: application/json" \
-d "email=ada@example.com"Status codes
| Status | Meaning |
|---|---|
303 | Accepted. The browser is redirected. |
200 | Accepted. JSON answer with ok: true. |
400 | Empty or malformed body. |
404 | The Form does not exist or was deleted. |
413 | The body, a field or a File is too large. |
415 | Unsupported content type. |
429 | Too many Submissions from one address. |
A Submission that is accepted but judged Spam gets the same success answer as any other, so a bot learns nothing. See Form endpoint for every field, header and message, and Limits for sizes and rates.
Check the result
Open the Form's Inbox tab. The Submission is there, marked unread, unless a spam check moved it to the Spam tab.