Skip to main content

Get All Forms

Retrieve all forms belonging to the authenticated user, including response counts.

Endpoint

GET /api/getAllForms

Authentication

Requires Clerk authentication. Only returns forms owned by the authenticated user.

Response

success
boolean
Always true for successful requests
forms
array
Array of form objects ordered by creation date (newest first)

Example Request

curl -X GET https://your-domain.com/api/getAllForms \
  -H "Cookie: __session=your-clerk-session"

Example Response

{
  "success": true,
  "forms": [
    {
      "id": "cm3x7y2z1a0b1c2d3e4f5",
      "title": "Customer Feedback Form",
      "createdAt": "2026-03-01T10:30:00.000Z",
      "_count": {
        "responses": 42
      }
    },
    {
      "id": "cm3a1b2c3d4e5f6g7h8i9",
      "title": "Event Registration",
      "createdAt": "2026-02-28T15:45:00.000Z",
      "_count": {
        "responses": 15
      }
    }
  ]
}
Source: app/api/getAllForms/route.ts:5

Get Form

Retrieve a specific form by its ID or slug. This endpoint is public and does not require authentication.

Endpoint

GET /api/forms/[id]

Parameters

id
string
required
Form identifier - can be either the form’s UUID or its URL-friendly slug

Response

success
boolean
Always true for successful requests
data
object
Complete form object including all fields

Example Request

# By ID
curl -X GET https://your-domain.com/api/forms/cm3x7y2z1a0b1c2d3e4f5

# By slug
curl -X GET https://your-domain.com/api/forms/customer-feedback-abc123

Example Response

{
  "success": true,
  "data": {
    "id": "cm3x7y2z1a0b1c2d3e4f5",
    "slug": "customer-feedback-abc123",
    "userId": "user_2abc123xyz",
    "title": "Customer Feedback Form",
    "fields": [
      {
        "id": "name",
        "label": "Your Name",
        "type": "text",
        "required": true
      },
      {
        "id": "email",
        "label": "Email Address",
        "type": "email",
        "required": true
      },
      {
        "id": "rating",
        "label": "Rating",
        "type": "number",
        "required": true
      }
    ],
    "isPublished": true,
    "createdAt": "2026-03-01T10:30:00.000Z"
  }
}
Source: app/api/forms/[id]/route.ts:12

Delete Form

Permanently delete a form and all its associated responses.

Endpoint

DELETE /api/forms/[id]

Authentication

Requires Clerk authentication. You can only delete forms you own.

Parameters

id
string
required
The UUID of the form to delete

Response

success
boolean
Always true for successful deletions
data
object
The deleted form object

Example Request

curl -X DELETE https://your-domain.com/api/forms/cm3x7y2z1a0b1c2d3e4f5 \
  -H "Cookie: __session=your-clerk-session"

Example Response

{
  "success": true,
  "data": {
    "id": "cm3x7y2z1a0b1c2d3e4f5",
    "title": "Customer Feedback Form",
    "userId": "user_2abc123xyz",
    "slug": "customer-feedback-abc123",
    "fields": [...],
    "isPublished": true,
    "createdAt": "2026-03-01T10:30:00.000Z"
  }
}

Error Responses

Source: app/api/forms/[id]/route.ts:57

Toggle Publish Status

Toggle a form’s isPublished status between true and false.

Endpoint

PATCH /api/forms/[id]

Authentication

Requires Clerk authentication. You can only update forms you own.

Parameters

id
string
required
The UUID of the form to update

Response

success
boolean
Always true for successful updates
data
object
The updated form object with the new isPublished value

Example Request

curl -X PATCH https://your-domain.com/api/forms/cm3x7y2z1a0b1c2d3e4f5 \
  -H "Cookie: __session=your-clerk-session"

Example Response

{
  "success": true,
  "data": {
    "id": "cm3x7y2z1a0b1c2d3e4f5",
    "title": "Customer Feedback Form",
    "userId": "user_2abc123xyz",
    "slug": "customer-feedback-abc123",
    "fields": [...],
    "isPublished": false,
    "createdAt": "2026-03-01T10:30:00.000Z"
  }
}
Source: app/api/forms/[id]/route.ts:109