Skip to Content
Reference

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 pathUse
POST /f/<form-id>Send a Submission.
OPTIONS /f/<form-id>CORS preflight. Returns 204.
GET /f/<form-id>/challengeFetch the proof-of-work challenge and the Turnstile site key.
POST /f/<form-id>/uploadAsk for permission to upload one File directly.
GET /f/<form-id>/thanksThe 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 typeHow fields are read
application/x-www-form-urlencodedEach name and value pair is one field.
multipart/form-dataEach text part is one field. Each part with a file name, or with content, is a File.
application/jsonThe 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%2Fcontact

To 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.

RequestReply
Accept contains application/json, or the body is application/json200 with { "ok": true, "id": "<submission-id>", "redirect": "<url>" }
Anything else303 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.

FieldPurpose
_gotchaHoneypot. If it has any value, the Submission goes to Spam. Keep it empty and hidden from people.
_altchaThe solved proof-of-work payload. Checked when the Site requires proof of work.
cf-turnstile-responseThe Turnstile answer. Checked when the Site has Turnstile keys.
_filesA 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.

OrderCheckSpam reason
1_gotcha has a value.Honeypot
2The Site requires proof of work and _altcha is missing, wrong, expired, used before, or less than 2 seconds old.Proof of work failed
3The Site has Turnstile keys and the answer does not verify, or its hostname is not on the Site's domains.Turnstile failed
4The Site lists domains and the Origin or Referer is not on them.Blocked content
4More than 5 http:// or https:// links across all field values.Blocked content
4The 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
4Before 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: 86400

The challenge route allows GET, OPTIONS instead of POST, OPTIONS.

Status codes

StatusBody messageCause
200{ "ok": true, ... }Submission stored, JSON reply.
204noneReply to OPTIONS.
303noneSubmission stored, redirect reply.
400Empty submissionNo fields and no Files after removing reserved fields.
400Malformed bodyThe 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.
400Invalid fileThe upload request has no fileName, or sizeBytes is not a whole number of zero or more.
400Invalid 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.
400Upload 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.
404Form not foundThe Form, its Site or its Workspace does not exist or was deleted.
413Body too largeThe request body is over the request cap.
413Submission too largeToo many fields or multipart Files, or a field size or name length over the limit. See Limits.
413File too largeA File, or a sizeBytes in an upload request, is over the Workspace's upload limit.
415Unsupported content typeThe content type is not one of the three above.
429Too 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.
429Too 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.
500Submission failed, Upload failed or Challenge failedServer error.
503Could 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 type
HTTP/2 415
Unsupported content type

On this page