Skip to content

Forms

GET forms/<id> gives a live form, as visitors get it. POST forms/<id>/submit sends an answer.

A form

  • fields hold name, type, label, required, placeholder, icon, options and show. The types are text, textarea, email, tel, number, url, date, slot, select, choice, multi, checkbox, file and hidden.
  • from_query names a parameter of the page address that fills the field in, such as email for ?email=…. A hidden field always has it. With query_lock: true, a field filled in that way cannot be changed by the visitor; without the parameter it stays open.
  • An email field can have email: {require: [...], exclude: [...]}, with domains it must, or must not, be of. A subdomain counts too, so mail.gmail.com is in gmail.com. The CMS checks it again when the answer comes in.
  • A field that is switched off in the CMS is not in fields.
  • steps is [] for one screen. Otherwise it is [{title, fields, show}]. Draw one step at a time, with Next and Back.
  • submit, note and success_html are given per language.

Show when

A field or step has show. It is null, or {match: "all"|"any", rules: [{field, op, value, i}]}. A rule only names a field before it.

The values of op are eq, ne, contains, starts, ends, in, filled, empty, gt, gte, lt, lte and regex. A field that does not show is never required, and it is not sent.

Sending

POST forms/<id>/submit
{"answers": {…}, "lang": "en", "page": "/contact/", "seconds": 14.2}
  • Check your honeypot first. seconds is how long filling in took.
  • With a file field, send multipart/form-data. Put the JSON in the part payload, and the files as files[<field>][<n>].
  • The answer has status, and success_html with the answers filled in. It also has message, from a service that the visitor waited for.
  • A suspect answer gets the same answer as any other. Never tell a sender that it was held.
  • On an environment that is not live, an answer is kept as a test, and it is sent nowhere. It says "test": true.

Webhooks from a form

A webhook integration posts {text, form, values, page, summary, event, delivery, files?}. It sends these headers:

  • X-Signature: t=<unix>,v1=<hex>. That is HMAC-SHA256 with the signing secret of the integration, over <t>.<raw body>.
  • X-Lightbolt-Event: form.submitted.
  • X-Lightbolt-Delivery. It stays the same when it is sent again, so skip a repeat.

Refuse a t that is older than five minutes.

Also called: form API, form submissions, form webhooks, conditional logic, file uploads.

Last changed