Add forms to HTML
A SendForm endpoint is a URL you POST to, so a plain HTML form works with no JavaScript at all. This page shows the standard setup, the AJAX variant, and what happens to fields you add.
Standard HTML form
Replace the action URL with your own endpoint and the form is live on any static host:
<form action="https://sendform.net/!a8Kz3mXq12" method="POST">
<input name="name" placeholder="Name">
<input type="email" name="email" placeholder="Email" required>
<textarea name="message" required></textarea>
<button type="submit">Send message</button>
</form>
Both application/x-www-form-urlencoded (what a browser sends) and JSON bodies are accepted.
Extra fields
email and message are the two fields SendForm treats specially - both are required. Every other named input rides along as an extra field and is stored with the submission, shown in the dashboard, included in the notification email, and sent to your webhooks.
The limits: at most 25 extra fields per submission, keys truncated at 64 characters and values at 3000. _hp, _ts and antibot are reserved for the spam controls and are never stored as fields.
Redirect after submit
Set a redirect URL on the form and a successful browser submission sends the visitor to your own thank-you page instead of SendForm's confirmation page. It must be an http/https URL. A submission that asked for JSON never redirects.
Submit with fetch (AJAX)
Send Accept: application/json to get a JSON envelope back and keep the visitor on the page:
const res = await fetch("https://sendform.net/!a8Kz3mXq12", {
method: "POST",
headers: { "Accept": "application/json" },
body: new FormData(form),
});
const data = await res.json();
if (data.success) {
// { success: true, form_id: "a8Kz3mXq12", received: { ... } }
} else {
// data.error is a machine-readable code - see the errors page
}
The endpoint answers CORS preflights and stamps CORS headers on every response, so a cross-origin fetch() from any site can read the result. Note that failures come back with HTTP 200 and an error key rather than a 4xx status - always branch on the payload, not the status code. See Errors for the full list.
Testing an endpoint
Opening the endpoint in a browser (a GET) renders a small test console for the form, so you can send a submission before wiring up your site. curl works too:
curl -H "Accept: application/json" \
-d "email=you@example.com" \
-d "message=Hello from curl" \
https://sendform.net/!a8Kz3mXq12
Heads up: use your own endpoint. a8Kz3mXq12 above is only an example.