# Form messages

> Receive email notifications when visitors submit a message form on your published document, with built-in spam protection and rate limits.

Source: https://hyperclay.com/docs/form-messages/

Visitors can submit a contact or feedback form on your published document without you running a custom backend. To add a message form (`message-form`) to your document's markup, use the [ClayJS message plugin](https://clayjs.com/docs/plugins/message/).

## Where messages arrive

When a visitor submits a form carrying `message-form`, the page serializes the form fields and posts them to `/_/message` on Hyperclay.

Hyperclay looks up the owner of the document and sends an email notification to the owner's account email address:

- **From address**: `_@hyperclay.com`
- **Subject**: `message from <document name> (hyperclay site)`
- **Body**: One `**field**: value` line for each submitted form field, followed by a `site` link to the document's address.

On the page itself, a successful submission displays the text configured in `message-form` (or `Sent` if none is specified) and resets the form.

> [!NOTE]
> Form messages are delivered to your email inbox. They do not appear in the workspace **Inbox**, which only lists document [comments, replies, and mentions](https://hyperclay.com/docs/presence-and-comments/). In addition, when the form has an `email` field holding a valid address, the notification sets `Reply-To` to that address, so you can reply to the visitor straight from your inbox. Without a valid `email` field the header is left off, and you copy the visitor's address out of the message body instead.

If you want form submissions to create browsable items inside a workspace folder instead of sending email notifications, use [Collections](https://hyperclay.com/docs/collections/).

## Notify me form

A notify me form is a message form with one extra job: it collects an address you can reply to. Name the email field `email` and give it `type="email"`, so Hyperclay receives a valid address and sets `Reply-To` on the notification it sends you. Mark the form with a `message-form` attribute, whose value is the text the visitor sees after sending, so the ClayJS message plugin takes the form over on submit.

```html
<form message-form="Thanks, I will let you know when it launches.">
  <input name="email" type="email" required placeholder="you@example.com">
  <textarea name="note" placeholder="A note for me (optional)"></textarea>
  <input name="item" type="hidden" value="swarmation">
  <button>Notify me</button>
</form>
```

The hidden `item` field names the thing the visitor asked about, and it arrives as one more line in the notification, so a page with several projects can tell them apart without a separate form for each. Any other field you add, such as the optional `note` above, is emailed as its own line too.

Each submission arrives as an ordinary message: one `**field**: value` line per field, a `site` link, and a `Reply-To` that is the visitor's own address. Click reply in your mail app and your answer goes to them rather than to `_@hyperclay.com`.

The plan requirements, rate limits and spam checks below apply to a notify me form unchanged. To show which items visitors liked alongside it, see [Likes](https://hyperclay.com/docs/likes/).

## Plan requirements

Any anonymous visitor can submit a message form on a public document as long as the document owner has an active paid plan (**Personal** or **Maker**).

If the document owner's subscription has lapsed, Hyperclay refuses submissions with the message `This form isn't accepting messages right now.` and sends no email.

## Spam protection and rate limits

Hyperclay screens every submission for bot activity and enforces rate limits before sending an email:

- **One-time form token**: When a visitor focuses or types in a form, the page requests a single-use token from `GET /_/form-token` (valid for 2 hours). If a token expires before the visitor submits, the browser fetches a fresh token and retries once automatically. Requests sent without JavaScript enabled are refused with `This message couldn't be sent: the form needs JavaScript turned on.`, and replayed or invalid scripted requests are refused with `This message couldn't be sent. Please try again.`.
- **Honeypot field**: If an automated bot fills the hidden `contact-me-by-fax-only` field, Hyperclay returns a normal success response to the bot and silently discards the message without emailing you. Internal verification fields (`formToken`, `formSignals`, `behaviorData`, and honeypots) are stripped before the message is emailed.
- **Per-connection limit**: A single IP connection can send at most 10 form submissions per hour. Extra attempts receive `Too many messages from this connection. Try again later.`.
- **Per-document limit**: A single document accepts at most 60 messages per hour. Extra attempts receive `This page has received too many messages. Try again later.`. This 60-message limit is counted after the bot check, so spam bursts cannot lock real visitors out of your form.
