# Form endpoint

Accepts the entries of a form. Only reachable from the page itself, at its own address.

Source: https://sharepa.ai/en/docs/reference/form

## Request

`POST /__sharepa/formular`

Body as `application/x-www-form-urlencoded`, `multipart/form-data` or `application/json` (flat object).

### Fields

- `any` (Text, number, list of text): Your fields. At most 50, names up to 100 characters, values up to 10,000 characters.
- `_honig` (Text): Bot trap, must stay empty.
- `_formular` (Text): Name of the form, up to 60 characters.
- `_weiter` (Path): Where to go after sending, on the same page.

### Headers

- `accept` (application/json): Answer as JSON instead of redirecting to the thank-you page.

```js
const r = await fetch("/__sharepa/formular", {
  method: "POST",
  headers: {
    "content-type": "application/json",
    accept: "application/json",
  },
  body: JSON.stringify({
    _formular: "Waitlist",
    email: "anna@example.com",
  }),
});
```

## Response

Without `accept: application/json`, sharepa redirects with status 303, to `_weiter` or the thank-you page. With JSON:

- `ok` (Boolean): `true` when the entry is stored.
- `fehler` (Text): Only with `ok: false`. One of the error codes below.

Response 200:

```json
{ "ok": true }
```

Response 422:

```json
{ "ok": false, "fehler": "formular.heikel" }
```

## Error codes

| Code | Status | Meaning |
|---|--:|---|
| `formular.herkunft` | 403 | The request did not come from the page itself. |
| `formular.gesperrt` | 401 | The page has a password, and the visitor has not unlocked it. |
| `formular.zuGross` | 413 | The entry is larger than 100 KB. |
| `formular.ungueltig` | 422 | The body could not be read, it has no fields, more than 50 fields, a name over 100 or a value over 10,000 characters. |
| `formular.heikel` | 422 | A field looks like password, payment or health data. |
| `formular.langsam` | 429 | Too many entries in a short time from the same visitor. |
| `formular.grenze` | 429 | The limit of the page or the account is reached. |

## Related guides

- [Build a form with your chat and collect entries](https://sharepa.ai/en/guides/build-a-form-with-your-chat)
- [A waiting list or newsletter sign-up where the page stays put](https://sharepa.ai/en/guides/waitlist-and-newsletter-signup)
