Form endpoint
The URL a Form receives Submissions at. Methods, content types, fields, reserved fields, redirects, status codes and errors.
Every Form receives Submissions at one URL on its Workspace's Region host. For a Form in the US Region it is https://us.insaneforms.com/f/<form-id>. You can copy the address from the Form's page in the app.
A Form declares no fields. The endpoint stores every field it receives, in the order received.
Methods
| Method and path | Use |
|---|---|
POST /f/<form-id> | Send a Submission. |
OPTIONS /f/<form-id> | CORS preflight. Returns 204. |
GET /f/<form-id>/challenge | Fetch the proof-of-work challenge and the Turnstile site key. |
POST /f/<form-id>/upload | Ask for permission to upload one File directly. |
GET /f/<form-id>/thanks | The default thank-you page. |
Send a Submission
POST /f/<form-id> accepts three content types. The endpoint reads the media type before any parameters, so application/json; charset=utf-8 works.
| Content type | How fields are read |
|---|---|
application/x-www-form-urlencoded | Each name and value pair is one field. |
multipart/form-data | Each text part is one field. Each part with a file name, or with content, is a File. |
application/json | The body must be a JSON object. Each key is a field. |
A request with another content type, or none, gets 415.
In a JSON body, an array becomes one field per item under the same name. A nested object becomes a field whose value is its JSON text. Any other value becomes a field with its string form.
curl -X POST "https://us.insaneforms.com/f/<form-id>" \
-H "content-type: application/json" \
-H "accept: application/json" \
-H "origin: https://example.com" \
-d '{"name":"Ada Lovelace","email":"ada@example.com","topics":["pricing","support"]}'{
"ok": true,
"id": "<submission-id>",
"redirect": "https://us.insaneforms.com/f/<form-id>/thanks?back=https%3A%2F%2Fexample.com%2Fcontact"
}A browser form post gets a redirect instead of JSON:
curl -i -X POST "https://us.insaneforms.com/f/<form-id>" \
-H "origin: https://example.com" \
-H "referer: https://example.com/contact" \
--data-urlencode "name=Ada Lovelace" \
--data-urlencode "email=ada@example.com"HTTP/2 303
location: https://us.insaneforms.com/f/<form-id>/thanks?back=https%3A%2F%2Fexample.com%2FcontactTo send a File in the same request, use multipart/form-data. The whole request body, Files included, must stay under the request cap in Limits. For larger Files, upload each File first (see Upload a File directly).
curl -X POST "https://us.insaneforms.com/f/<form-id>" \
-H "accept: application/json" \
-H "origin: https://example.com" \
-F "name=Ada Lovelace" \
-F "resume=@resume.pdf"A request with no fields and no Files gets 400. Reserved fields do not count as fields.
Origin and Referer
If the Site lists domains, the endpoint checks the Origin header, or the Referer header when there is no Origin. The host must equal a listed domain or be a subdomain of one, and the scheme must be http or https. A request with neither header fails the check. A request that fails the check is not refused. It is stored as Spam and the caller receives the normal success reply. Browsers set these headers on their own. When you test with curl against a Site that lists domains, set Origin yourself, as the samples above do.
Response to the caller
The reply is the same whether the Submission lands in the Inbox or in Spam. The caller cannot tell the two apart.
| Request | Reply |
|---|---|
Accept contains application/json, or the body is application/json | 200 with { "ok": true, "id": "<submission-id>", "redirect": "<url>" } |
| Anything else | 303 with a Location header set to the redirect URL |
Redirect URL
If the Form has a redirect URL, that is the redirect. It is an HTTPS address of at most 2048 characters, without a user name or password, set in the Form's settings.
Otherwise the redirect is the default thank-you page, https://us.insaneforms.com/f/<form-id>/thanks. When the Referer header is on one of the Site's domains, the page gets a back query parameter and shows a link back to that page. The thank-you page checks back again against the Site's domains, so a forged value shows no link.
Reserved fields
These four field names are read by the endpoint and are never stored in the Submission.
| Field | Purpose |
|---|---|
_gotcha | Honeypot. If it has any value, the Submission goes to Spam. Keep it empty and hidden from people. |
_altcha | The solved proof-of-work payload. Checked when the Site requires proof of work. |
cf-turnstile-response | The Turnstile answer. Checked when the Site has Turnstile keys. |
_files | A JSON array of Files already uploaded directly, each { "fieldName": "<field-name>", "pathname": "<pathname>" }. |
See Spam protection for how to set each one up.
Checks that send a Submission to Spam
The first check that fails decides the reason, in this order.
| Order | Check | Spam reason |
|---|---|---|
| 1 | _gotcha has a value. | Honeypot |
| 2 | The Site requires proof of work and _altcha is missing, wrong, expired, used before, or less than 2 seconds old. | Proof of work failed |
| 3 | The Site has Turnstile keys and the answer does not verify, or its hostname is not on the Site's domains. | Turnstile failed |
| 4 | The Site lists domains and the Origin or Referer is not on them. | Blocked content |
| 4 | More than 5 http:// or https:// links across all field values. | Blocked content |
| 4 | The same content arrived on this Form in the last 24 hours and is in the Inbox, or is in Spam because a person put it there. | Blocked content |
| 4 | Before this one, the same sender had 10 or more Submissions stored on this Form in the last 10 minutes. | Blocked content |
The duplicate check compares field names and values in order after trimming and lowercasing. It skips Submissions with no fields to compare. A Submission in Spam produces no Deliveries.
Challenge
GET /f/<form-id>/challenge returns JSON with Cache-Control: no-store.
curl "https://us.insaneforms.com/f/<form-id>/challenge"{
"challenge": null,
"expiresInMs": 600000,
"minProofAgeMs": 2000,
"turnstileSiteKey": null
}challenge is null unless the Site requires proof of work. A challenge is valid for 10 minutes and can be used once. expiresInMs is the time left before the challenge expires, in milliseconds. It is 600000 when challenge is null. A solution counts only after minProofAgeMs has passed since the challenge was issued. turnstileSiteKey is the Site's Turnstile site key, or null.
Upload a File directly
A plain form post carries Files only up to the request cap. To upload a larger File, up to the Workspace's upload limit, the Visitor's browser uploads it straight to file storage and then names it in _files. The drop-in script and @insane-forms/core do this for you (see Core package). This section describes the first step.
POST /f/<form-id>/upload takes a JSON body:
curl -X POST "https://us.insaneforms.com/f/<form-id>/upload" \
-H "content-type: application/json" \
-d '{"fileName":"resume.pdf","sizeBytes":2457600}'{
"pathname": "files/<workspace-id>/<form-id>/<random-id>/resume.pdf",
"token": "<upload-credential>"
}The token is a short-lived credential for file storage. It lasts 10 minutes and allows one File of at most sizeBytes. After the upload, include the pathname in the Submission:
{
"name": "Ada Lovelace",
"_files": [
{
"fieldName": "resume",
"pathname": "files/<workspace-id>/<form-id>/<random-id>/resume.pdf"
}
]
}The Submission must arrive within one hour of the upload, or it gets 400 with Upload expired. Please upload the file again. The same reply comes when the pathname is already attached to a Submission, because each upload can be used once.
A pathname that is not one of this Form's uploads, or that appears twice in one request, gets 400 with Invalid file references. A File over the Workspace's upload limit gets 413 with File too large.
The Submission is stored only if every File in it is accepted. When one File fails, the request fails and nothing is stored.
CORS
Every endpoint reply carries these headers, so browsers on any site can post.
access-control-allow-origin: *
access-control-allow-methods: POST, OPTIONS
access-control-allow-headers: content-type, accept
access-control-max-age: 86400The challenge route allows GET, OPTIONS instead of POST, OPTIONS.
Status codes
| Status | Body message | Cause |
|---|---|---|
200 | { "ok": true, ... } | Submission stored, JSON reply. |
204 | none | Reply to OPTIONS. |
303 | none | Submission stored, redirect reply. |
400 | Empty submission | No fields and no Files after removing reserved fields. |
400 | Malformed body | The body is not valid for its content type, or JSON that is not an object. Also a NUL character or a lone surrogate in a field name or value, or a NUL character in a File's field name, file name or content type. |
400 | Invalid file | The upload request has no fileName, or sizeBytes is not a whole number of zero or more. |
400 | Invalid file references | _files is not a JSON array of { fieldName, pathname }, lists more Files than the Submission may hold, names a pathname that is not this Form's or appears twice, or holds a NUL character. |
400 | Upload expired. Please upload the file again. | A File in _files was uploaded more than one hour ago, no longer exists, or is already attached to a Submission. |
404 | Form not found | The Form, its Site or its Workspace does not exist or was deleted. |
413 | Body too large | The request body is over the request cap. |
413 | Submission too large | Too many fields or multipart Files, or a field size or name length over the limit. See Limits. |
413 | File too large | A File, or a sizeBytes in an upload request, is over the Workspace's upload limit. |
415 | Unsupported content type | The content type is not one of the three above. |
429 | Too many submissions. Try again in a few minutes. | This sender already has 50 or more Submissions stored on this Form from the last 10 minutes. |
429 | Too many uploads. Try again in a few minutes. | An upload budget is used up, by direct uploads or by Files in a plain form post. See Limits. |
500 | Submission failed, Upload failed or Challenge failed | Server error. |
503 | Could not check the uploaded file. Please try again. | File storage could not be reached to check an uploaded File. |
Errors
An error reply has the same CORS headers as a success. If the request's Accept or Content-Type header contains application/json, the body is JSON:
{ "ok": false, "error": "Submission too large" }Otherwise the body is the message as plain text.
curl -i -X POST "https://us.insaneforms.com/f/<form-id>" \
-H "content-type: text/plain" \
-d "hello"HTTP/2 415
Unsupported content typeHTTP/2 415
Unsupported content type