Skip to main content

Forms API

API endpoints for managing forms.

List Formsโ€‹

Retrieve all forms in your organization.

GET /api/v1/forms

Required Permission: forms:read

Query Parameters:

ParameterTypeDefaultDescription
pagenumber1Page number
pageSizenumber20Items per page (max 100)
statusstring-Filter by status: draft or published

Example Request:

curl -X GET "https://your-domain.com/api/v1/forms?status=published&page=1&pageSize=10" \
-H "Authorization: Bearer np_live_your_api_key"

Example Response:

{
"success": true,
"data": [
{
"id": "form_abc123",
"slug": "contact-form",
"name": "Contact Form",
"description": "Customer contact form",
"status": "published",
"responseCount": 42,
"createdAt": "2024-01-15T10:00:00.000Z",
"updatedAt": "2024-01-20T15:30:00.000Z",
"publishedAt": "2024-01-16T09:00:00.000Z"
}
],
"pagination": {
"total": 5,
"page": 1,
"pageSize": 10,
"totalPages": 1,
"hasMore": false
},
"requestId": "req_abc123"
}

Get Formโ€‹

Retrieve a single form by ID or slug.

GET /api/v1/forms/:formId

Required Permission: forms:read

Example Request:

curl -X GET "https://your-domain.com/api/v1/forms/contact-form" \
-H "Authorization: Bearer np_live_your_api_key"

Example Response:

{
"success": true,
"data": {
"id": "form_abc123",
"slug": "contact-form",
"name": "Contact Form",
"description": "Customer contact form",
"status": "published",
"responseCount": 42,
"createdAt": "2024-01-15T10:00:00.000Z",
"updatedAt": "2024-01-20T15:30:00.000Z",
"publishedAt": "2024-01-16T09:00:00.000Z",
"fields": [
{
"id": "field_1",
"path": "name",
"label": "Full Name",
"type": "text",
"required": true,
"placeholder": "Enter your name"
},
{
"id": "field_2",
"path": "email",
"label": "Email Address",
"type": "email",
"required": true,
"validation": {
"pattern": "^[^@]+@[^@]+\\.[^@]+$"
}
}
],
"settings": {
"submitButtonText": "Send Message",
"successMessage": "Thank you for contacting us!"
}
},
"requestId": "req_abc123"
}

Create Formโ€‹

Create a new form.

POST /api/v1/forms

Required Permission: forms:write

Request Body:

{
"name": "Feedback Form",
"description": "Collect customer feedback",
"fields": [
{
"path": "rating",
"label": "Rating",
"type": "number",
"required": true,
"validation": {
"min": 1,
"max": 5
}
},
{
"path": "comments",
"label": "Comments",
"type": "textarea",
"required": false,
"placeholder": "Tell us more..."
}
]
}

Example Request:

curl -X POST "https://your-domain.com/api/v1/forms" \
-H "Authorization: Bearer np_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Feedback Form",
"description": "Collect customer feedback",
"fields": [
{
"path": "rating",
"label": "Rating",
"type": "number",
"required": true
}
]
}'

Example Response:

{
"success": true,
"data": {
"id": "form_new123",
"slug": "feedback-form",
"name": "Feedback Form",
"status": "draft",
"createdAt": "2024-01-20T16:00:00.000Z"
},
"requestId": "req_abc123"
}

Update Formโ€‹

Update an existing form.

PATCH /api/v1/forms/:formId

Required Permission: forms:write

Request Body:

{
"name": "Updated Form Name",
"description": "Updated description",
"status": "published"
}

Example Request:

curl -X PATCH "https://your-domain.com/api/v1/forms/form_abc123" \
-H "Authorization: Bearer np_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Updated Contact Form",
"status": "published"
}'

Delete Formโ€‹

Delete a form and all its submissions.

DELETE /api/v1/forms/:formId

Required Permission: forms:delete

Example Request:

curl -X DELETE "https://your-domain.com/api/v1/forms/form_abc123" \
-H "Authorization: Bearer np_live_your_api_key"

Example Response:

{
"success": true,
"data": {
"deleted": true,
"formId": "form_abc123"
},
"requestId": "req_abc123"
}
warning

Deleting a form permanently removes all associated submissions. This action cannot be undone.

Field Typesโ€‹

Forms support the following field types:

TypeDescription
textSingle-line text input
textareaMulti-line text input
emailEmail address with validation
numberNumeric input
phonePhone number input
dateDate picker
datetimeDate and time picker
selectDropdown selection
multiselectMultiple selection
checkboxSingle checkbox
checkboxGroupMultiple checkboxes
radioRadio button group
fileFile upload
signatureSignature capture
ratingStar rating