Skip to content

Beautiful Open-Source Form Builder

Enhance API documentation and submission export functionality

JhumanJ6b05cc6db8d6
diff --git a/docs/api-reference/openapi.yaml b/docs/api-reference/openapi.yaml
index 4ae182e4d..3ebe31023 100644
--- a/docs/api-reference/openapi.yaml
+++ b/docs/api-reference/openapi.yaml
@@ -544,7 +544,7 @@ paths:
tags:
- Submissions
summary: List Submissions
- description: "Requires `forms-read`. Supports pagination via the `page` query parameter."
+ description: "Requires `forms-read`. Supports pagination, search, and status filtering."
security:
- bearerAuth: []
parameters:
@@ -559,22 +559,80 @@ paths:
schema:
type: number
minimum: 1
+ default: 1
+ description: "Pagination page number"
+ - name: per_page
+ in: query
+ required: false
+ schema:
+ type: number
+ minimum: 1
+ maximum: 100
+ default: 100
+ description: "Number of results per page"
+ - name: search
+ in: query
+ required: false
+ schema:
+ type: string
+ description: "Search term to filter submissions by field values"
+ - name: status
+ in: query
+ required: false
+ schema:
+ type: string
+ enum: [completed, partial, all]
+ default: all
+ description: "Filter by submission status"
responses:
"200":
description: Successful
content:
application/json:
schema:
- type: array
- items:
- $ref: "#/components/schemas/Submission"
+ type: object
+ properties:
+ data:
+ type: array
+ items:
+ $ref: "#/components/schemas/Submission"
+ links:
+ type: object
+ properties:
+ first:
+ type: string
+ last:
+ type: string
+ prev:
+ type: string
+ nullable: true
+ next:
+ type: string
+ nullable: true
+ meta:
+ type: object
+ properties:
+ current_page:
+ type: number
+ from:
+ type: number
+ last_page:
+ type: number
+ per_page:
+ type: number
+ to:
+ type: number
+ total:
+ type: number
"403":
description: "Forbidden – token lacks forms-read ability"
+
+ "/open/forms/{id}/submissions/export":
post:
tags:
- Submissions
summary: Export Submissions (CSV)
- description: "Export submissions as CSV. Requires `forms-read`."
+ description: "Export submissions as CSV. Large exports are processed asynchronously. Requires `forms-read`."
security:
- bearerAuth: []
parameters:
@@ -589,6 +647,8 @@ paths:
application/json:
schema:
type: object
+ required:
+ - columns
properties:
columns:
type: object
@@ -597,15 +657,34 @@ paths:
description: "Object mapping field IDs to booleans to include columns in CSV."
responses:
"200":
- description: CSV File
+ description: "Synchronous export (CSV file) or asynchronous export (job status)"
+ content:
+ application/json:
+ schema:
+ oneOf:
+ - type: string
+ format: binary
+ description: "CSV file download for small forms"
+ - type: object
+ description: "Job status for large forms"
+ properties:
+ message:
+ type: string
+ example: "Export started. Large export will be processed in the background."
+ job_id:
+ type: string
+ example: "export_abc123def456"
+ is_async:
+ type: boolean
+ example: true
"403":
description: Forbidden
- "/open/forms/{id}/submissions/export":
- post:
+ "/open/forms/{id}/submissions/export/{job_id}/status":
+ get:
tags:
- Submissions
- summary: Export Submissions (CSV)
- description: "Export submissions as CSV. Requires `forms-read`."
+ summary: Check Export Status
+ description: "Check the status of an asynchronous export job. Requires `forms-read`."
security:
- bearerAuth: []
parameters:
@@ -614,21 +693,21 @@ paths:
required: true
schema:
type: number
- requestBody:
- required: true
- content:
- application/json:
- schema:
- type: object
- properties:
- columns:
- type: object
- additionalProperties:
- type: boolean
- description: "Object mapping field IDs to booleans to include columns in CSV."
+ - name: job_id
+ in: path
+ required: true
+ schema:
+ type: string
+ description: "Export job identifier"
responses:
"200":
- description: CSV File
+ description: Export job status
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/ExportJobStatus"
+ "404":
+ description: "Export job not found or has expired"
"403":
description: Forbidden
"/open/forms/{id}/submissions/{submission_id}":
@@ -1022,19 +1101,24 @@ components:
Submission:
type: object
properties:
- submission_id:
+ id:
type: number
+ description: "Unique submission ID"
readOnly: true
form_id:
type: number
+ description: "ID of the parent form"
readOnly: true
- submitted_at:
- type: string
- format: date-time
+ completion_time:
+ type: number
+ nullable: true
+ description: "Time taken to complete the form in seconds"
readOnly: true
data:
type: object
+ description: "Contains form field responses plus metadata (status, created_at, id)"
additionalProperties: true
+ readOnly: true
UserWorkspaceMember:
type: object
properties:
@@ -1066,6 +1150,57 @@ components:
type: string
format: date-time
description: Expiration timestamp for the invite
+ ExportJobStatus:
+ type: object
+ properties:
+ status:
+ type: string
+ enum: [processing, completed, failed]
+ description: "Current status of the export job"
+ progress:
+ type: number
+ minimum: 0
+ maximum: 100
+ description: "Completion percentage (0-100)"
+ form_id:
+ type: number
+ description: "ID of the form being exported"
+ user_id:
+ type: number
+ description: "ID of the user who initiated the export"
+ job_id:
+ type: string
+ description: "Export job identifier"
+ processed_submissions:
+ type: number
+ description: "Number of submissions processed so far"
+ nullable: true
+ total_submissions:
+ type: number
+ description: "Total number of submissions to process"
+ nullable: true
+ file_url:
+ type: string
+ format: uri
+ description: "Download URL for completed exports"
+ nullable: true
+ expires_at:
+ type: string
+ format: date-time
+ description: "File expiration timestamp (24 hours from completion)"
+ nullable: true
+ error_message:
+ type: string
+ description: "Error description for failed exports"
+ nullable: true
+ created_at:
+ type: string
+ format: date-time
+ description: "Job creation timestamp"
+ updated_at:
+ type: string
+ format: date-time
+ description: "Last update timestamp"
securitySchemes:
bearerAuth:
type: http
diff --git a/docs/api-reference/submissions/export-status.mdx b/docs/api-reference/submissions/export-status.mdx
new file mode 100644
index 000000000..4d2e6d80d
--- /dev/null
+++ b/docs/api-reference/submissions/export-status.mdx
@@ -0,0 +1,136 @@
+---
+openapi: get /open/forms/{id}/submissions/export/{job_id}/status
+---
+
+# Check Export Status
+
+Check the status and progress of an asynchronous CSV export job.
+
+## Authentication & Scope
+
+Requires `forms-read` ability.
+
+## Request
+
+```http
+GET /open/forms/{id}/submissions/export/{job_id}/status HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+| --------- | ------ | ----------------------- |
+| id | number | Numeric ID of the form. |
+| job_id | string | Export job identifier. |
+
+## Response
+
+### Processing Status
+
+```json
+{
+ "status": "processing",
+ "progress": 65,
+ "form_id": 123,
+ "user_id": 456,
+ "processed_submissions": 650,
+ "total_submissions": 1000,
+ "created_at": "2024-06-12T09:15:23.000Z",
+ "updated_at": "2024-06-12T09:16:10.000Z",
+ "job_id": "export_abc123def456"
+}
+```
+
+### Completed Status
+
+```json
+{
+ "status": "completed",
+ "progress": 100,
+ "form_id": 123,
+ "user_id": 456,
+ "processed_submissions": 1000,
+ "total_submissions": 1000,
+ "file_url": "https://storage.example.com/exports/form-123-submissions-2024-06-12-09-15-23.csv",
+ "expires_at": "2024-06-13T09:15:23.000Z",
+ "created_at": "2024-06-12T09:15:23.000Z",
+ "updated_at": "2024-06-12T09:16:30.000Z",
+ "job_id": "export_abc123def456"
+}
+```
+
+### Failed Status
+
+```json
+{
+ "status": "failed",
+ "progress": 0,
+ "form_id": 123,
+ "user_id": 456,
+ "error_message": "Database connection timeout",
+ "created_at": "2024-06-12T09:15:23.000Z",
+ "updated_at": "2024-06-12T09:15:45.000Z",
+ "job_id": "export_abc123def456"
+}
+```
+
+## Response Fields
+
+| Field | Type | Description |
+| ----------------------- | ------ | ---------------------------------------------------- |
+| `status` | string | Job status: `processing`, `completed`, or `failed` |
+| `progress` | number | Completion percentage (0-100) |
+| `form_id` | number | ID of the form being exported |
+| `user_id` | number | ID of the user who initiated the export |
+| `job_id` | string | Export job identifier |
+| `processed_submissions` | number | Number of submissions processed so far |
+| `total_submissions` | number | Total number of submissions to process |
+| `file_url` | string | Download URL for completed exports |
+| `expires_at` | string | File expiration timestamp (24 hours from completion) |
+| `error_message` | string | Error description for failed exports |
+| `created_at` | string | Job creation timestamp |
+| `updated_at` | string | Last update timestamp |
+
+<Note>
+ Only `status`, `progress`, `form_id`, `user_id`, `job_id`, `created_at`, and
+ `updated_at` are always present. Other fields appear based on the job state.
+</Note>
+
+<Warning>
+ Export files are automatically deleted after 24 hours for security and
+ storage management.
+</Warning>
+
+## Error Responses
+
+`404 Not Found` – Export job not found or has expired.
+
+`403 Forbidden` – The token lacks `forms-read` or you don't have access.
+
+## Usage Example
+
+After initiating an export that returns `is_async: true`, poll this endpoint to track progress:
+
+<Steps>
+<Step title="Start export">
+ Call the export endpoint and receive a `job_id`.
+</Step>
+
+<Step title="Poll status">
+ Use the `job_id` to check export progress every few seconds.
+ <Tip>
+ Avoid polling too frequently. Check every 2-5 seconds for optimal
+ performance.
+ </Tip>
+</Step>
+
+<Step title="Download file">
+ When status is `completed`, use the `file_url` to download your CSV file.
+
+ <Warning>
+ Download the file promptly as it expires in 24 hours.
+ </Warning>
+</Step>
+</Steps>
diff --git a/docs/api-reference/submissions/export-submissions-csv.mdx b/docs/api-reference/submissions/export-submissions-csv.mdx
index 38ed2f678..cb607b89b 100644
--- a/docs/api-reference/submissions/export-submissions-csv.mdx
+++ b/docs/api-reference/submissions/export-submissions-csv.mdx
@@ -4,7 +4,7 @@ openapi: post /open/forms/{id}/submissions/export
# Export Submissions (CSV)
-Download a CSV file containing submissions for the specified form.
+Export submissions for a form as a CSV file. Large exports are processed asynchronously in the background, while smaller exports are processed immediately.
## Authentication & Scope
@@ -21,30 +21,53 @@ Authorization: Bearer <token>
### Path Parameters
-| Parameter | Type | Description |
-|-----------|--------|-----------------------------|
-| id | number | Numeric ID of the form. |
+| Parameter | Type | Description |
+| --------- | ------ | ----------------------- |
+| id | number | Numeric ID of the form. |
### Body Parameters
-| Field | Type | Required | Description |
-|---------|-------|----------|-----------------------------------------------------------------------------------------------------------------|
+| Field | Type | Required | Description |
+| ------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------- |
| columns | object | Yes | Keys are field IDs (or `created_at`); values are booleans indicating whether to include the column in the export. |
Example payload exporting two fields and the created_at timestamp:
```json
{
- "columns": {
- "field_name": true,
- "field_email": true,
- "created_at": true
- }
+ "columns": {
+ "field_name": true,
+ "field_email": true,
+ "created_at": true
+ }
}
```
## Response
-`200 OK` – Returns a CSV file download. The response's `Content-Type` will be `text/csv` and include the `Content-Disposition` header.
+The API automatically determines whether to process the export synchronously or asynchronously based on the form size.
-`403 Forbidden` – The token lacks `forms-read` or you don't have access.
\ No newline at end of file
+### Synchronous Export (Small Forms)
+
+`200 OK` – Returns a CSV file download immediately. The response's `Content-Type` will be `text/csv` and include the `Content-Disposition` header.
+
+### Asynchronous Export (Large Forms)
+
+`200 OK` – Returns a job status object for background processing:
+
+```json
+{
+ "message": "Export started. Large export will be processed in the background.",
+ "job_id": "export_abc123def456",
+ "is_async": true
+}
+```
+
+<Note>
+ Use the `job_id` to check export progress using the [Export Status
+ endpoint](/api-reference/submissions/export-status).
+</Note>
+
+### Error Responses
+
+`403 Forbidden` – The token lacks `forms-read` or you don't have access.
diff --git a/docs/api-reference/submissions/list-submissions.mdx b/docs/api-reference/submissions/list-submissions.mdx
index 589047ebf..b3167d478 100644
--- a/docs/api-reference/submissions/list-submissions.mdx
+++ b/docs/api-reference/submissions/list-submissions.mdx
@@ -20,15 +20,18 @@ Authorization: Bearer <token>
### Path Parameters
-| Parameter | Type | Description |
-|-----------|--------|-----------------------------|
-| id | number | Numeric ID of the form. |
+| Parameter | Type | Description |
+| --------- | ------ | ----------------------- |
+| id | number | Numeric ID of the form. |
### Query Parameters
-| Parameter | Type | Required | Description |
-|-----------|--------|----------|----------------------------------------------------|
-| page | number | No | Pagination page number (default `1`). 100 results per page. |
+| Parameter | Type | Required | Description |
+| --------- | ------ | -------- | ------------------------------------------------------------------------ |
+| page | number | No | Pagination page number (default `1`). |
+| per_page | number | No | Number of results per page (default `100`, max `100`). |
+| search | string | No | Search term to filter submissions by field values. |
+| status | string | No | Filter by submission status: `completed`, `partial`, or `all` (default). |
## Response
@@ -36,33 +39,114 @@ Authorization: Bearer <token>
```json
{
- "data": [
- {
- "submission_id": 1,
- "form_id": 123,
- "submitted_at": "2024-06-12T09:15:23Z",
- "data": {
- "First name": "Alice",
- "Email": "[email protected]"
- }
+ "data": [
+ {
+ "data": {
+ "field-id-1": "Sample text response",
+ "field-id-2": ["Option 1", "Option 2"],
+ "field-id-3": [
+ {
+ "file_url": "https://api.opnform.com/open/forms/123/submissions/file/document.pdf?expires=1756808073&signature=abc123...",
+ "file_name": "document.pdf"
+ }
+ ],
+ "status": "completed",
+ "created_at": "2024-06-12 09:15:23",
+ "id": 615432
+ },
+ "completion_time": 45,
+ "form_id": 123,
+ "id": 615432
+ }
+ ],
+ "links": {
+ "first": "https://api.opnform.com/open/forms/123/submissions?page=1",
+ "last": "https://api.opnform.com/open/forms/123/submissions?page=3",
+ "prev": null,
+ "next": "https://api.opnform.com/open/forms/123/submissions?page=2"
+ },
+ "meta": {
+ "current_page": 1,
+ "from": 1,
+ "last_page": 3,
+ "links": [
+ {
+ "url": null,
+ "label": "&laquo; Previous",
+ "active": false
+ },
+ {
+ "url": "https://api.opnform.com/open/forms/123/submissions?page=1",
+ "label": "1",
+ "active": true
+ },
+ {
+ "url": "https://api.opnform.com/open/forms/123/submissions?page=2",
+ "label": "Next &raquo;",
+ "active": false
+ }
+ ],
+ "path": "https://api.opnform.com/open/forms/123/submissions",
+ "per_page": 100,
+ "to": 12,
+ "total": 12
}
- ],
- "links": {
- "first": "https://api.opnform.com/open/forms/123/submissions?page=1",
- "last": "https://api.opnform.com/open/forms/123/submissions?page=3",
- "prev": null,
- "next": "https://api.opnform.com/open/forms/123/submissions?page=2"
- },
- "meta": {
- "current_page": 1,
- "from": 1,
- "last_page": 3,
- "path": "https://api.opnform.com/open/forms/123/submissions",
- "per_page": 100,
- "to": 100,
- "total": 250
- }
}
```
-`403 Forbidden` – The token lacks `forms-read`.
\ No newline at end of file
+### Response Fields
+
+Each submission object contains:
+
+| Field | Type | Description |
+| ----------------- | ----------- | ------------------------------------------- |
+| `data` | object | Contains form field responses plus metadata |
+| `completion_time` | number/null | Time taken to complete the form in seconds |
+| `form_id` | number | ID of the parent form |
+| `id` | number | Unique submission ID |
+
+#### Data Object Structure
+
+The `data` object contains:
+
+- **Form field responses**: Keyed by field UUID, values vary by field type
+- **Metadata fields**:
+ - `status`: Submission status (`completed` or `partial`)
+ - `created_at`: Submission creation timestamp
+ - `id`: Submission ID (duplicate for convenience)
+
+#### File Field Handling
+
+File and signature fields are automatically processed to include download URLs:
+
+```json
+"field-uuid": [
+ {
+ "file_url": "https://api.opnform.com/open/forms/123/submissions/file/filename.pdf?expires=1756808073&signature=abc123...",
+ "file_name": "filename.pdf"
+ }
+]
+```
+
+<Note>File URLs are signed and expire after 10 minutes for security.</Note>
+
+### Query Parameter Details
+
+#### Search Functionality
+
+- Searches within submission field **values only** (not field names/keys)
+- Uses case-insensitive matching
+- Supports partial text matching
+
+#### Status Filtering
+
+- `completed`: Returns only fully completed submissions
+- `partial`: Returns only partially completed submissions (Pro feature)
+- `all` or omitted: Returns all submissions regardless of status
+
+#### Pagination
+
+- Default `per_page` is 100, maximum is 100
+- Results are ordered by `created_at` in descending order (newest first)
+
+`403 Forbidden` – The token lacks `forms-read`.
diff --git a/docs/docs.json b/docs/docs.json
index 90e88e903..fb1e825b6 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -91,6 +91,7 @@
"api-reference/submissions/list-submissions",
"api-reference/submissions/create-submission",
"api-reference/submissions/export-submissions-csv",
+ "api-reference/submissions/export-status",
"api-reference/submissions/update-submission",
"api-reference/submissions/delete-submission"
]