# Plain HTML form

## What this is

A contact page that posts straight from the browser to ContactUsIQ with a normal `<form>`. No JavaScript is required for the submit; Cloudflare Turnstile is added with one script tag and one `div`. On success the visitor is redirected to `thanks.html`.

Files: [`index.html`](index.html), [`thanks.html`](thanks.html).

This sample uses the placeholder form id `au_xxxxxxx` and the Turnstile site key placeholder `0x4AAAAAAA_PLACEHOLDER`. Replace both.

## Prerequisites

- A ContactUsIQ workspace with a verified domain (the domain the page will be served from).
- A published form on that domain. Its public id (`au_xxxxxxx`) and the Turnstile site key are on the form's Snippet screen.
- A place to host two static HTML files over HTTPS on the verified domain.

## Steps

1. Copy `index.html` and `thanks.html` into your site.
2. In `index.html`, replace `au_xxxxxxx` in the form `action` with your form id.
3. Replace `0x4AAAAAAA_PLACEHOLDER` in the `data-sitekey` attribute with your Turnstile site key. If you do not want Turnstile, delete the `div.cf-turnstile` and the Turnstile `<script>` tag; the form still works at stricter spam heuristics.
4. Replace the `_redirect` value with the absolute URL of your `thanks.html` (for example `https://www.example.com/thanks.html`). Remove the input to get ContactUsIQ's hosted thank-you page instead.
5. Deploy and open the page on the verified domain.

## The code

- `index.html`: the form. `action` is the intake URL, `method` is `POST`, the encoding is the browser default (`application/x-www-form-urlencoded`). Field names `name`, `email`, `message` are free-form; add any others you need (`phone`, `company`, ...). The `_honeypot` input is hidden with CSS rather than `type="hidden"` so bots that fill every text field fill it too.
- `thanks.html`: the page the visitor lands on after the `303` redirect.

## How to test

1. Open the page on the verified domain, fill the three fields, complete Turnstile, click Send.
2. Expect a redirect (`303 See Other`) to `thanks.html`. In the browser's Network tab the POST to `api.contactusiq.com/s/au_xxxxxxx` shows status `303` and a `Location` header.
3. Without `_redirect`, expect `200` with the hosted thank-you page.
4. The submission appears in the ContactUsIQ inbox with the visitor's IP, the page URL and the Turnstile outcome.

## Troubleshooting

- **Submission "succeeds" (200) but nothing arrives in the inbox.** Origin or Referer mismatch: the page is served from a domain that is not verified on the form (opening the file locally or from `localhost` counts). Spam and origin rejections return `200` on purpose. Serve the page from the verified domain, or enable "any origin" on the form for testing.
- **Turnstile shows an error or never completes.** The site key is wrong, or the domain is not listed on the Turnstile widget in Cloudflare. Check both; the ContactUsIQ snippet screen shows the key configured for your form.
- **429 Too Many Requests.** Per IP: 5 submissions per form per 10 minutes. Wait for the number of seconds in `Retry-After` and try again.
- **400.** A required field on the form definition is missing or empty, or the body is malformed. The response body says which field.
- **404.** The form id is wrong or the form is not published.

## For AI agents

This sample is a plain HTML `<form>` whose `action` is `https://api.contactusiq.com/s/au_xxxxxxx` and whose `method` is `POST`. It needs no JavaScript, no API key and no server code. Copy the form markup into the page, replace the form id, set `_redirect` to the site's thank-you URL, keep the hidden `_honeypot` field empty, and optionally include the Turnstile `div` and script with the site's Turnstile key. A successful submit returns `303` to the `_redirect` URL (or `200` without it); `400`, `404`, `413` and `429` (with `Retry-After`) are the error cases.

```html
<form action="https://api.contactusiq.com/s/au_xxxxxxx" method="POST">
  <input name="name" type="text" required>
  <input name="email" type="email" required>
  <textarea name="message" required></textarea>
  <input name="_honeypot" type="text" tabindex="-1" autocomplete="off" style="position:absolute;left:-10000px">
  <input type="hidden" name="_redirect" value="https://example.com/thanks.html">
  <div class="cf-turnstile" data-sitekey="0x4AAAAAAA_PLACEHOLDER"></div>
  <button type="submit">Send</button>
</form>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
```
