RESTful API Documentation v1.0
The Form Builder API is a comprehensive RESTful API for creating, managing, and submitting dynamic forms. It provides complete backend functionality for form management systems with support for:
https://your-domain.com/api/
All API responses are returned in JSON format with the following structure:
{
"status": "success",
"message": "Operation successful",
"data": { ... }
}
{
"status": "error",
"message": "Error description",
"errors": { ... }
}
The API uses Bearer Token authentication. After successful login or registration, you'll receive a token that must be included in the Authorization header of subsequent requests.
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
The API implements a three-tier role system with organization-scoped permissions:
Create a new user account and receive authentication token.
{
"name": "John Doe",
"email": "john@example.com",
"password": "secure_password_123"
}
name: Required, stringemail: Required, valid email format, must be uniquepassword: Required, minimum 8 characters{
"status": "success",
"message": "Registration successful",
"data": {
"user": {
"user_id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"org_id": null
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
Authenticate user and receive authentication token.
{
"email": "john@example.com",
"password": "secure_password_123"
}
{
"status": "success",
"message": "Login successful",
"data": {
"user": {
"user_id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"org_id": 5
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}
{
"status": "error",
"message": "Invalid credentials"
}
Revoke authentication token and log out user.
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
{
"status": "success",
"message": "Logout successful"
}
Retrieve list of users. Results are filtered based on user role:
{
"status": "success",
"data": {
"users": [
{
"user_id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"org_id": 1
},
{
"user_id": 2,
"name": "Jane Smith",
"email": "jane@example.com",
"role": "admin",
"org_id": 1
}
]
}
}
Get specific user details. Access is restricted by role:
{
"status": "success",
"data": {
"user": {
"user_id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "user",
"org_id": 1
}
}
}
Create a new user account. Permissions vary by role:
{
"name": "Jane Smith",
"email": "jane@example.com",
"password": "secure_password_123",
"role": "user",
"org_id": 1
}
role can be "user" or "admin" onlyrole can be "user", "admin", or "super_admin"org_id defaults to their organization if not provided{
"status": "success",
"message": "User created successfully",
"data": {
"user": {
"user_id": 2,
"name": "Jane Smith",
"email": "jane@example.com",
"role": "user",
"org_id": 1
}
}
}
Update user information. Permissions vary by role:
{
"name": "John Updated",
"email": "john.new@example.com",
"role": "admin",
"org_id": 2
}
name, email, passwordorg_id and set role to "super_admin"{
"status": "success",
"message": "User updated successfully",
"data": {
"user": {
"user_id": 1,
"name": "John Updated",
"email": "john.new@example.com",
"role": "admin",
"org_id": 2
}
}
}
Delete a user account. Permissions vary by role:
{
"status": "success",
"message": "User deleted successfully"
}
Get current authenticated user details.
{
"status": "success",
"data": {
"user": {
"user_id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "admin",
"org_id": 1,
"organizations": [
{
"org_id": 1,
"name": "Acme Corp",
"address": "123 Main St",
"accent_color": "#FF5733"
}
]
}
}
}
Retrieve list of all organizations. Only accessible by super admins.
{
"status": "success",
"data": {
"organizations": [
{
"org_id": 1,
"name": "Acme Corp",
"address": "123 Main St",
"accent_color": "#FF5733"
}
]
}
}
Get specific organization details with member list. Only accessible by super admins.
{
"status": "success",
"data": {
"organization": {
"org_id": 1,
"name": "Acme Corp",
"address": "123 Main St",
"accent_color": "#FF5733",
"members": [
{
"user_id": 1,
"name": "John Doe",
"email": "john@example.com",
"role": "admin"
}
]
}
}
}
Create new organization. Only accessible by super admins. The creator is automatically added as a member.
{
"name": "New Corp",
"address": "456 Oak Ave",
"accent_color": "#3498DB"
}
{
"status": "success",
"message": "Organization created successfully",
"data": {
"organization": {
"org_id": 2,
"name": "New Corp",
"address": "456 Oak Ave",
"accent_color": "#3498DB"
}
}
}
Update organization details. Only accessible by super admins.
{
"name": "Updated Corp",
"accent_color": "#E74C3C"
}
{
"status": "success",
"message": "Organization updated successfully",
"data": {
"organization": {
"org_id": 1,
"name": "Updated Corp",
"address": "123 Main St",
"accent_color": "#E74C3C"
}
}
}
Get all folders user has access to. Admins see all folders, users see folders they have permissions for.
{
"status": "success",
"data": {
"folders": [
{
"folder_id": 1,
"name": "HR Forms",
"parent_folder_id": null,
"org_id": 1
},
{
"folder_id": 2,
"name": "Onboarding",
"parent_folder_id": 1,
"org_id": 1
}
]
}
}
Get specific folder with parent and organization information.
{
"status": "success",
"data": {
"folder": {
"folder_id": 2,
"name": "Onboarding",
"parent_folder_id": 1,
"org_id": 1,
"parent": {
"folder_id": 1,
"name": "HR Forms"
},
"organization": {
"org_id": 1,
"name": "Acme Corp"
}
}
}
}
Create new folder. Creator automatically gets admin permission for the folder.
{
"name": "Finance Forms",
"org_id": 1,
"parent_folder_id": null
}
parent_folder_id to null for root-level folders, or specify a parent folder ID for nested folders.
{
"status": "success",
"message": "Folder created successfully",
"data": {
"folder": {
"folder_id": 3,
"name": "Finance Forms",
"parent_folder_id": null,
"org_id": 1
}
}
}
Get all forms in user's organization.
{
"status": "success",
"data": {
"forms": [
{
"form_id": 1,
"template_id": 1,
"name": "Employee Onboarding",
"title": "Employee Onboarding",
"description": "New employee intake form",
"folder_id": 1,
"concept_flag": false,
"publication_date": "2025-10-15",
"submission_type": 1,
"status": "published",
"version": 1,
"created_at": "2025-10-10 14:30:00",
"updated_at": "2025-10-15 09:20:00"
}
]
}
}
Get specific form template details.
{
"status": "success",
"data": {
"form": {
"form_id": 1,
"template_id": 1,
"title": "Employee Onboarding",
"description": "New employee intake form",
"folder_id": 1,
"concept_flag": false,
"publication_date": "2025-10-15",
"submission_type": 1,
"status": "published",
"version": 1
}
}
}
Create new form template with optional field definitions.
{
"title": "Feedback Form",
"folder_id": 1,
"description": "Employee feedback survey",
"concept_flag": 1,
"submission_type": 1,
"form_data": {
"fields": [
{
"field_name": "name",
"type": "text",
"label": "Your Name",
"required": true,
"order_index": 1
},
{
"field_name": "rating",
"type": "number",
"label": "Rating (1-5)",
"required": true,
"order_index": 2
}
]
}
}
{
"status": "success",
"message": "Form created successfully",
"data": {
"form": {
"form_id": 2,
"title": "Feedback Form",
"folder_id": 1,
"concept_flag": true,
"submission_type": 1
}
}
}
Update form template metadata.
{
"title": "Updated Form Title",
"description": "Updated description"
}
Delete form template.
{
"status": "success",
"message": "Form deleted successfully"
}
Publish a draft form (changes concept_flag from 1 to 0).
Get all field definitions for a specific form.
{
"status": "success",
"data": {
"fields": [
{
"field_id": 1,
"template_id": 1,
"field_name": "full_name",
"type": "text",
"label": "Full Name",
"placeholder": "Enter your full name",
"required": true,
"order_index": 1
},
{
"field_id": 2,
"template_id": 1,
"field_name": "email",
"type": "text",
"label": "Email Address",
"required": true,
"order_index": 2
}
]
}
}
Update form field definitions (bulk update).
{
"fields": [
{
"field_id": 1,
"label": "Updated Label",
"required": false
},
{
"field_id": 2,
"placeholder": "New placeholder text"
}
]
}
Submit form data or save as draft. Supports file uploads and various field types.
{
"form_id": 1,
"submission_type": 1,
"data": [
{
"field_id": 1,
"value": "John Doe"
},
{
"field_id": 2,
"value": "john@example.com"
},
{
"field_id": 3,
"value": 42
},
{
"field_id": 4,
"value": true
}
],
"files": []
}
0 = Draft (incomplete submission)1 = Complete (final submission)| Field Type | Value Format | Example |
|---|---|---|
| text | String | "John Doe" |
| number | Number | 42 or 3.14 |
| boolean | Boolean | true or false |
| date | String (ISO date) | "2025-10-28" |
| signature | Base64 string | "data:image/png;base64,..." |
| file/image | File path or upload data | Included in files array |
{
"status": "success",
"message": "Submission created successfully",
"data": {
"submission": {
"submission_id": 1,
"form_id": 1,
"version_id": 1,
"user_id": 1,
"submission_type": 1,
"submitted_at": "2025-10-28 14:30:00"
}
}
}
Get list of all submissions with optional form filter.
form_id (optional): Filter submissions by form ID
{
"status": "success",
"data": {
"submissions": [
{
"submission_id": 1,
"form_id": 1,
"version_id": 1,
"user_id": 1,
"submission_type": 1,
"submitted_at": "2025-10-28 14:30:00",
"user_name": "John Doe",
"user_email": "john@example.com"
}
]
}
}
Get detailed submission with all field data, including file paths and image references.
{
"status": "success",
"data": {
"submission": {
"submission_id": 1,
"form_id": 1,
"data": [
{
"field_id": 1,
"field_title": "Full Name",
"value": "John Doe"
},
{
"field_id": 3,
"field_title": "Photo",
"value": "uploads/submissions/images/1_3_timestamp.jpg"
}
]
}
}
}
Update existing submission, change draft to complete, or modify field values.
{
"submission_type": 1,
"data": [
{ "field_id": 1, "value": "Updated Value" }
]
}
Export all submissions for a form to CSV file for Excel or data analysis.
form_id (required): Form ID to export submissions fromtext/csvsubmissions_{form_id}_{date}.csvExport single submission as formatted HTML view (ready for PDF conversion or printing).
Get image or signature data for a specific field in base64 format.
{
"status": "success",
"data": {
"type": "image",
"mime_type": "image/jpeg",
"data": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA...",
"url": "/uploads/submissions/images/1_3_1698765432.jpg"
}
}
Serve uploaded files directly. Images are displayed inline, other files are downloaded.
type: images, signatures, or filesfilename: Name of the file/submissions/files/images/1_3_1698765432.jpg
/submissions/files/signatures/1_5_1698765433.png
/submissions/files/files/1_8_1698765434.pdf
The Password Change Notification system allows users to request notifications for password changes. These requests must be approved by an administrator.
Request password change notification. Users provide their username and email to receive notifications. This endpoint does not require authentication.
{
"username": "johndoe",
"email": "john@example.com"
}
{
"success": true,
"message": "If the provided details match our records, your request has been submitted for admin approval."
}
Admin Only: Get all pending password change notification requests.
Authorization: Bearer YOUR_TOKEN_HERE
{
"success": true,
"data": {
"pending_requests": [
{
"id": 1,
"user_id": 123,
"username": "johndoe",
"email_address": "john@example.com",
"is_approved": "no"
}
],
"count": 1
}
}
Admin Only: Get all password change notification requests (both pending and approved).
Authorization: Bearer YOUR_TOKEN_HERE
{
"success": true,
"data": {
"notifications": [
{
"id": 1,
"user_id": 123,
"username": "johndoe",
"email_address": "john@example.com",
"is_approved": "no"
},
{
"id": 2,
"user_id": 456,
"username": "janedoe",
"email_address": "jane@example.com",
"is_approved": "yes"
}
],
"count": 2
}
}
Admin Only: Approve a pending password change notification request.
Authorization: Bearer YOUR_TOKEN_HERE
{
"success": true,
"message": "Notification request approved successfully"
}
Admin Only: Delete a password change notification request.
Authorization: Bearer YOUR_TOKEN_HERE
{
"success": true,
"message": "Notification request deleted successfully"
}
is_approved: 'no'Export submission data in multiple formats for analysis, reporting, or archiving purposes.
Export all submissions for a specific form in CSV, Excel (XLSX), or OpenDocument (ODT) format.
| Parameter | Type | Required | Description |
|---|---|---|---|
form_id |
Integer | Yes | The ID of the form to export submissions from |
format |
String | No | Export format: csv, xlsx, or odt (default: csv) |
GET /api/submissions/export?form_id=26&format=csv
GET /api/submissions/export?form_id=26&format=xlsx
GET /api/submissions/export?form_id=26&format=odt
File download with appropriate headers:
{form_title}_{timestamp}.{extension}Each exported file includes:
| Column | Description |
|---|---|
| Submission ID | Unique identifier for the submission |
| Submitted At | Date and time of submission (YYYY-MM-DD HH:MM:SS) |
| Status | Complete or Draft |
| User Name | Name of the submitting user |
| User Email | Email of the submitting user |
| Organization | Organization name (if applicable) |
| Form Fields | Dynamic columns for each form field value |
| Field Type | Export Format |
|---|---|
| CHECKBOX | Yes / No |
| FILE, PHOTO, SIGNATURE | Filename only |
| NUMBER, PHONE | Numeric value or formatted text |
| TEXT, TEXTAREA, EMAIL, etc. | Text value |
| HEADER, DIVIDER | Excluded from export |
{
"status": "error",
"message": "Form ID is required"
}
{
"status": "error",
"message": "Invalid format. Supported formats: csv, xlsx, odt"
}
{
"status": "error",
"message": "Form not found"
}
| Code | Status | Description |
|---|---|---|
| 200 | OK | Successful GET, PUT, DELETE operation |
| 201 | Created | Successful POST operation (resource created) |
| 400 | Bad Request | Invalid request format or missing required fields |
| 401 | Unauthorized | Missing or invalid authentication token |
| 403 | Forbidden | Valid token but insufficient permissions |
| 404 | Not Found | Requested resource doesn't exist |
| 422 | Validation Error | Request validation failed |
| 500 | Server Error | Internal server error |
{
"status": "error",
"message": "Validation failed",
"errors": {
"email": "Valid email is required",
"password": "Password must be at least 8 characters"
}
}
{
"status": "error",
"message": "Unauthorized. Invalid or expired token."
}
{
"status": "error",
"message": "You do not have permission to access this resource"
}
{
"status": "error",
"message": "Resource not found"
}
Consider implementing rate limiting in production to prevent abuse. Recommended limits:
uploads/submissions/{type}/The API supports CORS for cross-origin requests. Configure allowed origins in public/api.php:
Access-Control-Allow-Origin: https://your-frontend-domain.com
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-Credentials: true
Regular database backups are essential. Recommended schedule: