Submitting forms (developers)
Endpoints (/pimkit/forms/api)
Section titled “Endpoints (/pimkit/forms/api)”| 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 |
JSON answers
Section titled “JSON answers”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 |
Without JavaScript
Section titled “Without JavaScript”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.
Form token
Section titled “Form token”_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.”
What happens on submit
Section titled “What happens on submit”- Find the published version by form name.
- Check the form token.
- 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 statusspam(unlessstoreSubmissionsis off) and never runs actions. Rate limits and captchas are described in Spam protection. PreSubmitEvent: listeners can change values (setValue) or reject with their own messages (addError).- Conditions decide which fields count. Values of hidden and disabled fields are dropped and never validated. A “require” condition makes a field required.
- Each field type validates its value. Empty strings count as “no value”.
- Values are normalised (trimmed text, numbers, choice lists, consent with its text).
- The submission is stored with status
received, the request’s site, and meta:ip_hash(HMAC, never the raw IP),user_agent,referrerandutm_*from the referrer. SubmissionStoredEventis dispatched. Actions (email, webhooks) start from it, see Actions.
Code: PimKit\FormsBundle\Submission\SubmissionHandler, Controller\Frontend\SubmitController.
Reading, retrying, erasing and exporting
Section titled “Reading, retrying, erasing and exporting”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.erasedwith the form name. Code:Submission\SubmissionEraser. - Export:
Export\ExportJobskeeps the job as JSON in thepimkit_forms.storageFlysystem storage underexports/,ExportSubmissionsHandlerwrites 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.