przio.com

Forms · API reference

Forms API & integration

Manage form definitions with authenticated REST endpoints, accept submissions from any origin via POST /api/forms/submit, export or delete submission rows, and wire client-side success handlers through sdk.min.js and embed JSON config.

Overview

Forms belong to a project; each definition has a human-chosen form id (slug) used by the public submit endpoint, and a MongoDB _id used by dashboard APIs.

The dashboard UI at /forms?projectId=… lists forms, opens the builder at /forms/<mongoId>?projectId=…, and shows submissions at /forms/<mongoId>/data. This page documents the HTTP API those screens call and the public endpoint third-party sites use to post leads.

Forms list in PRZIO dashboard
Forms index — each card exposes actions backed by the REST routes below.

Identifiers

NameWhereNotes
projectId Query string, JSON body MongoDB ObjectId string for the project (same as snippet data-project-id).
formId URL-safe slug; stored lowercase Unique across all projects. Used by POST /api/forms/submit and embed HTML. Not the same as _id.
_id Path param /api/forms/[id] MongoDB ObjectId of the Form document — used when fetching/updating/deleting a form or listing its submissions.

Authentication

Dashboard APIs require a valid JWT; the public submit route does not.

  • Dashboard routes (GET/POST /api/forms, GET/PUT/DELETE /api/forms/[id], GET/DELETE …/submissions): send Authorization: Bearer <JWT> with the user session token, or rely on the przio_token cookie after login.
  • Project access: the user must be the project owner or a member; tool access form is enforced on list/create.
  • Public submit: POST /api/forms/submit accepts JSON from any origin; CORS echoes the request Origin when present. No API key in the browser is required for submit.

Base URL: Use your deployment host (e.g. https://app.przio.com). Paths below are rooted at /api.

REST · manage forms

Authenticated. [id] is always the Form document’s MongoDB _id.

List forms for a project

GET /api/forms?projectId=PROJECT_ID
Authorization: Bearer YOUR_SESSION_JWT

200{ "forms": Form[] } (newest first).

Create form

POST /api/forms
Authorization: Bearer YOUR_SESSION_JWT
Content-Type: application/json

{
  "formId": "newsletter-footer",
  "name": "Newsletter signup",
  "formType": "subscription",
  "projectId": "PROJECT_ID",
  "fields": [],
  "steps": [],
  "status": "draft",
  "successClientEventEnabled": false,
  "successClientEventName": ""
}

Required: formId, name, formType, projectId. Optional: fields, steps, status, success-event flags. Custom event name must match ^[a-zA-Z0-9:_-]+$ when non-empty.

201{ "form": Form }. Errors: duplicate formId → 400.

Get one form

GET /api/forms/FORM_MONGO_ID
Authorization: Bearer YOUR_SESSION_JWT

Update form

PUT /api/forms/FORM_MONGO_ID
Authorization: Bearer YOUR_SESSION_JWT
Content-Type: application/json

{
  "name": "Updated name",
  "fields": [ /* ... */ ],
  "status": "active",
  "successClientEventEnabled": true,
  "successClientEventName": "mystore:lead-captured"
}

Omit keys you do not want to change. To rename the slug, send "formId": "new-slug" (must stay unique).

Delete form

DELETE /api/forms/FORM_MONGO_ID
Authorization: Bearer YOUR_SESSION_JWT

200{ "message": "Form deleted successfully" }.

REST · submit (public)

No login required. Form must exist and status must be active.

POST /api/forms/submit
Content-Type: application/json

{
  "formId": "pre-seeds",
  "data": { "email": "user@example.com" },
  "visitorId": "optional-przio-visitor-uuid",
  "isQA": false,
  "trackingType": "production"
}
  • formId — slug (case-insensitive match in DB).
  • data — object keyed by field name values from the form definition.
  • visitorId — optional; typically from PRZIO visitor cookie for correlation.
  • isQA — optional boolean for preview/test submissions.
  • trackingType — optional "QA" or "production" (default production).

201{ "message": "Form submitted successfully", "submissionId": "…" }. Server stores IP (from x-forwarded-for / x-real-ip) and user-agent.

400 — missing formId/data, or form not active. 404 — unknown formId.

Side effects: After save, enabled auto-send email rules for the form may send templated mail via configured SMTP (see below).

REST · submissions

Authenticated; path uses Form _id.

GET /api/forms/FORM_MONGO_ID/submissions
Authorization: Bearer YOUR_SESSION_JWT

200{ "submissions": Submission[] } sorted by submittedAt descending (matches dashboard table).

Delete submissions

DELETE /api/forms/FORM_MONGO_ID/submissions
Authorization: Bearer YOUR_SESSION_JWT
Content-Type: application/json

{ "submissionIds": ["id1", "id2"] }

Or wipe all rows:

{ "deleteAll": true }

200{ "deletedCount": number }.

Submissions grid with export and delete actions
Submissions UI — backed by GET/DELETE submissions routes.

Form resource shape

Fields mirror the TypeScript model in the repo (lib/models/Form.ts).

PropertyTypeNotes
_idstringMongo id — use in REST paths.
formIdstringLowercase unique slug.
namestringDisplay name in dashboard.
formTypestringsubscription | survey | contact | custom | quiz
projectIdObjectIdOwning project.
fieldsFormField[]See field types.
stepsFormStep[]Optional multi-step (survey) metadata.
statusstringdraft | active | inactive — only active accepts public submit.
successClientEventEnabledbooleanWhether embed JSON enables CustomEvent dispatch after successful submit.
successClientEventNamestringOptional extra event name (alphanumeric + :_-).
createdAt / updatedAtISO dateTimestamps.
Form builder with integration instructions
Builder — success event toggles map to successClientEvent* on the Form document.

Submission resource shape

PropertyNotes
_idSubmission id (returned as submissionId from submit).
formIdSlug copy for querying.
formObjectIdReference to Form _id.
projectIdProject reference.
dataArbitrary key/value payload from the submit body.
submittedAtServer time.
ipAddressFrom proxy headers when available.
userAgentRequest UA string.
visitorIdOptional PRZIO visitor id.
isQAQA flag from submit payload.
trackingTypeQA or production.

SDK & browser events

Load sdk.min.js (or dev sdk.js) with your project id on every page that hosts an embedded form.

The minified SDK includes a small bridge that intercepts successful responses to /api/forms/submit (via fetch or XMLHttpRequest). When the embed JSON (script[type="application/json"][data-przio-form-config]) has successClientEvent.enabled === true, it dispatches:

  • Alwaysprzio:form-submit-success (detail includes formId and API response).
  • Additionally — your custom event name when set and different from the default.
window.addEventListener('przio:form-submit-success', function (e) {
  console.log(e.detail); // { formId, response }
});

Embed forms through Popup or Personalization activities so exported HTML includes the JSON config block next to the form — see Forms overview and the in-app Integration → Form tutorial.

Embed JSON config

The bridge reads script[type="application/json"][data-przio-form-config="<formId>"]. When successClientEvent.enabled is true, events fire after a successful submit response.

Shape (conceptual):

{
  "successClientEvent": {
    "enabled": true,
    "eventName": "mystore:lead-captured"
  }
}

Implementation reference: frontend/lib/przioFormSuccessBridgeScript.ts (bundled into public SDK).

Auto-send email

Optional rules tied to a form can send email after submit when SMTP is configured.

On each successful submission, the server loads enabled AutoSendEmail rules for that form, resolves recipients (including merge tags from data and optional recipient folders), and sends via admin or user SMTP. Failures are logged to email history — configure rules in the dashboard rather than via public API here.

Field types

Each field has id, name (key in submit data), label, type, required, optional placeholder, options for choice controls, validation, and optional stepId.

typeNotes
textSingle-line input.
emailEmail validation in UI.
numberOptional min/max in validation.
textareaMulti-line.
selectRequires options[].
checkboxBoolean-style or multi-option depending on builder.
radioRequires options[].
dateDate picker.
telTelephone.
urlURL input.

Common errors

StatusMeaning
400Validation — duplicate slug, invalid event name, missing required JSON keys, inactive form on submit.
401Missing or invalid JWT on protected routes.
403User cannot access project or form tool.
404Unknown form slug (submit) or mongo id.
500Server error — retry or contact support.

Integration checklist

  • Activate the form before production traffic (status: active).
  • SDK on host pages that render popup/personalization embeds.
  • Re-embed after field changes so HTML + JSON config stay aligned.
  • Listen for przio:form-submit-success (and custom name if configured).
  • Submit payload keys must match field name values.
  • Privacy — avoid logging PII in client listeners in production without policy.

Copyright © 2026 PRZIO. All rights reserved.