Skip to content
Sign up

Install a form

Point a form on your site at its Atomicity endpoint, from plain HTML, fetch, or React.

Connect a form on your client’s site to Atomicity by posting it to the form’s endpoint. You can use a plain HTML form, which needs no JavaScript or server, or send it from your own code and get JSON back.

Before you start, you need:

  • A form in Atomicity. If you don’t have one, connect your first form.
  • The site’s domain listed in its site settings. Forms accept posts only from https:// on the site’s domains, and refuse every other website.

Copy the endpoint

Open the form and go to Install. Copy the URL under Your form’s endpoint:

https://app.atomicity.dev/f/YOUR_FORM_ID

The endpoint never changes, even if you rename the form, so you can rename forms without touching the site.

Add it to the site

Send any fields you like; there’s no fixed schema. Each field’s name becomes its label in the inbox and in notification emails.

Put the endpoint in the form’s action, with method="POST". After sending, the visitor lands on the form’s thank-you page, or on your own page if you set one.

<form action="https://app.atomicity.dev/f/YOUR_FORM_ID" method="POST">
  <label>
    Email
    <input type="email" name="email" required />
  </label>
  <label>
    Message
    <textarea name="message"></textarea>
  </label>
  <button type="submit">Send</button>
</form>

Send FormData from any JavaScript. Ask for JSON with the Accept header to get the result back instead of a redirect.

const formData = new FormData();
formData.append("name", "Jane Doe");
formData.append("email", "jane@example.com");
formData.append("message", "Hello from my site");

const response = await fetch("https://app.atomicity.dev/f/YOUR_FORM_ID", {
  method: "POST",
  headers: { Accept: "application/json" },
  body: formData,
});

const result = await response.json();
// { success: true, redirectURL: "https://..." }

Send the form from a component. The response says where to send the visitor next.

import { useState } from "react";

export function ContactForm() {
  const [email, setEmail] = useState("");
  const [message, setMessage] = useState("");

  async function handleSubmit(event) {
    event.preventDefault();

    const formData = new FormData();
    formData.append("email", email);
    formData.append("message", message);

    const response = await fetch("https://app.atomicity.dev/f/YOUR_FORM_ID", {
      method: "POST",
      headers: { Accept: "application/json" },
      body: formData,
    });

    const data = await response.json();
    if (data.success) window.location.href = data.redirectURL;
  }

  return (
    <form onSubmit={handleSubmit}>
      <input name="email" value={email} onChange={(e) => setEmail(e.target.value)} />
      <textarea name="message" value={message} onChange={(e) => setMessage(e.target.value)} />
      <button type="submit">Send</button>
    </form>
  );
}

A successful JSON request gets status 201 with success and redirectURL. redirectURL is the form’s own redirect if it has one, otherwise its hosted thank-you page, so your code can send the visitor there or record analytics first. A request also gets JSON back when it sends a JSON body with Content-Type: application/json, but a JSON body can’t carry files.

Check it’s working

Submit the form from the site, then go back to Install and select Check again under Check it’s working. Once a submission has arrived, it shows Receiving and the time of the last one.

If the form is refused

Message Cause
This website isn’t allowed to send to this form. The page’s domain isn’t on the site. Add it in site settings.
Too many submissions. Wait a minute and try again. One visitor sent more than 10 posts to this form in a minute.
This form isn’t accepting submissions right now. The site has reached its plan’s limit. See Plans and limits.
No fields were sent. The post had an empty body.

The form endpoint reference lists every response.

Type to search…

↑↓ navigate↵ selectEsc close