# Connect a form to FormKeep

Instructions for a coding agent (Claude Code, Cursor, Lovable, v0, Bolt or
similar). FormKeep is a form backend: a form posts to a FormKeep URL, and
FormKeep stores the submission, filters spam and emails the owner. No server
code, no API key.

## 1. Get the form URL

The form URL looks like `https://formkeep.com/f/<form-token>`. Do not invent a
token, reuse one from an example or guess one. Ask the user for it.

- No account yet: the user signs up at https://formkeep.com/sign_up and creates a form. The URL is on the form's Setup tab.
- Has an account: the same Setup tab shows it.
- If FormKeep is connected to you over MCP (`https://formkeep.com/mcp`, see [connecting an AI agent](https://formkeep.com/agents.md)), call `list_forms` to find the form, `get_form` for its endpoint URL and a starter HTML snippet, or `create_form` for a new one (the user must have allowed form changes when connecting).

## 2. Plain HTML form

Set the form's `action` to the URL and `method` to `POST`. Every input's
`name` becomes a field of the submission.

```html
<form action="https://formkeep.com/f/YOUR-TOKEN" method="POST">
  <input name="email" type="email" required>
  <textarea name="message"></textarea>
  <button type="submit">Send</button>
</form>
```

After a plain post the browser is redirected: to the form's own redirect URL
if the owner set one, else to a thank-you page FormKeep hosts at `/thanks`.

## 3. JavaScript (React, Next.js, any client)

Post from the browser with `fetch`. FormKeep allows cross-origin requests from
any site, so there is no server route to write and no API key to hold.

```js
const response = await fetch("https://formkeep.com/f/YOUR-TOKEN", {
  method: "POST",
  headers: { Accept: "application/json" },
  body: new FormData(event.target),
});
if (!response.ok) {
  // show an error; the submission was not stored
}
```

With `Accept: application/json` there is no redirect. A stored submission
answers `200` with the JSON body `null`. Do not set `Content-Type` yourself
with `FormData`: the browser adds the multipart boundary.

## 4. File uploads

Send `multipart/form-data` with a file input. With `FormData` that is automatic.
In HTML add `enctype="multipart/form-data"` to the `<form>`.

```html
<form action="https://formkeep.com/f/YOUR-TOKEN" method="POST" enctype="multipart/form-data">
  <input name="email" type="email">
  <input name="resume" type="file">
  <button type="submit">Send</button>
</form>
```

Each file may be up to 10 MB and a submission up to 50 files; the rest are
dropped. Whether attachments are kept depends on the account's plan, see
[pricing](https://formkeep.com/features/pricing).

## 5. Test it

Send one submission and confirm it arrived. This one is a real submission: it
counts toward the plan and emails the owner.

```bash
curl -i -X POST https://formkeep.com/f/YOUR-TOKEN \
  -H "Accept: application/json" \
  -H "User-Agent: my-agent/1.0" \
  -F "email=test@example.com" \
  -F "message=Test from my coding agent"
```

- `200` and a body of `null`: stored.
- `404`: the token is wrong. Ask the user to check the form's Setup tab.
- `403` with `{"error":"This form is not accepting submissions."}`: the form was switched off.

Always send a `User-Agent`; requests without one, or with a bare default such
as `curl`'s, can be blocked before they reach FormKeep.

Then open the form's Submissions tab in the dashboard (https://formkeep.com/sign_in) or
the owner's inbox: the test message is there.
Connected over MCP, `list_submissions` shows it (Free accounts, and forms with API access).

## Do not

- Do not put an API key or API token in client code. Posting to a form needs none. The read API token is a secret for servers only.
- Do not invent field names with a special meaning. These are reserved: `honey` (a filled-in value marks the submission as spam while the form's spam checking is on, the default, so never use it for real data), `_redirect_url`, `_embedded`, `_attachment_fields`, `utf8`, `referer`, `user_ip`, `user_agent`, `attachments_attributes`, `g-recaptcha-response`, `cf-turnstile-response` and `h-captcha-response`. Anything else is stored as the submission's data. Use `email` for the submitter's email address.
- Do not guess the form token, and do not post to a URL you made up.
- Do not add a server route to proxy the post. It is not needed.

More: [API documentation](https://formkeep.com/docs/api.md).
