Skip to content

Submitting forms (developers)

Method + path What it does
POST /forms/{name}/submit Takes a submission as a normal form post (multipart/form-data or application/x-www-form-urlencoded) or as JSON
GET /token?form={name} Returns {token, issuedAt} for headless clients. 404 for unknown or unpublished forms
GET /doi/{token} The double opt-in link. See Double opt-in

Besides the field values, a submission carries:

Input Meaning
_pk_token (or header X-PimKit-Form-Token) Signed form token. Rendered into every form, or fetched from /token
_pk_locale Language for error messages. Default: the request locale
_pk_website Honeypot. Must stay empty
cf-turnstile-response, h-captcha-response, g-recaptcha-response, frc-captcha-response, _pk_captcha (or header X-PimKit-Captcha) Captcha answer, when the form uses a captcha. See Spam protection

Sent when the body is JSON, the request is an XHR, or Accept asks for application/json.

Status Body
201 {uuid, successMode: "message", message} or {uuid, successMode: "redirect", redirect}
422 {errors: {field: [messages]}, formErrors: [messages]}. Messages are in the submission’s language
404 The form does not exist, is a draft or is archived

A plain form post is answered with a 303 redirect:

  • Success with “redirect” mode: to the configured page or URL.
  • Success with “message” mode: back to the page with ?pimkit_form_sent=<name>. The page then shows the success message where the form was.
  • Errors: back to the page. The values and errors are kept in the session for one page view, and the form shows them with an error summary.

Only redirects to the same host are made. Without a usable Referer, the answer is a bare page with the message or the form and its errors.

_pk_token is <issued-at>.<signature>, an HMAC over the form name and the time, signed with the app secret. It replaces a CSRF token without a session, so cached pages keep working. Tokens are valid for 7 days and only for the form they were made for. A missing, forged or expired token gives a 422 with “This form has expired. Please send it again.”

  1. Find the published version by form name.
  2. Check the form token.
  3. Spam traps: the honeypot must be empty, and the form must not be sent faster than settings.spam.timeTrapSeconds (default 3) after it was rendered. Spam gets the normal success answer, is stored with status spam (unless storeSubmissions is off) and never runs actions. Rate limits and captchas are described in Spam protection.
  4. PreSubmitEvent: listeners can change values (setValue) or reject with their own messages (addError).
  5. Conditions decide which fields count. Values of hidden and disabled fields are dropped and never validated. A “require” condition makes a field required.
  6. Each field type validates its value. Empty strings count as “no value”.
  7. Values are normalised (trimmed text, numbers, choice lists, consent with its text).
  8. The submission is stored with status received, the request’s site, and meta: ip_hash (HMAC, never the raw IP), user_agent, referrer and utm_* from the referrer.
  9. SubmissionStoredEvent is dispatched. Actions (email, webhooks) start from it, see Actions.

Code: PimKit\FormsBundle\Submission\SubmissionHandler, Controller\Frontend\SubmitController.

Editors read submissions in Studio under PimKit > Forms > Submissions.

  • Retry: puts the action back to “retrying” with 0 attempts, moves a failed submission back to received (or confirmed) and queues ExecuteActionMessage. Code: Action\ActionRetrier.
  • Erase (see also GDPR and retention): deletes the submission, its stored files and its action log (cascade). The audit log keeps submission.erased with the form name. Code: Submission\SubmissionEraser.
  • Export: Export\ExportJobs keeps the job as JSON in the pimkit_forms.storage Flysystem storage under exports/, ExportSubmissionsHandler writes the file in batches of 200 rows. Columns: ID, date, status, language, then one per field with text values (choice labels, file names). Cells that start with =, +, - or @ get a leading ' in CSV so spreadsheets do not run them. XLSX cells are always text. Jobs and files older than a day are removed when a new export starts.