---
title: "Install a form"
description: "Point a form on your site at its Atomicity endpoint, from plain HTML, fetch, or React."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.atomicity.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Install a form

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](https://docs.atomicity.dev/get-started/connect-your-first-form/).
- The site's domain listed in its [site settings](https://docs.atomicity.dev/workspace/sites-and-domains/). 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**:

```txt
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.

### HTML

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](https://docs.atomicity.dev/forms/thank-you/) if you set one.

```html
<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>
```

### fetch

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

```js
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://..." }
```

### React

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

```jsx
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.

> **Testing locally**
>
> To post from your machine while you build, turn on **Allow localhost** in the site's settings. Submissions from `localhost`, and from staging or preview addresses, get a **TEST** tag and don't count toward your plan.

## 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](https://docs.atomicity.dev/workspace/sites-and-domains/). |
| 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](https://docs.atomicity.dev/billing/plans/). |
| No fields were sent. | The post had an empty body. |

The [form endpoint reference](https://docs.atomicity.dev/reference/form-endpoint/) lists every response.

## Related

- [File uploads](https://docs.atomicity.dev/forms/file-uploads/)
- [After submit](https://docs.atomicity.dev/forms/thank-you/)
- [Honeypot and CAPTCHA](https://docs.atomicity.dev/forms/honeypot-and-captcha/)

Source: https://docs.atomicity.dev/forms/install/index.mdx
