Docs
Survey Creation API
Official API reference maintained directly inside the SmartForm app.
SmartForm exposes a developer-first API for creating surveys programmatically. Each request is authenticated with your personal API key so that externally created surveys stay traceable and secure.
Tip: Prerequisites
Generate your API key from Settings → Developer API access inside the SmartForm application. Each user receives a unique key and can rotate it at any time.
Base URL
https://smartform.dev/api/v1
All Survey Creation endpoints live under /api/v1. Replace https://smartform.dev with your workspace domain when self-hosting.
Authentication
Provide your API key in one of the supported headers:
Authorization: Bearer <API_KEY>(recommended)X-API-Key: <API_KEY>
Keys are scoped to the user who owns the survey. Requests with missing or invalid credentials return 401 Unauthorized.
Quick Start
Here's a simple example to create your first survey:
curl --request POST \
--url https://smartform.dev/api/v1/survey \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"title": "Customer Feedback",
"questions": [
{
"title": "How satisfied are you?",
"type": "RATE",
"isRequired": true
}
],
"oneQuestionPerStep": true,
"displayTitle": true,
"accentColor": "#C7D2FE"
}'
Create a survey
POST /survey
Create a new survey with questions, styling, and configuration.
Request Body
{
"title": "Customer Feedback Survey",
"description": "Help us improve our service",
"questions": [
{
"title": "How satisfied are you?",
"type": "RATE",
"isRequired": true,
"fieldType": "USER_DEFINED"
},
{
"title": "First Name",
"type": "INPUT",
"isRequired": true,
"fieldType": "PROGRAMMATIC",
"paramName": "first_name"
}
],
"oneQuestionPerStep": true,
"displayTitle": true,
"hideProgressBar": false,
"accentColor": "#C7D2FE",
"backgroundColor": "#E7E3DC",
"formBackgroundColor": "#FFFFFF",
"logoUrl": null,
"logoPosition": "TOP_LEFT"
}
Parameters
Survey Configuration
| Field | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Survey title (max 100 characters) |
description | string | No | Survey description |
oneQuestionPerStep | boolean | Yes | Show one question per step |
displayTitle | boolean | Yes | Display survey title |
hideProgressBar | boolean | Yes | Hide progress bar |
Styling Options
| Field | Type | Required | Description |
|---|---|---|---|
accentColor | string | Yes | Accent color (hex format, e.g., "#C7D2FE") |
backgroundColor | string | Yes | Background color (hex format) |
formBackgroundColor | string | Yes | Form background color (hex format) |
logoUrl | string | No | Logo URL (data URL or HTTPS) |
logoPosition | string | Yes | Logo position: TOP_LEFT, TOP_CENTER, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT |
Questions
| Field | Type | Required | Description |
|---|---|---|---|
questions | array | Yes | Array of question objects |
questions[].title | string | Yes | Question text (max 500 characters) |
questions[].type | string | Yes | Question type: EMOJI, INPUT, CHOICE, RATE |
questions[].isRequired | boolean | Yes | Whether the question must be answered |
questions[].fieldType | string | No | Field type: USER_DEFINED (default) or PROGRAMMATIC |
questions[].paramName | string | No | Parameter name for programmatic fields (snake_case, no special chars) |
questions[].options | array | No | Answer options for CHOICE and EMOJI types |
questions[].logicPaths | array | No | Conditional logic paths |
Field Types
SmartForm supports two types of form fields to give you flexibility in how data is collected:
USER_DEFINED (Default)
Standard interactive fields where users provide their own answers through the survey interface.
PROGRAMMATIC
Fields that are automatically pre-filled from URL parameters when users access the survey. These fields are disabled in the UI to prevent user editing.
Example Usage:
- Create a survey with a programmatic field:
paramName: "first_name" - Share the survey URL:
https://smartform.dev/survey/abc123?first_name=John - The "First Name" field will be automatically filled with "John"
Parameter Naming:
- Use snake_case format (e.g.,
first_name,user_id) - Avoid special characters
- Parameters are case-sensitive
Response
Success Response (200)
{
"id": "clwxyz12ab34"
}
| Field | Type | Description |
|---|---|---|
id | string | Server-generated survey identifier |
Use this id to construct the survey URL: https://smartform.dev/survey/{id}
Error Responses
| Status Code | Error Type | Description | Solution |
|---|---|---|---|
400 | Bad Request | Invalid payload structure, missing required fields, or invalid values | Verify payload matches the API schema |
401 | Unauthorized | Missing or invalid API key | Add Authorization: Bearer <API_KEY> header |
500 | Internal Server Error | Unexpected server-side failure | Retry with exponential backoff |
Common 400 Errors:
- Survey title exceeds 100 characters
- Question title exceeds 500 characters
- Invalid question type
- Invalid logo position
- Malformed hex color codes
Code Examples
cURL
curl --request POST \
--url https://smartform.dev/api/v1/survey \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"title": "Customer Feedback Survey",
"description": "Help us improve our service",
"questions": [
{
"title": "How satisfied are you?",
"type": "RATE",
"isRequired": true,
"fieldType": "USER_DEFINED"
},
{
"title": "Your Name",
"type": "INPUT",
"isRequired": true,
"fieldType": "PROGRAMMATIC",
"paramName": "user_name"
}
],
"oneQuestionPerStep": true,
"displayTitle": true,
"hideProgressBar": false,
"accentColor": "#C7D2FE",
"backgroundColor": "#E7E3DC",
"formBackgroundColor": "#FFFFFF",
"logoPosition": "TOP_LEFT"
}'
JavaScript (Node.js)
const response = await fetch('https://smartform.dev/api/v1/survey', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
title: 'Customer Feedback Survey',
questions: [
{
title: 'How satisfied are you?',
type: 'RATE',
isRequired: true,
},
],
oneQuestionPerStep: true,
displayTitle: true,
accentColor: '#C7D2FE',
backgroundColor: '#E7E3DC',
formBackgroundColor: '#FFFFFF',
logoPosition: 'TOP_LEFT',
}),
});
const result = await response.json();
console.log('Survey created:', result.id);
Best Practices
Security
- Always use HTTPS for API calls
- Store API keys securely (never in client-side code)
- Rotate API keys regularly via SmartForm settings
Development
- Test programmatic fields by appending parameters to survey URLs
- Validate survey IDs before using them in production
- Handle API errors gracefully with appropriate retry logic
Integration
- Programmatic fields are automatically disabled in the survey UI
- Use meaningful parameter names that match your data schema
- Consider user privacy when pre-filling personal information
Need help? Contact support@smartform.dev for assistance.