Skip to content

Beautiful Open-Source Form Builder

feat: Introduce Public API with Sanctum Token Authentication (#788)

Julien Nahumc1f8765a1a9a
diff --git a/.cursor/rules/docs.mdc b/.cursor/rules/docs.mdc
new file mode 100644
index 000000000..491e8878a
--- /dev/null
+++ b/.cursor/rules/docs.mdc
@@ -0,0 +1,364 @@
+---
+description:
+globs: docs/**/*.*
+alwaysApply: false
+---
+# Mintlify technical writing assistant
+
+You are an AI writing assistant specialized in creating exceptional technical documentation using Mintlify components and following industry-leading technical writing practices.
+
+## Core writing principles
+
+### Language and style requirements
+- Use clear, direct language appropriate for technical audiences
+- Write in second person ("you") for instructions and procedures
+- Use active voice over passive voice
+- Employ present tense for current states, future tense for outcomes
+- Maintain consistent terminology throughout all documentation
+- Keep sentences concise while providing necessary context
+- Use parallel structure in lists, headings, and procedures
+
+### Content organization standards
+- Lead with the most important information (inverted pyramid structure)
+- Use progressive disclosure: basic concepts before advanced ones
+- Break complex procedures into numbered steps
+- Include prerequisites and context before instructions
+- Provide expected outcomes for each major step
+- End sections with next steps or related information
+- Use descriptive, keyword-rich headings for navigation and SEO
+
+### User-centered approach
+- Focus on user goals and outcomes rather than system features
+- Anticipate common questions and address them proactively
+- Include troubleshooting for likely failure points
+- Provide multiple pathways when appropriate (beginner vs advanced), but offer an opinionated path for people to follow to avoid overwhelming with options
+
+## Mintlify component reference
+
+### Callout components
+
+#### Note - Additional helpful information
+
+<Note>
+Supplementary information that supports the main content without interrupting flow
+</Note>
+
+#### Tip - Best practices and pro tips
+
+<Tip>
+Expert advice, shortcuts, or best practices that enhance user success
+</Tip>
+
+#### Warning - Important cautions
+
+<Warning>
+Critical information about potential issues, breaking changes, or destructive actions
+</Warning>
+
+#### Info - Neutral contextual information
+
+<Info>
+Background information, context, or neutral announcements
+</Info>
+
+#### Check - Success confirmations
+
+<Check>
+Positive confirmations, successful completions, or achievement indicators
+</Check>
+
+### Code components
+
+#### Single code block
+
+```javascript config.js
+const apiConfig = {
+baseURL: 'https://api.example.com',
+timeout: 5000,
+headers: {
+ 'Authorization': `Bearer ${process.env.API_TOKEN}`
+}
+};
+```
+
+#### Code group with multiple languages
+
+<CodeGroup>
+```javascript Node.js
+const response = await fetch('/api/endpoint', {
+ headers: { Authorization: `Bearer ${apiKey}` }
+});
+```
+
+```python Python
+import requests
+response = requests.get('/api/endpoint',
+ headers={'Authorization': f'Bearer {api_key}'})
+```
+
+```curl cURL
+curl -X GET '/api/endpoint' \
+ -H 'Authorization: Bearer YOUR_API_KEY'
+```
+</CodeGroup>
+
+#### Request/Response examples
+
+<RequestExample>
+```bash cURL
+curl -X POST 'https://api.example.com/users' \
+ -H 'Content-Type: application/json' \
+ -d '{"name": "John Doe", "email": "[email protected]"}'
+```
+</RequestExample>
+
+<ResponseExample>
+```json Success
+{
+ "id": "user_123",
+ "name": "John Doe",
+ "email": "[email protected]",
+ "created_at": "2024-01-15T10:30:00Z"
+}
+```
+</ResponseExample>
+
+### Structural components
+
+#### Steps for procedures
+
+<Steps>
+<Step title="Install dependencies">
+ Run `npm install` to install required packages.
+
+ <Check>
+ Verify installation by running `npm list`.
+ </Check>
+</Step>
+
+<Step title="Configure environment">
+ Create a `.env` file with your API credentials.
+
+ ```bash
+ API_KEY=your_api_key_here
+ ```
+
+ <Warning>
+ Never commit API keys to version control.
+ </Warning>
+</Step>
+</Steps>
+
+#### Tabs for alternative content
+
+<Tabs>
+<Tab title="macOS">
+ ```bash
+ brew install node
+ npm install -g package-name
+ ```
+</Tab>
+
+<Tab title="Windows">
+ ```powershell
+ choco install nodejs
+ npm install -g package-name
+ ```
+</Tab>
+
+<Tab title="Linux">
+ ```bash
+ sudo apt install nodejs npm
+ npm install -g package-name
+ ```
+</Tab>
+</Tabs>
+
+#### Accordions for collapsible content
+
+<AccordionGroup>
+<Accordion title="Troubleshooting connection issues">
+ - **Firewall blocking**: Ensure ports 80 and 443 are open
+ - **Proxy configuration**: Set HTTP_PROXY environment variable
+ - **DNS resolution**: Try using 8.8.8.8 as DNS server
+</Accordion>
+
+<Accordion title="Advanced configuration">
+ ```javascript
+ const config = {
+ performance: { cache: true, timeout: 30000 },
+ security: { encryption: 'AES-256' }
+ };
+ ```
+</Accordion>
+</AccordionGroup>
+
+### API documentation components
+
+#### Parameter fields
+
+<ParamField path="user_id" type="string" required>
+Unique identifier for the user. Must be a valid UUID v4 format.
+</ParamField>
+
+<ParamField body="email" type="string" required>
+User's email address. Must be valid and unique within the system.
+</ParamField>
+
+<ParamField query="limit" type="integer" default="10">
+Maximum number of results to return. Range: 1-100.
+</ParamField>
+
+<ParamField header="Authorization" type="string" required>
+Bearer token for API authentication. Format: `Bearer YOUR_API_KEY`
+</ParamField>
+
+#### Response fields
+
+<ResponseField name="user_id" type="string" required>
+Unique identifier assigned to the newly created user.
+</ResponseField>
+
+<ResponseField name="created_at" type="timestamp">
+ISO 8601 formatted timestamp of when the user was created.
+</ResponseField>
+
+<ResponseField name="permissions" type="array">
+List of permission strings assigned to this user.
+</ResponseField>
+
+#### Expandable nested fields
+
+<ResponseField name="user" type="object">
+Complete user object with all associated data.
+
+<Expandable title="User properties">
+ <ResponseField name="profile" type="object">
+ User profile information including personal details.
+
+ <Expandable title="Profile details">
+ <ResponseField name="first_name" type="string">
+ User's first name as entered during registration.
+ </ResponseField>
+
+ <ResponseField name="avatar_url" type="string | null">
+ URL to user's profile picture. Returns null if no avatar is set.
+ </ResponseField>
+ </Expandable>
+ </ResponseField>
+</Expandable>
+</ResponseField>
+
+### Interactive components
+
+#### Cards for navigation
+
+<Card title="Getting started guide" icon="rocket" href="/quickstart">
+Complete walkthrough from installation to your first API call in under 10 minutes.
+</Card>
+
+<CardGroup cols={2}>
+<Card title="Authentication" icon="key" href="/auth">
+ Learn how to authenticate requests using API keys or JWT tokens.
+</Card>
+
+<Card title="Rate limiting" icon="clock" href="/rate-limits">
+ Understand rate limits and best practices for high-volume usage.
+</Card>
+</CardGroup>
+
+### Media and advanced components
+
+#### Frames for images
+
+Wrap all images in frames.
+
+<Frame>
+<img src="/images/dashboard.png" alt="Main dashboard showing analytics overview" />
+</Frame>
+
+<Frame caption="The analytics dashboard provides real-time insights">
+<img src="/images/analytics.png" alt="Analytics dashboard with charts" />
+</Frame>
+
+#### Tooltips and updates
+
+<Tooltip tip="Application Programming Interface - protocols for building software">
+API
+</Tooltip>
+
+<Update label="Version 2.1.0" description="Released March 15, 2024">
+## New features
+- Added bulk user import functionality
+- Improved error messages with actionable suggestions
+
+## Bug fixes
+- Fixed pagination issue with large datasets
+- Resolved authentication timeout problems
+</Update>
+
+## Required page structure
+
+Every documentation page must begin with YAML frontmatter:
+
+```yaml
+---
+title: "Clear, specific, keyword-rich title"
+description: "Concise description explaining page purpose and value"
+---
+```
+
+## Content quality standards
+
+### Code examples requirements
+- Always include complete, runnable examples that users can copy and execute
+- Show proper error handling and edge case management
+- Use realistic data instead of placeholder values
+- Include expected outputs and results for verification
+- Test all code examples thoroughly before publishing
+- Specify language and include filename when relevant
+- Add explanatory comments for complex logic
+
+### API documentation requirements
+- Document all parameters including optional ones with clear descriptions
+- Show both success and error response examples with realistic data
+- Include rate limiting information with specific limits
+- Provide authentication examples showing proper format
+- Explain all HTTP status codes and error handling
+- Cover complete request/response cycles
+
+### Accessibility requirements
+- Include descriptive alt text for all images and diagrams
+- Use specific, actionable link text instead of "click here"
+- Ensure proper heading hierarchy starting with H2
+- Provide keyboard navigation considerations
+- Use sufficient color contrast in examples and visuals
+- Structure content for easy scanning with headers and lists
+
+## AI assistant instructions
+
+### Component selection logic
+- Use **Steps** for procedures, tutorials, setup guides, and sequential instructions
+- Use **Tabs** for platform-specific content or alternative approaches
+- Use **CodeGroup** when showing the same concept in multiple languages
+- Use **Accordions** for supplementary information that might interrupt flow
+- Use **Cards and CardGroup** for navigation, feature overviews, and related resources
+- Use **RequestExample/ResponseExample** specifically for API endpoint documentation
+- Use **ParamField** for API parameters, **ResponseField** for API responses
+- Use **Expandable** for nested object properties or hierarchical information
+
+### Quality assurance checklist
+- Verify all code examples are syntactically correct and executable
+- Test all links to ensure they are functional and lead to relevant content
+- Validate Mintlify component syntax with all required properties
+- Confirm proper heading hierarchy with H2 for main sections, H3 for subsections
+- Ensure content flows logically from basic concepts to advanced topics
+- Check for consistency in terminology, formatting, and component usage
+
+### Error prevention strategies
+- Always include realistic error handling in code examples
+- Provide dedicated troubleshooting sections for complex procedures
+- Explain prerequisites clearly before beginning instructions
+- Include verification and testing steps with expected outcomes
+- Add appropriate warnings for destructive or security-sensitive actions
+- Validate all technical information through testing before publication
\ No newline at end of file
diff --git a/api/app/Console/Commands/EmailNotificationMigration.php b/api/app/Console/Commands/EmailNotificationMigration.php
deleted file mode 100644
index bed297ec3..000000000
--- a/api/app/Console/Commands/EmailNotificationMigration.php
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Models\Forms\Form;
-use App\Models\Integration\FormIntegration;
-use Illuminate\Console\Command;
-
-class EmailNotificationMigration extends Command
-{
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'forms:email-notification-migration {--dry : Log changes without applying them}';
-
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'One Time Only -- Migrate Email & Submission Notifications to new Email Integration';
-
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- if (app()->environment('production')) {
- if (!$this->confirm('Are you sure you want to run this migration in production?')) {
- $this->info('Migration aborted.');
- return 0;
- }
- }
- $query = FormIntegration::whereIn('integration_id', ['email', 'submission_confirmation'])
- ->whereHas('form');
- $totalCount = $query->count();
- $progressBar = $this->output->createProgressBar($totalCount);
- $progressBar->start();
-
- $isDryRun = $this->option('dry');
-
- $query->with('form')->chunk(100, function ($integrations) use ($progressBar, $isDryRun) {
- foreach ($integrations as $integration) {
- try {
- $this->updateIntegration($integration, $isDryRun);
- } catch (\Exception $e) {
- $this->error('Error updating integration ' . $integration->id . '. Error: ' . $e->getMessage());
- ray($e);
- }
- $progressBar->advance();
- }
- });
-
- $progressBar->finish();
- $this->newLine();
-
- $this->line('Migration Done');
- }
-
- public function updateIntegration(FormIntegration $integration, $isDryRun = false)
- {
- if (!$integration->form) {
- return;
- }
- $existingData = $integration->data;
- if ($integration->integration_id === 'email' && isset($existingData->notification_emails)) {
- $newData = [
- 'send_to' => $existingData->notification_emails ?? null,
- 'sender_name' => 'OpnForm',
- 'subject' => 'New form submission',
- 'email_content' => 'Hello there πŸ‘‹ <br>New form submission received.',
- 'include_submission_data' => true,
- 'include_hidden_fields_submission_data' => false,
- 'reply_to' => $existingData->notification_reply_to ?? null
- ];
- if ($isDryRun) {
- $this->info('Dry run: Would update integration ' . $integration->id . ' with data: ' . json_encode($newData));
- } else {
- $integration->data = $newData;
- return $integration->save();
- }
- } elseif ($integration->integration_id === 'submission_confirmation' && isset($existingData->notification_subject)) {
- $newData = [
- 'send_to' => $this->getMentionHtml($integration->form),
- 'sender_name' => $existingData->notification_sender,
- 'subject' => $existingData->notification_subject,
- 'email_content' => $existingData->notification_body,
- 'include_submission_data' => $existingData->notifications_include_submission,
- 'include_hidden_fields_submission_data' => false,
- 'reply_to' => $existingData->confirmation_reply_to ?? null
- ];
- if ($isDryRun) {
- $this->info('Dry run: Would update integration ' . $integration->id . ' with data: ' . json_encode($newData));
- } else {
- $integration->integration_id = 'email';
- $integration->data = $newData;
- return $integration->save();
- }
- }
- return;
- }
-
- private function getMentionHtml(Form $form)
- {
- $emailField = $this->getRespondentEmail($form);
- return $emailField ? '<span mention-field-id="' . $emailField['id'] . '" mention-field-name="' . $emailField['name'] . '" mention-fallback="" contenteditable="false" mention="true">' . $emailField['name'] . '</span>' : '';
- }
-
- private function getRespondentEmail(Form $form)
- {
- $emailFields = collect($form->properties)->filter(function ($field) {
- $hidden = $field['hidden'] ?? false;
- return !$hidden && $field['type'] == 'email';
- });
-
- return $emailFields->count() > 0 ? $emailFields->first() : null;
- }
-}
diff --git a/api/app/Console/Commands/FormTitleMigration.php b/api/app/Console/Commands/FormTitleMigration.php
deleted file mode 100644
index 05c3d12aa..000000000
--- a/api/app/Console/Commands/FormTitleMigration.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-namespace App\Console\Commands;
-
-use App\Models\Forms\Form;
-use App\Models\Template;
-use Illuminate\Console\Command;
-use Illuminate\Support\Str;
-
-class FormTitleMigration extends Command
-{
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'forms:form-title-migration';
-
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'One Time Only -- Migrate Form Title to new Form Title';
-
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- $this->formMigration();
-
- $this->formTemplateMigration();
-
- $this->line('Migration Done');
- }
-
- public function formMigration()
- {
- $this->info('Starting forms migration...');
-
- Form::chunk(100, function ($forms) {
- foreach ($forms as $form) {
- if ($form?->hide_title ?? false) {
- continue;
- }
-
- $properties = $form->properties ?? [];
-
- array_unshift($properties, [
- 'type' => 'nf-text',
- 'content' => '<h1>' . $form->title . '</h1>',
- 'name' => 'Title',
- 'align' => $form->layout_rtl ? 'right' : 'left',
- 'id' => Str::uuid()
- ]);
-
- $form->properties = $properties;
- $form->timestamps = false;
- $form->save();
- }
- });
- }
-
- public function formTemplateMigration()
- {
- $this->info('Starting forms template migration...');
-
- Template::chunk(100, function ($templates) {
- foreach ($templates as $template) {
- $structure = $template->structure ?? [];
- if (!$structure) {
- continue;
- }
-
- $properties = $structure['properties'] ?? [];
-
- array_unshift($properties, [
- 'type' => 'nf-text',
- 'content' => '<h1>' . $structure['title'] . '</h1>',
- 'name' => 'Title',
- 'align' => isset($structure['layout_rtl']) && $structure['layout_rtl'] ? 'right' : 'left',
- 'id' => Str::uuid()
- ]);
-
- $structure['properties'] = $properties;
- $template->structure = $structure;
- $template->timestamps = false;
- $template->save();
- }
- });
- }
-}
diff --git a/api/app/Enums/AccessTokenAbility.php b/api/app/Enums/AccessTokenAbility.php
index 1935a8943..e6adea251 100644
--- a/api/app/Enums/AccessTokenAbility.php
+++ b/api/app/Enums/AccessTokenAbility.php
@@ -7,8 +7,18 @@ use Illuminate\Support\Arr;
enum AccessTokenAbility: string
{
case ManageIntegrations = 'manage-integrations';
- case ListForms = 'list-forms';
- case ListWorkspaces = 'list-workspaces';
+ // Granular scopes
+ // Forms
+ case FormsRead = 'forms-read';
+ case FormsWrite = 'forms-write';
+
+ // Workspaces
+ case WorkspacesRead = 'workspaces-read';
+ case WorkspacesWrite = 'workspaces-write';
+
+ // Workspace Users
+ case WorkspaceUsersRead = 'workspace-users-read';
+ case WorkspaceUsersWrite = 'workspace-users-write';
public static function values(): array
{
diff --git a/api/app/Http/Controllers/Forms/FormController.php b/api/app/Http/Controllers/Forms/FormController.php
index c98174ac0..cd6caa36b 100644
--- a/api/app/Http/Controllers/Forms/FormController.php
+++ b/api/app/Http/Controllers/Forms/FormController.php
@@ -31,7 +31,7 @@ class FormController extends Controller
public function index($workspaceId)
{
$workspace = Workspace::findOrFail($workspaceId);
- $this->authorize('view', $workspace);
+ $this->authorize('ownsWorkspace', $workspace);
$this->authorize('viewAny', Form::class);
$workspaceIsPro = $workspace->is_pro;
@@ -85,7 +85,7 @@ class FormController extends Controller
{
$forms = collect();
foreach (Auth::user()->workspaces as $workspace) {
- $this->authorize('view', $workspace);
+ $this->authorize('ownsWorkspace', $workspace);
$this->authorize('viewAny', Form::class);
$workspaceIsPro = $workspace->is_pro;
@@ -109,7 +109,7 @@ class FormController extends Controller
public function store(StoreFormRequest $request)
{
$workspace = Workspace::findOrFail($request->get('workspace_id'));
- $this->authorize('view', $workspace);
+ $this->authorize('ownsWorkspace', $workspace);
$this->authorize('create', [Form::class, $workspace]);
$formData = $this->formCleaner
@@ -276,7 +276,7 @@ class FormController extends Controller
$workspace = Workspace::findOrFail($workspace_id);
$this->authorize('update', $form);
- $this->authorize('view', $workspace);
+ $this->authorize('ownsWorkspace', $workspace);
$form->workspace_id = $workspace_id;
$form->creator_id = auth()->user()->id;
diff --git a/api/app/Http/Controllers/Forms/FormSubmissionController.php b/api/app/Http/Controllers/Forms/FormSubmissionController.php
index 65ff02f16..3b91115de 100644
--- a/api/app/Http/Controllers/Forms/FormSubmissionController.php
+++ b/api/app/Http/Controllers/Forms/FormSubmissionController.php
@@ -105,4 +105,17 @@ class FormSubmissionController extends Controller
Storage::temporaryUrl($fileName, now()->addMinute())
);
}
+
+ public function destroy($id, $submissionId)
+ {
+ $form = Form::findOrFail((int) $id);
+ $this->authorize('delete', $form);
+
+ $submission = $form->submissions()->where('id', $submissionId)->firstOrFail();
+ $submission->delete();
+
+ return $this->success([
+ 'message' => 'Record successfully removed.',
+ ]);
+ }
}
diff --git a/api/app/Http/Controllers/Forms/RecordController.php b/api/app/Http/Controllers/Forms/RecordController.php
deleted file mode 100644
index 8b69bc4e6..000000000
--- a/api/app/Http/Controllers/Forms/RecordController.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Forms;
-
-use App\Http\Controllers\Controller;
-use App\Models\Forms\Form;
-use Illuminate\Http\Request;
-
-class RecordController extends Controller
-{
- public function delete(Request $request, $id, $recordId)
- {
- $form = Form::findOrFail((int) $id);
- $this->authorize('delete', $form);
-
- $record = $form->submissions()->where('id', $recordId)->firstOrFail();
- $record->delete();
-
- return $this->success([
- 'message' => 'Record successfully removed.',
- ]);
- }
-}
diff --git a/api/app/Http/Controllers/Integrations/Zapier/ListFormsController.php b/api/app/Http/Controllers/Integrations/Zapier/ListFormsController.php
index 34e677605..bd05834ef 100644
--- a/api/app/Http/Controllers/Integrations/Zapier/ListFormsController.php
+++ b/api/app/Http/Controllers/Integrations/Zapier/ListFormsController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Integrations\Zapier;
use App\Http\Requests\Zapier\ListFormsRequest;
use App\Http\Resources\Zapier\FormResource;
+use App\Models\Forms\Form;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class ListFormsController
@@ -14,7 +15,8 @@ class ListFormsController
{
$workspace = $request->workspace();
- $this->authorize('view', $workspace);
+ $this->authorize('ownsWorkspace', $workspace);
+ $this->authorize('viewAny', Form::class);
return FormResource::collection(
$workspace->forms()->get()
diff --git a/api/app/Http/Controllers/WorkspaceController.php b/api/app/Http/Controllers/WorkspaceController.php
index 9d0ac6946..c5797d04e 100644
--- a/api/app/Http/Controllers/WorkspaceController.php
+++ b/api/app/Http/Controllers/WorkspaceController.php
@@ -66,6 +66,8 @@ class WorkspaceController extends Controller
public function create(Request $request)
{
+ $this->authorize('create', Workspace::class);
+
$user = $request->user();
$this->validate($request, [
diff --git a/api/app/Http/Kernel.php b/api/app/Http/Kernel.php
index 2ec1c5df5..a1ec214fc 100644
--- a/api/app/Http/Kernel.php
+++ b/api/app/Http/Kernel.php
@@ -4,6 +4,7 @@ namespace App\Http;
use App\Http\Middleware\AcceptsJsonMiddleware;
use App\Http\Middleware\AuthenticateJWT;
+use App\Http\Middleware\AuthenticateWithJwtOrSanctum;
use App\Http\Middleware\CustomDomainRestriction;
use App\Http\Middleware\DevCorsMiddleware;
use App\Http\Middleware\ImpersonationMiddleware;
@@ -11,6 +12,7 @@ use App\Http\Middleware\IsAdmin;
use App\Http\Middleware\IsModerator;
use App\Http\Middleware\IsNotSubscribed;
use App\Http\Middleware\IsSubscribed;
+use App\Http\Middleware\RequireProPlan;
use App\Http\Middleware\SelfHostedCredentialsMiddleware;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
@@ -38,6 +40,30 @@ class Kernel extends HttpKernel
AcceptsJsonMiddleware::class,
];
+ /**
+ * The priority-sorted list of middleware.
+ *
+ * Forces non-global middleware to always be in the given order.
+ *
+ * @var string[]
+ */
+ protected $middlewarePriority = [
+ \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
+ \Illuminate\Cookie\Middleware\EncryptCookies::class,
+ \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
+ \Illuminate\Session\Middleware\StartSession::class,
+ \Illuminate\View\Middleware\ShareErrorsFromSession::class,
+ AuthenticateJWT::class,
+ AuthenticateWithJwtOrSanctum::class,
+ \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class,
+ \Illuminate\Routing\Middleware\ThrottleRequests::class,
+ \Illuminate\Routing\Middleware\ThrottleRequestsWithRedis::class,
+ \Illuminate\Contracts\Session\Middleware\AuthenticatesSessions::class,
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ \Illuminate\Auth\Middleware\Authorize::class,
+ ];
+
+
/**
* The application's route middleware groups.
*
@@ -60,9 +86,9 @@ class Kernel extends HttpKernel
'api' => [
'throttle:100,1',
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Session\Middleware\StartSession::class,
+ \Illuminate\Routing\Middleware\SubstituteBindings::class,
SelfHostedCredentialsMiddleware::class,
ImpersonationMiddleware::class,
],
@@ -87,6 +113,7 @@ class Kernel extends HttpKernel
'moderator' => IsModerator::class,
'subscribed' => IsSubscribed::class,
'not-subscribed' => IsNotSubscribed::class,
+ 'require-pro' => RequireProPlan::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
@@ -100,5 +127,6 @@ class Kernel extends HttpKernel
'abilities' => \Laravel\Sanctum\Http\Middleware\CheckAbilities::class,
'ability' => \Laravel\Sanctum\Http\Middleware\CheckForAnyAbility::class,
+ 'auth.multi' => \App\Http\Middleware\AuthenticateWithJwtOrSanctum::class,
];
}
diff --git a/api/app/Http/Middleware/AuthenticateWithJwtOrSanctum.php b/api/app/Http/Middleware/AuthenticateWithJwtOrSanctum.php
new file mode 100644
index 000000000..07a594dac
--- /dev/null
+++ b/api/app/Http/Middleware/AuthenticateWithJwtOrSanctum.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Auth\AuthenticationException;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+
+class AuthenticateWithJwtOrSanctum
+{
+ /**
+ * Handle an incoming request by authenticating via JWT or Sanctum.
+ */
+ public function handle(Request $request, Closure $next)
+ {
+ // 1. Attempt authentication via the default 'api' guard (JWT)
+ if (Auth::guard('api')->check()) {
+ Auth::shouldUse('api');
+ return $next($request);
+ }
+
+ // 2. Fallback to Sanctum guard
+ if (Auth::guard('sanctum')->check()) {
+ $user = Auth::guard('sanctum')->user();
+
+ // Check if user is pro before allowing Sanctum authentication
+ if (!$user->is_pro) {
+ throw new AuthenticationException('Pro subscription required for API access.');
+ }
+
+ Auth::setUser($user);
+
+ // Validate route against whitelist
+ $routeName = $request->route()?->getName();
+ $allowedRoutes = config('sanctum-routes.allowed', []);
+
+ if (! $routeName || ! in_array($routeName, $allowedRoutes, true)) {
+ // Return 404 to avoid revealing route existence
+ throw new NotFoundHttpException();
+ }
+
+ return $next($request);
+ }
+
+ // 3. Neither guard could authenticate
+ throw new AuthenticationException();
+ }
+}
diff --git a/api/app/Http/Middleware/ImpersonationMiddleware.php b/api/app/Http/Middleware/ImpersonationMiddleware.php
index 6cd31873f..a75ce6d32 100644
--- a/api/app/Http/Middleware/ImpersonationMiddleware.php
+++ b/api/app/Http/Middleware/ImpersonationMiddleware.php
@@ -4,6 +4,8 @@ namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Log;
use Tymon\JWTAuth\Exceptions\JWTException;
class ImpersonationMiddleware
@@ -71,7 +73,7 @@ class ImpersonationMiddleware
public function handle(Request $request, Closure $next)
{
try {
- if (!auth()->check() || !auth()->payload()->get('impersonating')) {
+ if (!Auth::guard('api')->check() || !Auth::guard('api')->payload()->get('impersonating')) {
return $next($request);
}
} catch (JWTException $e) {
@@ -84,17 +86,17 @@ class ImpersonationMiddleware
return response([
'message' => 'Unauthorized when impersonating',
'route' => $routeName,
- 'impersonator' => auth()->payload()->get('impersonator_id'),
- 'impersonated_account' => auth()->id(),
+ 'impersonator' => Auth::guard('api')->payload()->get('impersonator_id'),
+ 'impersonated_account' => Auth::id(),
'url' => $request->fullUrl(),
'payload' => $request->all(),
], 403);
} elseif (in_array($routeName, self::LOG_ROUTES)) {
- \Log::warning(self::ADMIN_LOG_PREFIX . 'Impersonator action', [
+ Log::warning(self::ADMIN_LOG_PREFIX . 'Impersonator action', [
'route' => $routeName,
'url' => $request->fullUrl(),
- 'impersonated_account' => auth()->id(),
- 'impersonator' => auth()->payload()->get('impersonator_id'),
+ 'impersonated_account' => Auth::id(),
+ 'impersonator' => Auth::guard('api')->payload()->get('impersonator_id'),
'payload' => $request->all(),
]);
}
diff --git a/api/app/Http/Middleware/RequireProPlan.php b/api/app/Http/Middleware/RequireProPlan.php
new file mode 100644
index 000000000..a28af4b04
--- /dev/null
+++ b/api/app/Http/Middleware/RequireProPlan.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+
+class RequireProPlan
+{
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @return mixed
+ */
+ public function handle(Request $request, Closure $next)
+ {
+ if (!Auth::user()->is_pro) {
+ return response()->json([
+ 'message' => 'A Pro plan is required to use this feature.',
+ ], 402);
+ }
+
+ return $next($request);
+ }
+}
diff --git a/api/app/Http/Requests/UserFormRequest.php b/api/app/Http/Requests/UserFormRequest.php
index 10da80a86..f3e02bf8f 100644
--- a/api/app/Http/Requests/UserFormRequest.php
+++ b/api/app/Http/Requests/UserFormRequest.php
@@ -66,10 +66,12 @@ abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
];
// Log to both default channel and Slack
- Log::channel('combined')->warning(
- 'Frontend validation bypass detected in form submission',
- $logData
- );
+ if (!in_array(\App::environment(), ['testing'])) {
+ Log::channel('combined')->warning(
+ 'Frontend validation bypass detected in form submission',
+ $logData
+ );
+ }
throw new ValidationException($validator);
}
diff --git a/api/app/Http/Resources/UserResource.php b/api/app/Http/Resources/UserResource.php
index a126648ac..03371f3f1 100644
--- a/api/app/Http/Resources/UserResource.php
+++ b/api/app/Http/Resources/UserResource.php
@@ -15,6 +15,7 @@ class UserResource extends JsonResource
public function toArray($request)
{
$personalData = \Auth::id() === $this->id ? [
+ 'is_pro' => $this->is_pro,
'is_subscribed' => $this->is_subscribed,
'has_enterprise_subscription' => $this->has_enterprise_subscription,
'admin' => $this->admin,
diff --git a/api/app/Models/User.php b/api/app/Models/User.php
index 547337cf3..ff37aefbf 100644
--- a/api/app/Models/User.php
+++ b/api/app/Models/User.php
@@ -133,6 +133,13 @@ class User extends Authenticatable implements JWTSubject
return $this->admin || in_array($this->email, config('opnform.template_editor_emails'));
}
+ public function getIsProAttribute()
+ {
+ return $this->workspaces()->get()->some(function ($workspace) {
+ return $workspace->is_pro;
+ });
+ }
+
/**
* =================================
* Helper Related
diff --git a/api/app/Policies/FormPolicy.php b/api/app/Policies/FormPolicy.php
index bdf16ca48..5aabf2bc6 100644
--- a/api/app/Policies/FormPolicy.php
+++ b/api/app/Policies/FormPolicy.php
@@ -18,6 +18,11 @@ class FormPolicy
*/
public function viewAny(User $user)
{
+ // Check if authenticated via Sanctum token
+ if ($token = $user->currentAccessToken()) {
+ return $token->can('forms-read');
+ }
+
return true;
}
@@ -28,6 +33,13 @@ class FormPolicy
*/
public function view(User $user, Form $form)
{
+ // Check if authenticated via Sanctum token
+ if ($token = $user->currentAccessToken()) {
+ $canAccess = $token->can('forms-read') || $token->can('manage-integrations');
+ return $canAccess && $user->ownsForm($form);
+ }
+
+ // Fallback to JWT / session logic
return $user->ownsForm($form);
}
@@ -38,7 +50,13 @@ class FormPolicy
*/
public function create(User $user, Workspace $workspace)
{
- return !$workspace->isReadonlyUser($user);
+ $userIsNotReadonly = !$workspace->isReadonlyUser($user);
+ // If using Sanctum token, ensure the token has write ability
+ if ($token = $user->currentAccessToken()) {
+ return $token->can('forms-write') && $userIsNotReadonly;
+ }
+
+ return $userIsNotReadonly;
}
/**
@@ -46,7 +64,14 @@ class FormPolicy
*/
private function canPerformWriteOperation(User $user, Form $form): bool
{
- return $user->ownsForm($form) && !$form->workspace->isReadonlyUser($user);
+ $ownsAndWritable = $user->ownsForm($form) && !$form->workspace->isReadonlyUser($user);
+
+ // If using Sanctum token, ensure the token has write ability
+ if ($token = $user->currentAccessToken()) {
+ return $token->can('forms-write') && $ownsAndWritable;
+ }
+
+ return $ownsAndWritable;
}
/**
diff --git a/api/app/Policies/WorkspacePolicy.php b/api/app/Policies/WorkspacePolicy.php
index 2863e4b8b..d896a4793 100644
--- a/api/app/Policies/WorkspacePolicy.php
+++ b/api/app/Policies/WorkspacePolicy.php
@@ -20,6 +20,11 @@ class WorkspacePolicy
*/
public function viewAny(User $user)
{
+ // Check if authenticated via Sanctum token
+ if ($token = $user->currentAccessToken()) {
+ return $token->can('workspaces-read');
+ }
+
return true;
}
@@ -30,6 +35,12 @@ class WorkspacePolicy
*/
public function view(User $user, Workspace $workspace)
{
+ if ($token = $user->currentAccessToken()) {
+ $canAccess = $token->can('workspaces-read');
+
+ return $canAccess && $user->ownsWorkspace($workspace);
+ }
+
return $user->ownsWorkspace($workspace);
}
@@ -40,7 +51,11 @@ class WorkspacePolicy
*/
public function create(User $user)
{
- return false;
+ if ($token = $user->currentAccessToken()) {
+ return $token->can('workspaces-write');
+ }
+
+ return true;
}
/**
@@ -50,6 +65,10 @@ class WorkspacePolicy
*/
public function update(User $user, Workspace $workspace)
{
+ if ($token = $user->currentAccessToken()) {
+ return $token->can('workspaces-write') && $user->ownsWorkspace($workspace);
+ }
+
return $user->ownsWorkspace($workspace);
}
@@ -60,7 +79,17 @@ class WorkspacePolicy
*/
public function delete(User $user, Workspace $workspace)
{
- return !$workspace->owners->where('id', $user->id)->isEmpty() && $user->workspaces()->count() > 1;
+ $basePermission = !$workspace->owners->where('id', $user->id)->isEmpty() && $user->workspaces()->count() > 1;
+
+ if (! $basePermission) {
+ return false;
+ }
+
+ if ($token = $user->currentAccessToken()) {
+ return $token->can('workspaces-write');
+ }
+
+ return true;
}
/**
@@ -107,6 +136,13 @@ class WorkspacePolicy
}
}
+ // If using Sanctum token, require write ability first
+ if ($token = $user->currentAccessToken()) {
+ if (! $token->can('workspaces-write')) {
+ return Response::deny('Token lacks workspaces:write ability.');
+ }
+ }
+
return true;
}
@@ -117,9 +153,21 @@ class WorkspacePolicy
*/
public function adminAction(User $user, Workspace $workspace)
{
+ // Sanctum token must include write ability
+ if ($token = $user->currentAccessToken()) {
+ if (! $token->can('workspaces-write')) {
+ return false;
+ }
+ }
+
$userWorkspace = UserWorkspace::where('user_id', $user->id)
->where('workspace_id', $workspace->id)
->first();
return $userWorkspace && $userWorkspace->role === 'admin';
}
+
+ public function ownsWorkspace(User $user, Workspace $workspace)
+ {
+ return $user->ownsWorkspace($workspace);
+ }
}
diff --git a/api/config/sanctum-routes.php b/api/config/sanctum-routes.php
new file mode 100644
index 000000000..d763b0ad8
--- /dev/null
+++ b/api/config/sanctum-routes.php
@@ -0,0 +1,34 @@
+<?php
+
+return [
+ 'allowed' => [
+ // Form CRUD
+ 'open.forms.index-all',
+ 'open.forms.store',
+ 'open.forms.show',
+ 'open.forms.update',
+ 'open.forms.destroy',
+
+ // Form Submission CRUD
+ 'open.forms.submissions.index',
+ 'open.forms.submissions.update',
+ 'open.forms.submissions.export',
+ 'open.forms.submissions.destroy',
+
+ // Workspace CRUD
+ 'open.workspaces.index',
+ 'open.workspaces.create',
+ 'open.workspaces.update',
+ 'open.workspaces.delete',
+
+ // Workspace User Management
+ 'open.workspaces.users.index',
+ 'open.workspaces.users.add',
+ 'open.workspaces.users.remove',
+ 'open.workspaces.users.update-role',
+ 'open.workspaces.leave',
+ 'open.workspaces.invites.index',
+ 'open.workspaces.invites.resend',
+ 'open.workspaces.invites.cancel',
+ ],
+];
diff --git a/api/routes/api-external.php b/api/routes/api-external.php
index 59725785b..a20ba7bd7 100644
--- a/api/routes/api-external.php
+++ b/api/routes/api-external.php
@@ -7,6 +7,7 @@
use App\Http\Controllers\Integrations\Zapier;
use App\Http\Controllers\Integrations\Zapier\ListFormsController;
use App\Http\Controllers\Integrations\Zapier\ListWorkspacesController;
+use Illuminate\Support\Facades\Route;
Route::prefix('external')
->middleware('auth:sanctum')
@@ -28,11 +29,11 @@ Route::prefix('external')
});
Route::get('workspaces', ListWorkspacesController::class)
- ->middleware('ability:list-workspaces')
+ ->middleware('ability:workspaces-read')
->name('workspaces');
Route::get('forms', ListFormsController::class)
- ->middleware('ability:list-forms')
+ ->middleware('ability:forms-read')
->name('forms');
});
});
diff --git a/api/routes/api.php b/api/routes/api.php
index 59e113782..a03659c7f 100644
--- a/api/routes/api.php
+++ b/api/routes/api.php
@@ -14,7 +14,6 @@ use App\Http\Controllers\Forms\Integration\FormIntegrationsController;
use App\Http\Controllers\Forms\Integration\FormIntegrationsEventController;
use App\Http\Controllers\Forms\Integration\FormZapierWebhookController;
use App\Http\Controllers\Forms\PublicFormController;
-use App\Http\Controllers\Forms\RecordController;
use App\Http\Controllers\Settings\OAuthProviderController;
use App\Http\Controllers\Settings\PasswordController;
use App\Http\Controllers\Settings\ProfileController;
@@ -47,7 +46,7 @@ if (config('app.self_hosted')) {
Route::get('/healthcheck', [HealthCheckController::class, 'apiCheck']);
}
-Route::group(['middleware' => 'auth:api'], function () {
+Route::group(['middleware' => 'auth.multi'], function () {
Route::post('logout', [LoginController::class, 'logout'])->name('logout');
Route::post('update-credentials', [ProfileController::class, 'updateAdminCredentials'])->name('credentials.update');
@@ -58,7 +57,7 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::patch('/profile', [ProfileController::class, 'update']);
Route::patch('/password', [PasswordController::class, 'update']);
- Route::prefix('/tokens')->name('tokens.')->group(function () {
+ Route::prefix('/tokens')->name('tokens.')->middleware('require-pro')->group(function () {
Route::get('/', [TokenController::class, 'index'])->name('index');
Route::post('/', [TokenController::class, 'store'])->name('store');
Route::delete('{token}', [TokenController::class, 'destroy'])->name('destroy');
@@ -167,15 +166,16 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::delete('/{id}', [FormController::class, 'destroy'])->name('destroy');
Route::get('/{id}/mobile-editor-email', [FormController::class, 'mobileEditorEmail'])->name('mobile-editor-email');
- Route::get('/{id}/submissions', [FormSubmissionController::class, 'submissions'])->name('submissions');
- Route::put('/{id}/submissions/{submission_id}', [FormSubmissionController::class, 'update'])->name('submissions.update')->middleware([ResolveFormMiddleware::class]);
- Route::post('/{id}/submissions/export', [FormSubmissionController::class, 'export'])->name('submissions.export');
- Route::get('/{id}/submissions/file/{filename}', [FormSubmissionController::class, 'submissionFile'])
- ->middleware('signed')
- ->withoutMiddleware(['auth:api'])
- ->name('submissions.file');
-
- Route::delete('/{id}/records/{recordid}/delete', [RecordController::class, 'delete'])->name('records.delete');
+ Route::prefix('/{id}/submissions')->name('submissions.')->group(function () {
+ Route::get('/', [FormSubmissionController::class, 'submissions'])->name('index');
+ Route::put('/{submission_id}', [FormSubmissionController::class, 'update'])->name('update')->middleware([ResolveFormMiddleware::class]);
+ Route::post('/export', [FormSubmissionController::class, 'export'])->name('export');
+ Route::get('/file/{filename}', [FormSubmissionController::class, 'submissionFile'])
+ ->middleware('signed')
+ ->withoutMiddleware(['auth.multi'])
+ ->name('file');
+ Route::delete('/{submission_id}', [FormSubmissionController::class, 'destroy'])->name('destroy');
+ });
// Form Admin tool
Route::put(
@@ -193,7 +193,7 @@ Route::group(['middleware' => 'auth:api'], function () {
Route::post(
'/assets/upload',
[FormController::class, 'uploadAsset']
- )->withoutMiddleware(['auth:api'])->name('assets.upload');
+ )->withoutMiddleware(['auth.multi'])->name('assets.upload');
Route::get(
'/{id}/uploaded-file/{filename}',
[FormController::class, 'viewFile']
diff --git a/api/tests/Feature/DualAuthMiddlewareTest.php b/api/tests/Feature/DualAuthMiddlewareTest.php
new file mode 100644
index 000000000..6ece0b51e
--- /dev/null
+++ b/api/tests/Feature/DualAuthMiddlewareTest.php
@@ -0,0 +1,58 @@
+<?php
+
+use App\Models\User;
+use App\Models\Workspace;
+use Laravel\Sanctum\Sanctum;
+
+it('allows Sanctum token to access whitelisted GET endpoint', function () {
+ // Arrange: user with a workspace and a Sanctum token that has read ability
+ $user = $this->createProUser();
+ $workspace = Workspace::factory()->create();
+ $workspace->users()->attach($user, ['role' => 'admin']);
+
+ // Act as the user via Sanctum with the relevant read ability
+ Sanctum::actingAs($user, ['workspaces-read']);
+
+ // The route name exists in config/sanctum-routes.php so the request should succeed (200)
+ $this->getJson(route('open.workspaces.index'))
+ ->assertSuccessful();
+});
+
+it('returns 404 when Sanctum token hits a non-whitelisted GET endpoint', function () {
+ // Arrange: authenticated user via Sanctum
+ $user = $this->createProUser();
+ $workspace = Workspace::factory()->create();
+ $workspace->users()->attach($user, ['role' => 'admin']);
+ Sanctum::actingAs($user, ['workspaces-read']); // abilities don\'t matter for middleware check
+
+ // `open.providers` is NOT present in the sanctum whitelist, therefore the middleware
+ // should short-circuit the request with a 404 response
+ $this->getJson(route('open.providers'))
+ ->assertNotFound();
+});
+
+it('allows JWT token to access whitelisted GET endpoint', function () {
+ // Arrange: Authenticate a user via JWT (session-based for tests)
+ $this->actingAsUser();
+
+ // Act & Assert: The request should succeed because JWT auth does not check the whitelist.
+ $this->getJson(route('open.workspaces.index'))
+ ->assertSuccessful();
+});
+
+it('allows JWT token to access non-whitelisted GET endpoint', function () {
+ // Arrange: Authenticate a user via JWT (session-based for tests)
+ $this->actingAsUser();
+
+ // Act & Assert: The request should succeed because JWT auth bypasses the Sanctum route whitelist.
+ // The route 'open.providers' is not in sanctum-routes.php.
+ $this->getJson(route('open.providers'))
+ ->assertSuccessful();
+});
+
+it('throws AuthenticationException for unauthenticated requests', function () {
+ // Act & Assert: Attempt to access a protected route without any authentication.
+ // The middleware should throw an AuthenticationException, resulting in a 401.
+ $this->getJson(route('open.workspaces.index'))
+ ->assertUnauthorized();
+});
diff --git a/api/tests/Feature/Forms/FormSubmissionExportTest.php b/api/tests/Feature/Forms/FormSubmissionExportTest.php
index c31d98ad0..bfc4db8a1 100644
--- a/api/tests/Feature/Forms/FormSubmissionExportTest.php
+++ b/api/tests/Feature/Forms/FormSubmissionExportTest.php
@@ -1,7 +1,6 @@
<?php
use App\Models\User;
-use Laravel\Sanctum\Sanctum;
it('can export form submissions with selected columns', function () {
$user = $this->actingAsProUser();
@@ -77,21 +76,18 @@ it('cannot export form submissions with invalid columns', function () {
it('cannot export form submissions from another user form', function () {
$user = User::factory()->create();
- $user2 = User::factory()->create();
- $workspace = createUserWorkspace($user2);
+ $workspace = createUserWorkspace($user);
$form = createForm($user, $workspace);
- Sanctum::actingAs($user2);
+ $this->actingAsProUser();
$response = $this->postJson(route('open.forms.submissions.export', [
'id' => $form->id,
- 'columns' => [
- 'name_field' => true
- ]
+ 'columns' => []
]));
$response->assertJson([
- 'message' => 'Unauthenticated.'
+ 'message' => 'This action is unauthorized.'
]);
});
diff --git a/api/tests/Feature/PublicApiPolicyTest.php b/api/tests/Feature/PublicApiPolicyTest.php
new file mode 100644
index 000000000..88458d41f
--- /dev/null
+++ b/api/tests/Feature/PublicApiPolicyTest.php
@@ -0,0 +1,118 @@
+<?php
+
+use App\Models\Forms\Form;
+use App\Models\User;
+use App\Models\Workspace;
+use Laravel\Sanctum\Sanctum;
+
+describe('Public API Policy Tests', function () {
+ // Test Pro Plan Policy
+ it('not allowed to access the api with a non-pro user', function () {
+ // Arrange
+ $user = $this->createUser();
+ $workspace = $this->createUserWorkspace($user);
+ $this->createForm($user, $workspace);
+ $form = $this->makeForm($user, $workspace);
+
+ // Act & Assert: Add 'workspaces-read' to pass the FormController's workspace authorization check.
+ Sanctum::actingAs($user, ['forms-read']);
+
+ $this->getJson(route('open.forms.index-all'))
+ ->assertUnauthorized();
+ });
+
+ // Test Form Policies
+ it('allows read-only token to list forms but not create them', function () {
+ // Arrange
+ $user = $this->createProUser();
+ $workspace = $this->createUserWorkspace($user);
+ $this->createForm($user, $workspace);
+ $form = $this->makeForm($user, $workspace);
+ $formData = new \App\Http\Resources\FormResource($form);
+
+ // Act & Assert: Add 'workspaces-read' to pass the FormController's workspace authorization check.
+ Sanctum::actingAs($user, ['forms-read']);
+
+ $this->getJson(route('open.forms.index-all'))
+ ->assertSuccessful();
+
+ $this->postJson(route('open.forms.store'), $formData->toArray(request()))
+ ->assertForbidden();
+ });
+
+ it('allows write token to create a form', function () {
+ // Arrange
+ $user = $this->createProUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->makeForm($user, $workspace);
+
+ // Act & Assert
+ Sanctum::actingAs($user, ['forms-write']);
+
+ $formData = new \App\Http\Resources\FormResource($form);
+ $this->postJson(route('open.forms.store'), $formData->toArray(request()))
+ ->assertSuccessful();
+ });
+
+ // Test Submission Policies (now governed by Form abilities)
+ it('allows forms-read token to list submissions', function () {
+ // Arrange
+ $user = $this->createProUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace);
+ $form->submissions()->create(['data' => []]);
+
+ // Act & Assert
+ Sanctum::actingAs($user, ['forms-read']);
+
+ $this->getJson(route('open.forms.submissions.index', ['id' => $form->id]))
+ ->assertSuccessful();
+ });
+
+ it('forbids forms-read token from deleting submissions', function () {
+ // Arrange
+ $user = $this->createProUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace);
+ $submission = $form->submissions()->create(['data' => []]);
+
+ // Act & Assert
+ Sanctum::actingAs($user, ['forms-read']);
+
+ $this->deleteJson(route('open.forms.submissions.destroy', ['id' => $form->id, 'submission_id' => $submission->id]))
+ ->assertForbidden();
+ });
+
+ it('allows forms-write token to delete a submission', function () {
+ // Arrange
+ $user = $this->createProUser();
+ $workspace = $this->createUserWorkspace($user);
+ $form = $this->createForm($user, $workspace);
+ $submission = $form->submissions()->create(['data' => []]);
+
+ // Act & Assert
+ Sanctum::actingAs($user, ['forms-write']);
+
+ $this->deleteJson(route('open.forms.submissions.destroy', ['id' => $form->id, 'submission_id' => $submission->id]))
+ ->assertSuccessful();
+ });
+
+ // Test Cross-User Authorization
+ it('forbids a token from accessing the resources of another user', function () {
+ // Arrange
+ $userA = $this->createProUser();
+ $userB = $this->createProUser();
+ $workspaceB = $this->createUserWorkspace($userB);
+ $formB = $this->createForm($userB, $workspaceB);
+
+ // Act
+ Sanctum::actingAs($userA, ['forms-read']);
+
+ // Assert: Laravel will return a 401 when a policy check fails on a model binding.
+ $this->getJson(route('open.forms.show', ['slug' => $formB->slug]))
+ ->assertUnauthorized();
+
+ $this->getJson(route('open.forms.submissions.index', ['id' => $formB->id]))
+ ->assertUnauthorized();
+ });
+});
diff --git a/api/tests/Feature/TokenPermissionsTest.php b/api/tests/Feature/TokenPermissionsTest.php
new file mode 100644
index 000000000..eec56ac95
--- /dev/null
+++ b/api/tests/Feature/TokenPermissionsTest.php
@@ -0,0 +1,54 @@
+<?php
+
+use App\Models\Workspace;
+use Laravel\Sanctum\Sanctum;
+
+it('can not create token with a non-pro user', function () {
+ $user = $this->actingAsUser();
+ $workspace = $this->createUserWorkspace($user);
+
+ $this->postJson(route('settings.tokens.store'), [
+ 'name' => 'New Token',
+ 'abilities' => ['forms-read'],
+ ])->assertStatus(402);
+});
+
+it('can create token with a pro user', function () {
+ $user = $this->actingAsProUser();
+ $workspace = $this->createUserWorkspace($user);
+
+ $this->postJson(route('settings.tokens.store'), [
+ 'name' => 'New Token',
+ 'abilities' => ['forms-read'],
+ ])->assertSuccessful();
+});
+
+
+it('can access read-only workspace endpoints with read token', function () {
+ $user = $this->createProUser();
+ $workspace = Workspace::factory()->create();
+ $workspace->users()->attach($user, ['role' => 'admin']);
+
+ Sanctum::actingAs($user, ['workspaces-read']);
+
+ $this->getJson(route('open.workspaces.index'))
+ ->assertSuccessful();
+
+ $this->postJson(route('open.workspaces.create'), [
+ 'name' => 'New Workspace',
+ 'icon' => 'πŸš€',
+ ])->assertForbidden();
+});
+
+it('can access write workspace endpoints with write token', function () {
+ $user = $this->createProUser();
+ $workspace = Workspace::factory()->create();
+ $workspace->users()->attach($user, ['role' => 'admin']);
+
+ Sanctum::actingAs($user, ['workspaces-write']);
+
+ $this->postJson(route('open.workspaces.create'), [
+ 'name' => 'New Workspace',
+ 'icon' => 'πŸš€',
+ ])->assertSuccessful();
+});
diff --git a/api/tests/Feature/Zapier/ListFormsTest.php b/api/tests/Feature/Zapier/ListFormsTest.php
index 674e5077e..3df711d90 100644
--- a/api/tests/Feature/Zapier/ListFormsTest.php
+++ b/api/tests/Feature/Zapier/ListFormsTest.php
@@ -14,21 +14,19 @@ test('list all forms of a given workspace', function () {
Sanctum::actingAs(
$user,
- ['list-forms']
+ ['forms-read']
);
get(route('zapier.forms', ['workspace_id' => $workspace->id]))
->assertOk()
->assertJsonCount(2)
- ->assertJson([
- [
- 'id' => $form1->id,
- 'name' => $form1->title,
- ],
- [
- 'id' => $form2->id,
- 'name' => $form2->title,
- ],
+ ->assertJsonFragment([
+ 'id' => $form1->id,
+ 'name' => $form1->title,
+ ])
+ ->assertJsonFragment([
+ 'id' => $form2->id,
+ 'name' => $form2->title,
]);
});
diff --git a/api/tests/Feature/Zapier/ListWorkspacesTest.php b/api/tests/Feature/Zapier/ListWorkspacesTest.php
index 3cf80104b..31ea12f3f 100644
--- a/api/tests/Feature/Zapier/ListWorkspacesTest.php
+++ b/api/tests/Feature/Zapier/ListWorkspacesTest.php
@@ -14,7 +14,7 @@ test('list all workspaces of a user', function () {
Sanctum::actingAs(
$user,
- ['list-workspaces']
+ ['workspaces-read']
);
get(route('zapier.workspaces'))
diff --git a/api/tests/Unit/EmailNotificationMigrationTest.php b/api/tests/Unit/EmailNotificationMigrationTest.php
deleted file mode 100644
index d678715de..000000000
--- a/api/tests/Unit/EmailNotificationMigrationTest.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-namespace Tests\Unit;
-
-use App\Console\Commands\EmailNotificationMigration;
-use App\Models\Integration\FormIntegration;
-use Tests\TestCase;
-
-uses(TestCase::class);
-
-beforeEach(function () {
- $this->command = new EmailNotificationMigration();
-});
-
-it('updates email integration correctly', function () {
- $user = $this->actingAsUser();
- $workspace = $this->createUserWorkspace($user);
- $form = $this->createForm($user, $workspace);
-
- $integration = FormIntegration::create([
- 'integration_id' => 'email',
- 'form_id' => $form->id,
- 'status' => FormIntegration::STATUS_ACTIVE,
- 'data' => [
- 'notification_emails' => '[email protected]',
- 'notification_reply_to' => '[email protected]',
- ],
- ]);
-
- $this->command->updateIntegration($integration);
-
- expect($integration->fresh())
- ->integration_id->toBe('email')
- ->data->toMatchArray([
- 'send_to' => '[email protected]',
- 'sender_name' => 'OpnForm',
- 'subject' => 'New form submission',
- 'email_content' => 'Hello there πŸ‘‹ <br>New form submission received.',
- 'include_submission_data' => true,
- 'include_hidden_fields_submission_data' => false,
- 'reply_to' => '[email protected]',
- ]);
-});
-
-it('updates submission confirmation integration correctly', function () {
- $user = $this->actingAsUser();
- $workspace = $this->createUserWorkspace($user);
- $form = $this->createForm($user, $workspace);
-
- $emailProperty = collect($form->properties)->filter(function ($property) {
- return $property['type'] == 'email';
- })->first();
-
- $integration = FormIntegration::create([
- 'integration_id' => 'submission_confirmation',
- 'form_id' => $form->id,
- 'status' => FormIntegration::STATUS_ACTIVE,
- 'data' => [
- 'notification_sender' => 'Sender Name',
- 'notification_subject' => 'Thank you for your submission',
- 'notification_body' => 'We received your submission.',
- 'notifications_include_submission' => true,
- 'confirmation_reply_to' => '[email protected]',
- ],
- ]);
-
- $this->command->updateIntegration($integration);
-
- expect($integration->fresh())
- ->integration_id->toBe('email')
- ->data->toMatchArray([
- 'send_to' => '<span mention-field-id="' . $emailProperty['id'] . '" mention-field-name="' . $emailProperty['name'] . '" mention-fallback="" contenteditable="false" mention="true">' . $emailProperty['name'] . '</span>',
- 'sender_name' => 'Sender Name',
- 'subject' => 'Thank you for your submission',
- 'email_content' => 'We received your submission.',
- 'include_submission_data' => true,
- 'include_hidden_fields_submission_data' => false,
- 'reply_to' => '[email protected]',
- ]);
-});
diff --git a/client/components/open/components/RecordOperations.vue b/client/components/open/components/RecordOperations.vue
index ac3637f4d..d1815ab53 100644
--- a/client/components/open/components/RecordOperations.vue
+++ b/client/components/open/components/RecordOperations.vue
@@ -70,9 +70,8 @@ export default {
opnFetch(
"/open/forms/" +
this.form.id +
- "/records/" +
- this.submission.id +
- "/delete",
+ "/submissions/" +
+ this.submission.id,
{ method: "DELETE" },
)
.then(async (data) => {
diff --git a/client/components/pages/pricing/PricingTable.vue b/client/components/pages/pricing/PricingTable.vue
index cf2e3e55a..069198baa 100644
--- a/client/components/pages/pricing/PricingTable.vue
+++ b/client/components/pages/pricing/PricingTable.vue
@@ -217,7 +217,8 @@ export default {
"Remove OpnForm branding",
"Priority support",
"Form Analytics",
- "Custom sender email (SMTP)"
+ "Custom sender email (SMTP)",
+ "API access",
],
}),
diff --git a/client/components/pages/pricing/SubscriptionModal.vue b/client/components/pages/pricing/SubscriptionModal.vue
index f537bc6b1..50bbad932 100644
--- a/client/components/pages/pricing/SubscriptionModal.vue
+++ b/client/components/pages/pricing/SubscriptionModal.vue
@@ -153,7 +153,7 @@
class="w-5 h-5 text-nt-blue"
/>
<p class="mt-2">
- <strong class="font-semibold text-slate-800">Access to all integrations.</strong>
+ <strong class="font-semibold text-slate-800">All ntegrations & API access.</strong>
<span class="text-slate-500"> Setup email, Slack, Discord notifications or GSheet, Zapier or webhooks integrations.</span>
</p>
</div>
diff --git a/client/components/settings/AccessTokenModal.vue b/client/components/settings/AccessTokenModal.vue
index d162eb5d6..b2bd34d68 100644
--- a/client/components/settings/AccessTokenModal.vue
+++ b/client/components/settings/AccessTokenModal.vue
@@ -49,7 +49,7 @@
v-model="form.abilities"
:value="ability.name"
:label="ability.title"
- disabled
+ :disabled="ability.disabled ?? false"
/>
</div>
</div>
diff --git a/client/opnform.config.js b/client/opnform.config.js
index eb92fb6ea..360a9b416 100644
--- a/client/opnform.config.js
+++ b/client/opnform.config.js
@@ -17,5 +17,6 @@ export default {
changelog_url: "https://feedback.opnform.com/changelog",
roadmap: "https://feedback.opnform.com/roadmap",
tech_docs: "https://docs.opnform.com",
+ api_docs: "https://docs.opnform.com/api-reference/introduction",
},
}
diff --git a/client/pages/settings/access-tokens.vue b/client/pages/settings/access-tokens.vue
index 864e4e3bb..082a95a39 100644
--- a/client/pages/settings/access-tokens.vue
+++ b/client/pages/settings/access-tokens.vue
@@ -8,14 +8,43 @@
<small class="text-gray-600">Manage your access tokens keys.</small>
</div>
+ <UButton
+ label="API Docs"
+ icon="i-heroicons-book-open"
+ variant="ghost"
+ :to="opnformConfig.links.api_docs"
+ target="_blank"
+ class="mr-2"
+ />
+
<UButton
label="Create new token"
icon="i-heroicons-plus"
:loading="loading"
+ :disabled="!user.is_pro"
@click="accessTokenModal = true"
/>
</div>
+ <UAlert
+ v-if="!user.is_pro"
+ icon="i-heroicons-user-group-20-solid"
+ class="my-4 !text-orange-500"
+ color="orange"
+ variant="subtle"
+ title="Pro plan required"
+ >
+ <template #description>
+ Please <a
+ href="#"
+ class="text-orange-500 underline"
+ @click.prevent="openSubscriptionModal"
+ >
+ upgrade your account
+ </a> to create and manage access tokens.
+ </template>
+ </UAlert>
+
<div
v-if="loading"
class="w-full text-blue-500 text-center"
@@ -39,6 +68,7 @@
</template>
<script setup>
+import opnformConfig from '~/opnform.config.js'
useOpnSeoMeta({
title: "Access Tokens",
})
@@ -47,8 +77,17 @@ const accessTokenModal = ref(false)
const accessTokenStore = useAccessTokenStore()
const tokens = computed(() => accessTokenStore.getAll)
const loading = computed(() => accessTokenStore.loading)
+const user = computed(() => useAuthStore().user)
+const subscriptionModalStore = useSubscriptionModalStore()
+
+const openSubscriptionModal = () => {
+ subscriptionModalStore.setModalContent('Upgrade to start using our API')
+ subscriptionModalStore.openModal()
+}
onMounted(() => {
- accessTokenStore.fetchTokens()
+ if (user.value.is_pro) {
+ accessTokenStore.fetchTokens()
+ }
})
</script>
diff --git a/client/stores/access_tokens.js b/client/stores/access_tokens.js
index d46853e0f..5a7635a86 100644
--- a/client/stores/access_tokens.js
+++ b/client/stores/access_tokens.js
@@ -10,12 +10,28 @@ export const useAccessTokenStore = defineStore("access_tokens", () => {
name: 'manage-integrations',
},
{
- title: 'List forms',
- name: 'list-forms',
+ title: 'Forms – Read',
+ name: 'forms-read',
},
{
- title: 'List workspaces',
- name: 'list-workspaces',
+ title: 'Forms – Write',
+ name: 'forms-write',
+ },
+ {
+ title: 'Workspaces – Read',
+ name: 'workspaces-read',
+ },
+ {
+ title: 'Workspaces – Write',
+ name: 'workspaces-write',
+ },
+ {
+ title: 'Workspace Users – Read',
+ name: 'workspace-users-read',
+ },
+ {
+ title: 'Workspace Users – Write',
+ name: 'workspace-users-write',
},
]
@@ -34,7 +50,10 @@ export const useAccessTokenStore = defineStore("access_tokens", () => {
const tokens = computed(() => contentStore.getAll.value)
const getAbility = (name) => {
- return abilities.find(ability => ability.name == name)
+ return abilities.find((ability) => ability.name === name) ?? {
+ name,
+ title: name,
+ }
}
return {
diff --git a/docs.json b/docs.json
new file mode 100644
index 000000000..0519ecba6
--- /dev/null
+++ b/docs.json
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/docs/api-reference/api-keys.mdx b/docs/api-reference/api-keys.mdx
new file mode 100644
index 000000000..7ae2a689d
--- /dev/null
+++ b/docs/api-reference/api-keys.mdx
@@ -0,0 +1,55 @@
+---
+title: "API Keys"
+description: "Generate and manage Personal Access Tokens on OpnForm."
+---
+
+Personal Access Tokens are the credentials you'll use to authenticate with the OpnForm REST API. They're scoped, revocable, and tied to your user account – **keep them secret**.
+
+## Creating a token
+
+1. Sign in to your OpnForm account.
+2. Open **Settings β†’ Access Tokens** (`/settings/access-tokens`).
+3. Click **Create new token**.
+4. Pick a descriptive name (e.g. "Zapier Integration").
+5. Select the abilities you want to grant (see the table below).
+6. Click **Create** and copy the token value – you **won't** be able to see it again after closing the dialog.
+
+<Frame>
+ <img src="/api-reference/images/create-token.png" alt="Create token" />
+</Frame>
+
+## Abilities
+
+| Ability | Grants |
+|---------|--------|
+| workspaces-read | List workspaces |
+| workspaces-write | Create, update or delete workspaces |
+| workspace-users-read | List members and invites |
+| workspace-users-write | Manage members and invites |
+| forms-read | List forms and submissions |
+| forms-write | Create or modify forms and submissions |
+
+You can combine abilities as needed – choose the minimum set your integration requires.
+
+## Using the token
+
+Send the token in the `Authorization` header:
+
+```http
+Authorization: Bearer <access_token>
+```
+
+## Revoking a token
+
+If a token is leaked or no longer needed:
+
+1. Go back to **Settings β†’ Access Tokens**.
+2. Click **Revoke** next to the token.
+3. Any further API requests that use that token will receive `401 Unauthorized`.
+
+## Best practices
+
+* Store tokens securely (environment variables, secret managers, CI secrets).
+* Use a dedicated token per integration – easier to revoke individually.
+* Avoid committing tokens to version control.
+* Rotate tokens periodically.
\ No newline at end of file
diff --git a/docs/api-reference/changelog.mdx b/docs/api-reference/changelog.mdx
new file mode 100644
index 000000000..a3256be1c
--- /dev/null
+++ b/docs/api-reference/changelog.mdx
@@ -0,0 +1,15 @@
+---
+title: "Changelog"
+description: "Notable updates to the OpnForm API."
+---
+
+## 2024-06-18 – API creation πŸŽ‰
+
+The first public version of the OpnForm REST API is live! You can now:
+
+* Manage workspaces and members
+* Create, update and delete forms
+* Retrieve and manage submissions
+* Generate personal access tokens with granular abilities
+
+Stay tuned for more endpoints and features.
\ No newline at end of file
diff --git a/docs/api-reference/documentation-checklist.md b/docs/api-reference/documentation-checklist.md
new file mode 100644
index 000000000..f3170b4ac
--- /dev/null
+++ b/docs/api-reference/documentation-checklist.md
@@ -0,0 +1,29 @@
+- [x] open.forms.index-all
+- [x] open.forms.store
+- [x] open.forms.show
+- [x] open.forms.update
+- [x] open.forms.destroy
+- [x] open.forms.submissions.index
+- [x] open.forms.submissions.update
+- [x] open.forms.submissions.export
+- [x] open.forms.submissions.destroy
+- [x] open.workspaces.index
+- [x] open.workspaces.create
+- [x] open.workspaces.update
+- [x] open.workspaces.delete
+- [x] open.workspaces.users.index
+- [x] open.workspaces.users.add
+- [x] open.workspaces.users.remove
+- [x] open.workspaces.users.update-role
+- [x] open.workspaces.leave
+- [x] open.workspaces.invites.index
+- [x] open.workspaces.invites.resend
+- [x] open.workspaces.invites.cancel
+
+---
+
+Additional tasks:
+
+- [x] Create an Introduction page for the API (similar to Tally's) under `/api-reference` and add it to `docs.json` navigation.
+- [x] Create an API Keys page (similar to Tally's) explaining token management (referencing `access-tokens.vue`) and add it to `docs.json` navigation.
+- [x] Create a Changelog page with an initial entry for "API creation" and link it in the navigation.
\ No newline at end of file
diff --git a/docs/api-reference/endpoint/list-forms.mdx b/docs/api-reference/endpoint/list-forms.mdx
deleted file mode 100644
index 22745a158..000000000
--- a/docs/api-reference/endpoint/list-forms.mdx
+++ /dev/null
@@ -1,4 +0,0 @@
----
-title: "List Forms"
-openapi: "GET /external/zapier/forms"
----
diff --git a/docs/api-reference/endpoint/open-form-submissions.mdx b/docs/api-reference/endpoint/open-form-submissions.mdx
new file mode 100644
index 000000000..fb7fd9c84
--- /dev/null
+++ b/docs/api-reference/endpoint/open-form-submissions.mdx
@@ -0,0 +1,33 @@
+# List Form Submissions (Public API)
+
+Retrieve the submissions of a specific form.
+
+```http
+GET /open/forms/{formId}/submissions HTTP/1.1
+Authorization: Bearer <token with `forms-read`>
+```
+
+### Response
+
+```
+Status: 200 OK
+[ { "submission_id": "abc", "submitted_at": "...", "data": { /* ... */ } } ]
+```
+
+---
+
+# Update Submission
+
+```http
+PUT /open/forms/{formId}/submissions/{submissionId} HTTP/1.1
+Authorization: Bearer <token with `submissions-write`>
+Content-Type: application/json
+
+{ "data": { /* patched fields */ } }
+```
+
+### Response
+```
+Status: 200 OK
+{ "message": "Record successfully updated." }
+```
\ No newline at end of file
diff --git a/docs/api-reference/endpoint/open-forms-list.mdx b/docs/api-reference/endpoint/open-forms-list.mdx
new file mode 100644
index 000000000..7f2207ec6
--- /dev/null
+++ b/docs/api-reference/endpoint/open-forms-list.mdx
@@ -0,0 +1,22 @@
+# List Forms (Public API)
+
+Retrieves all forms accessible to the provided API token. Requires the `forms-read` ability.
+
+```http
+GET /open/forms HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Response
+
+```
+Status: 200 OK
+Content-Type: application/json
+
+[
+ {
+ "id": 123,
+ "name": "Customer Feedback"
+ }
+]
\ No newline at end of file
diff --git a/docs/api-reference/endpoint/open-workspace-users.mdx b/docs/api-reference/endpoint/open-workspace-users.mdx
new file mode 100644
index 000000000..2c500b0a7
--- /dev/null
+++ b/docs/api-reference/endpoint/open-workspace-users.mdx
@@ -0,0 +1,25 @@
+# Workspace Users (Public API)
+
+## List Users in Workspace
+
+```http
+GET /open/workspaces/{workspaceId}/users HTTP/1.1
+Authorization: Bearer <token with `workspace-users-read`>
+```
+
+## Add User to Workspace
+
+```http
+POST /open/workspaces/{workspaceId}/users/add HTTP/1.1
+Authorization: Bearer <token with `workspace-users-write`>
+Content-Type: application/json
+
+{ "email": "[email protected]", "role": "member" }
+```
+
+## Remove User from Workspace
+
+```http
+DELETE /open/workspaces/{workspaceId}/users/{userId}/remove HTTP/1.1
+Authorization: Bearer <token with `workspace-users-write`>
+```
\ No newline at end of file
diff --git a/docs/api-reference/endpoint/open-workspaces-list.mdx b/docs/api-reference/endpoint/open-workspaces-list.mdx
new file mode 100644
index 000000000..cba89b8e6
--- /dev/null
+++ b/docs/api-reference/endpoint/open-workspaces-list.mdx
@@ -0,0 +1,32 @@
+# Workspaces (Public API)
+
+## List Workspaces
+
+```http
+GET /open/workspaces HTTP/1.1
+Authorization: Bearer <token with `workspaces-read`>
+```
+
+## Create Workspace
+
+```http
+POST /open/workspaces HTTP/1.1
+Authorization: Bearer <token with `workspaces-write`>
+Content-Type: application/json
+
+{ "name": "My Workspace" }
+```
+
+## Update Workspace
+
+```http
+PUT /open/workspaces/{workspaceId} HTTP/1.1
+Authorization: Bearer <token with `workspaces-write`>
+```
+
+## Delete Workspace
+
+```http
+DELETE /open/workspaces/{workspaceId} HTTP/1.1
+Authorization: Bearer <token with `workspaces-write`>
+```
\ No newline at end of file
diff --git a/docs/api-reference/endpoint/validate-api-key.mdx b/docs/api-reference/endpoint/validate-api-key.mdx
deleted file mode 100644
index df6eef292..000000000
--- a/docs/api-reference/endpoint/validate-api-key.mdx
+++ /dev/null
@@ -1,4 +0,0 @@
----
-title: "Validate API Key"
-openapi: "GET /external/zapier/validate"
----
diff --git a/docs/api-reference/forms/create-form.mdx b/docs/api-reference/forms/create-form.mdx
new file mode 100644
index 000000000..110b33b65
--- /dev/null
+++ b/docs/api-reference/forms/create-form.mdx
@@ -0,0 +1,66 @@
+---
+openapi: post /open/forms
+---
+
+# Create Form
+
+Create a new form within a workspace.
+
+## Authentication & Scope
+
+Requires a Personal Access Token with the `forms-write` ability.
+
+## Request
+
+```http
+POST /open/forms HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Body Parameters
+
+| Field | Type | Required | Description |
+| -------------- | ------- | -------- | -------------------------------------------------------- |
+| workspace_id | number | Yes | ID of the workspace that will own the form. |
+| title | string | Yes | Human-readable title shown in the dashboard. |
+| visibility | string | Yes | One of `public`, `draft`, or `closed`. |
+| language | string | Yes | Two-letter ISO language code (e.g. `en`). |
+| properties | array | Yes | Array of form blocks (see `FormProperty` schema). |
+| …other fields | mixed | No | See the `Form` schema for the full list of attributes. |
+
+Example request:
+
+```json
+{
+ "workspace_id": 1,
+ "title": "Event Registration",
+ "visibility": "public",
+ "language": "en",
+ "properties": [
+ {
+ "id": "field-1",
+ "type": "short_text",
+ "name": "First name",
+ "required": true
+ }
+ ]
+}
+```
+
+## Response
+
+`201 Created` – Returns the full `Form` object.
+
+```json
+{
+ "id": 99,
+ "slug": "event-registration",
+ "title": "Event Registration",
+ "visibility": "public",
+ "properties": [...]
+}
+```
+
+`403 Forbidden` – The token does not include the `forms-write` ability.
\ No newline at end of file
diff --git a/docs/api-reference/forms/delete-form.mdx b/docs/api-reference/forms/delete-form.mdx
new file mode 100644
index 000000000..2381167a7
--- /dev/null
+++ b/docs/api-reference/forms/delete-form.mdx
@@ -0,0 +1,31 @@
+---
+openapi: delete /open/forms/{id}
+---
+
+# Delete Form
+
+Permanently delete a form and all of its submissions.
+
+## Authentication & Scope
+
+Requires a Personal Access Token that includes the `forms-write` ability.
+
+## Request
+
+```http
+DELETE /open/forms/{id} HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-----------|--------|--------------------------------|
+| id | number | Numeric ID of the form to delete |
+
+## Response
+
+`204 No Content` – Form successfully deleted.
+
+`403 Forbidden` – The token lacks `forms-write` or you are not allowed to delete this form.
\ No newline at end of file
diff --git a/docs/api-reference/forms/get-form.mdx b/docs/api-reference/forms/get-form.mdx
new file mode 100644
index 000000000..999ebf083
--- /dev/null
+++ b/docs/api-reference/forms/get-form.mdx
@@ -0,0 +1,43 @@
+---
+openapi: get /open/forms/{slug}
+---
+
+# Get Form
+
+Retrieve a single form by its **slug** (UUID or human-readable slug).
+
+## Authentication & Scope
+
+Requires a token with the `forms-read` ability.
+
+## Request
+
+```http
+GET /open/forms/{slug} HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-----------|--------|---------------------------------------|
+| slug | string | The form slug or UUID (see dashboard) |
+
+## Response
+
+`200 OK` – Returns a `Form` object.
+
+```json
+{
+ "id": 42,
+ "slug": "customer-feedback",
+ "title": "Customer Feedback",
+ "visibility": "public",
+ "properties": [...]
+}
+```
+
+`404 Not Found` – No form matches the provided slug.
+
+`403 Forbidden` – The token lacks the required ability or you do not have permission to view the form.
\ No newline at end of file
diff --git a/docs/api-reference/forms/list-forms.mdx b/docs/api-reference/forms/list-forms.mdx
new file mode 100644
index 000000000..fc7c0f410
--- /dev/null
+++ b/docs/api-reference/forms/list-forms.mdx
@@ -0,0 +1,45 @@
+---
+openapi: get /open/forms
+---
+
+# List Forms
+
+Retrieve every form accessible to the authenticated user across **all** of their workspaces.
+
+## Authentication & Scope
+
+This request must be authenticated using a **Personal Access Token** that includes the `forms-read` ability.
+
+```http
+Authorization: Bearer <token>
+```
+
+## Request
+
+```http
+GET /open/forms HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+There are no query parameters for this endpoint.
+
+## Response
+
+`200 OK` – Returns a JSON array of Form objects.
+
+```json
+[
+ {
+ "id": 42,
+ "slug": "customer-feedback",
+ "title": "Customer Feedback",
+ "visibility": "public",
+ "properties": [
+ /* form fields & layout blocks */
+ ]
+ }
+]
+```
+
+`403 Forbidden` – The token does not include the required `forms-read` ability.
\ No newline at end of file
diff --git a/docs/api-reference/forms/update-form.mdx b/docs/api-reference/forms/update-form.mdx
new file mode 100644
index 000000000..a3ac994d6
--- /dev/null
+++ b/docs/api-reference/forms/update-form.mdx
@@ -0,0 +1,58 @@
+---
+openapi: put /open/forms/{id}
+---
+
+# Update Form
+
+Update an existing form. You can modify any attribute that can be set when creating a form.
+
+## Authentication & Scope
+
+Requires a token with the `forms-write` ability.
+
+## Request
+
+```http
+PUT /open/forms/{id} HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-----------|--------|--------------------------------|
+| id | number | Numeric ID of the form to edit |
+
+### Body Parameters (partial)
+
+All fields from the [Create Form](./create-form) endpoint may be supplied. Only the fields you include will be updated; omitting a field leaves its current value unchanged.
+
+Important:
+
+* Passing a new `slug` will regenerate the form URL (self-hosted only).
+* The `workspace_id` can **not** be changed via this endpointβ€”use `/open/forms/{id}/workspace/{workspace_id}` instead.
+
+Example:
+
+```json
+{
+ "title": "Customer Feedback (v2)",
+ "visibility": "draft",
+ "properties": [
+ {
+ "id": "field-1",
+ "type": "short_text",
+ "name": "First name",
+ "required": true
+ }
+ ]
+}
+```
+
+## Response
+
+`200 OK` – Returns the updated `Form` object.
+
+`403 Forbidden` – The token lacks `forms-write` or you don't have permission.
\ No newline at end of file
diff --git a/docs/api-reference/introduction.mdx b/docs/api-reference/introduction.mdx
index 60df239d5..56b902522 100644
--- a/docs/api-reference/introduction.mdx
+++ b/docs/api-reference/introduction.mdx
@@ -1,37 +1,75 @@
---
title: "Introduction"
-description: "API Documentation for OpnForm"
+description: "Overview of the OpnForm REST API, base URL, authentication, and rate limits."
---
-Welcome to the OpnForm API documentation. This guide provides information on how to interact with the OpnForm API to automate your workflows and integrate OpnForm with your applications.
+Welcome to the **OpnForm REST API** – a straightforward, JWT-based interface that lets you manage workspaces, forms and submissions from your own tools or backend jobs.
+
+If you've ever used the dashboard you already know the objects you'll be working with: **workspaces**, **forms**, **submissions**, and **users**. The API exposes almost the same capabilities – you can list items, create new ones, update them or delete them, all with predictable HTTP verbs.
+
+## Base URL
+
+```text
+https://api.opnform.com
+```
+
+All endpoints documented in this reference are relative to that URL.
## Authentication
-To authenticate with the OpnForm API, you need an API key. Here's how to create and use an API key.
+Every request must include a **Personal Access Token** in the `Authorization` header:
+
+```http
+Authorization: Bearer <access_token>
+```
+
+Tokens can be created in your OpnForm dashboard (see the [API Keys](./api-keys) section). Each token is associated with one or more **abilities / scopes** that restrict what it can do.
+
+| Ability | Description |
+|---------|-------------|
+| workspaces-read | Read workspaces the user belongs to |
+| workspaces-write | Create, update or delete workspaces |
+| workspace-users-read | List workspace members & invites |
+| workspace-users-write | Manage workspace members & invites |
+| forms-read | Read forms & submissions |
+| forms-write | Create or modify forms & submissions |
-### Creating an API Key
+When your request attempts an operation outside the abilities attached to the token, the API responds with **403 Forbidden**.
-<Frame>
- <img
- src="/api-reference/images/create-token.png"
- alt="Creating an API Key in OpnForm"
- />
-</Frame>
+## Pagination
-1. Log in to your OpnForm account.
-2. Navigate to the Access Tokens page at https://opnform.com/settings/access-tokens.
-3. Click on the "Create new token" button.
-4. Give your token a name (e.g., "My API Integration").
-5. Click "Create" to generate your API key. 6. Copy the generated API key immediately, as it won't be displayed again for security reasons.
+Some list endpoints are paginated. Use the `page` query parameter (`?page=2`) to retrieve subsequent pages.
-### Using the API Key
+## Rate limits
-To use the API key, you need to include it in the header of every request you make to the API as a Bearer token. Here's how to do it:
+Each IP address is limited to **100 requests per minute**. Exceeding the limit returns **429 Too Many Requests**.
-1. Take your API key that you generated earlier.
-2. Add it to the `Authorization` header of your HTTP request.
-3. Prefix the key with the word "Bearer" followed by a space.
+## Errors
+Errors are returned in JSON with an HTTP status code that reflects the problem:
+
+```json
+{
+ "message": "Validation failed.",
+ "errors": {
+ "title": ["The title field is required."]
+ }
+}
```
-Authorization: Bearer YOUR_API_KEY
+
+See the status-code table below for the most common cases:
+
+| Status | Meaning |
+|--------|---------|
+| 400 | Bad request / validation error |
+| 401 | Missing or invalid token |
+| 403 | Token lacks required ability |
+| 404 | Resource not found |
+| 429 | Rate limit exceeded |
+| 500 | Server error – something went wrong on our side |
+
+That's all you need to know to get started – head over to the endpoint sections or grab a token and make your first call:
+
+```bash
+curl -H "Authorization: Bearer <access_token>" https://api.opnform.com/open/workspaces
```
diff --git a/docs/api-reference/openapi.json b/docs/api-reference/openapi.json
deleted file mode 100644
index 7d1f7c7be..000000000
--- a/docs/api-reference/openapi.json
+++ /dev/null
@@ -1,200 +0,0 @@
-{
- "openapi": "3.0.1",
- "info": {
- "title": "OpnForm API",
- "description": "API for interacting with OpnForm, primarily used for Zapier integration",
- "version": "1.0.0"
- },
- "servers": [
- {
- "url": "https://api.opnform.com"
- }
- ],
- "security": [
- {
- "bearerAuth": []
- }
- ],
- "paths": {
- "/external/zapier/validate": {
- "get": {
- "summary": "Validate API Key",
- "description": "This endpoint is used by Zapier to test the validity of the API key.",
- "responses": {
- "200": {
- "description": "API key is valid"
- },
- "401": {
- "description": "Invalid API key"
- }
- }
- }
- },
- "/external/zapier/forms": {
- "get": {
- "summary": "List Forms",
- "description": "Retrieve a list of forms available in a specific workspace.",
- "parameters": [
- {
- "name": "workspace_id",
- "in": "query",
- "description": "The ID of the workspace for which to list forms",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Successful response",
- "content": {
- "application/json": {
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Form"
- }
- }
- }
- }
- }
- }
- }
- },
- "/external/zapier/webhook": {
- "post": {
- "summary": "New Submission Trigger",
- "description": "This endpoint is used to set up a webhook for new form submissions.",
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "hookUrl": {
- "type": "string",
- "description": "The URL provided by Zapier to send the submission data"
- },
- "form_id": {
- "type": "string",
- "description": "The ID of the form for which to trigger the webhook"
- }
- },
- "required": ["hookUrl", "form_id"]
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "Webhook successfully set up"
- }
- }
- },
- "delete": {
- "summary": "Unsubscribe Webhook",
- "description": "This endpoint is used to unsubscribe from the webhook.",
- "requestBody": {
- "required": true,
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "hookUrl": {
- "type": "string",
- "description": "The URL provided by Zapier to stop sending the submission data"
- },
- "form_id": {
- "type": "string",
- "description": "The ID of the form for which to unsubscribe the webhook"
- }
- },
- "required": ["hookUrl", "form_id"]
- }
- }
- }
- },
- "responses": {
- "200": {
- "description": "Webhook successfully unsubscribed"
- }
- }
- }
- },
- "/external/zapier/submissions/recent": {
- "get": {
- "summary": "Sample Submission Polling",
- "description": "Retrieves the most recent submissions for a specified form.",
- "parameters": [
- {
- "name": "form_id",
- "in": "query",
- "description": "The ID of the form to retrieve submissions for",
- "required": true,
- "schema": {
- "type": "string"
- }
- }
- ],
- "responses": {
- "200": {
- "description": "Successful response",
- "content": {
- "application/json": {
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/Submission"
- }
- }
- }
- }
- }
- }
- }
- }
- },
- "components": {
- "schemas": {
- "Form": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string"
- },
- "name": {
- "type": "string"
- }
- }
- },
- "Submission": {
- "type": "object",
- "properties": {
- "submission_id": {
- "type": "string"
- },
- "form_id": {
- "type": "string"
- },
- "submitted_at": {
- "type": "string",
- "format": "date-time"
- },
- "data": {
- "type": "object",
- "additionalProperties": true
- }
- }
- }
- },
- "securitySchemes": {
- "bearerAuth": {
- "type": "http",
- "scheme": "bearer"
- }
- }
- }
-}
\ No newline at end of file
diff --git a/docs/api-reference/openapi.yaml b/docs/api-reference/openapi.yaml
new file mode 100644
index 000000000..35b44a444
--- /dev/null
+++ b/docs/api-reference/openapi.yaml
@@ -0,0 +1,1016 @@
+openapi: 3.0.1
+info:
+ title: OpnForm API
+ description: API for interacting with OpnForm, primarily used for Zapier integration
+ version: 1.0.0
+servers:
+ - url: https://api.opnform.com
+ - url: https://opnform.test
+security:
+ - bearerAuth: []
+tags:
+ - name: Workspaces
+ description: Create and manage workspaces.
+ - name: Workspace Users
+ description: Manage users within a workspace.
+ - name: Forms
+ description: Manage and retrieve forms.
+ - name: Submissions
+ description: Access and manage form submissions.
+ - name: Zapier
+ description: Legacy endpoints for the Zapier integration.
+paths:
+ "/open/workspaces":
+ get:
+ tags:
+ - Workspaces
+ summary: List Workspaces
+ description: "Requires `workspaces-read`."
+ security:
+ - bearerAuth: []
+ responses:
+ "200":
+ description: Successful
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Workspace"
+ "403":
+ description: Forbidden
+ "/open/workspaces/create":
+ post:
+ tags:
+ - Workspaces
+ summary: Create Workspace
+ description: "Requires `workspaces-write`."
+ security:
+ - bearerAuth: []
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - name
+ properties:
+ name:
+ type: string
+ emoji:
+ type: string
+ description: Emoji or icon representing the workspace.
+ responses:
+ "200":
+ description: Created
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ workspace_id:
+ type: number
+ workspace:
+ $ref: "#/components/schemas/Workspace"
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}":
+ put:
+ tags:
+ - Workspaces
+ summary: Update Workspace
+ description: "Update workspace name or icon. Requires `workspaces-write`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: number
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Workspace"
+ responses:
+ "200":
+ description: Updated
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Workspace"
+ "403":
+ description: Forbidden
+ delete:
+ tags:
+ - Workspaces
+ summary: Delete Workspace
+ description: "Permanently delete a workspace. Requires `workspaces-write`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: number
+ responses:
+ "204":
+ description: Deleted
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/users":
+ get:
+ tags:
+ - Workspace Users
+ summary: List Workspace Users
+ description: "Requires `workspace-users-read`. Returns members with their role."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Successful
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/UserWorkspaceMember"
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/users/add":
+ post:
+ tags:
+ - Workspace Users
+ summary: Add Workspace User
+ description: "Requires `workspace-users-write`. Add an existing user or send an invite if the email is unknown."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - email
+ - role
+ properties:
+ email:
+ type: string
+ format: email
+ role:
+ type: string
+ enum: [admin, user, readonly]
+ responses:
+ "200":
+ description: User added
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/users/{userId}/remove":
+ delete:
+ tags:
+ - Workspace Users
+ summary: Remove Workspace User
+ description: "Requires `workspace-users-write`. Removes a specified user from the workspace."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ - name: userId
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: User removed
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: User removed from workspace successfully.
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/users/{userId}/update-role":
+ put:
+ tags:
+ - Workspace Users
+ summary: Update Workspace User Role
+ description: "Requires `workspace-users-write`. Update a member's role."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ - name: userId
+ in: path
+ required: true
+ schema:
+ type: string
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required:
+ - role
+ properties:
+ role:
+ type: string
+ enum: [admin, user, readonly]
+ description: New role for the user.
+ responses:
+ "200":
+ description: Role updated
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/leave":
+ post:
+ tags:
+ - Workspace Users
+ summary: Leave Workspace
+ description: "Allows the current user to leave the workspace. Requires `workspace-users-write`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "204":
+ description: Left workspace
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/invites":
+ get:
+ tags:
+ - Workspace Users
+ summary: List Workspace Invites
+ description: "Requires `workspace-users-read`. Lists pending & accepted invites."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Successful
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Invite"
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/invites/{inviteId}/resend":
+ post:
+ tags:
+ - Workspace Users
+ summary: Resend Workspace Invite
+ description: "Requires `workspace-users-write`. Resend the invitation email for a pending invite."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ - name: inviteId
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Invite resent
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: Invite email resent successfully.
+ "403":
+ description: Forbidden
+ "/open/workspaces/{workspaceId}/invites/{inviteId}/cancel":
+ delete:
+ tags:
+ - Workspace Users
+ summary: Cancel Workspace Invite
+ description: "Requires `workspace-users-write`. Delete a pending invite."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: workspaceId
+ in: path
+ required: true
+ schema:
+ type: string
+ - name: inviteId
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Invite canceled
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: Invite deleted successfully.
+ "403":
+ description: Forbidden
+ "/open/forms":
+ get:
+ tags:
+ - Forms
+ summary: List Forms
+ description: Retrieve all forms accessible to the token holder.
+ security:
+ - bearerAuth: []
+ responses:
+ "200":
+ description: Successful response
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Form"
+ "403":
+ description: Forbidden – token lacks forms-read ability
+ post:
+ tags:
+ - Forms
+ summary: Create Form
+ description: "Create a new form; requires forms-write ability."
+ security:
+ - bearerAuth: []
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Form"
+ responses:
+ "201":
+ description: Form created
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Form"
+ "403":
+ description: Forbidden – token lacks forms-write ability
+ "/open/forms/{slug}":
+ get:
+ tags:
+ - Forms
+ summary: Get Form
+ description: Retrieve a single form.
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: slug
+ in: path
+ required: true
+ schema:
+ type: string
+ responses:
+ "200":
+ description: Successful
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Form"
+ "404":
+ description: Not Found
+ "403":
+ description: Forbidden
+ "/open/forms/{id}":
+ put:
+ tags:
+ - Forms
+ summary: Update Form
+ description: "Update an existing form. Requires `forms-write`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: number
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Form"
+ responses:
+ "200":
+ description: Updated
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Form"
+ "403":
+ description: Forbidden – token lacks forms-write ability
+ delete:
+ tags:
+ - Forms
+ summary: Delete Form
+ description: "Delete a form. Requires `forms-write`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: number
+ responses:
+ "204":
+ description: Deleted
+ "403":
+ description: Forbidden
+ "/open/forms/{id}/submissions":
+ get:
+ tags:
+ - Submissions
+ summary: List Submissions
+ description: "Requires `forms-read`. Supports pagination via the `page` query parameter."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: number
+ - name: page
+ in: query
+ required: false
+ schema:
+ type: number
+ minimum: 1
+ responses:
+ "200":
+ description: Successful
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Submission"
+ "403":
+ description: "Forbidden – token lacks forms-read ability"
+ post:
+ tags:
+ - Submissions
+ summary: Export Submissions (CSV)
+ description: "Export submissions as CSV. Requires `forms-read`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: id
+ in: path
+ 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."
+ responses:
+ "200":
+ description: CSV File
+ "403":
+ description: Forbidden
+ "/open/forms/{id}/submissions/export":
+ post:
+ tags:
+ - Submissions
+ summary: Export Submissions (CSV)
+ description: "Export submissions as CSV. Requires `forms-read`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: id
+ in: path
+ 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."
+ responses:
+ "200":
+ description: CSV File
+ "403":
+ description: Forbidden
+ "/open/forms/{id}/submissions/{submission_id}":
+ put:
+ tags:
+ - Submissions
+ summary: Update Submission
+ description: "Update a submission. Requires `forms-write` ability."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: number
+ - name: submission_id
+ in: path
+ required: true
+ schema:
+ type: number
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Submission"
+ responses:
+ "200":
+ description: Updated
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/Submission"
+ "403":
+ description: "Forbidden – token lacks forms-write ability"
+ delete:
+ tags:
+ - Submissions
+ summary: Delete Submission
+ description: "Requires `forms-write`."
+ security:
+ - bearerAuth: []
+ parameters:
+ - name: id
+ in: path
+ required: true
+ schema:
+ type: number
+ description: The ID of the form.
+ - name: submission_id
+ in: path
+ required: true
+ schema:
+ type: number
+ description: The ID of the submission to delete.
+ responses:
+ "200":
+ description: Successful
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ message:
+ type: string
+ example: Record successfully removed.
+ "403":
+ description: "Forbidden – token lacks forms-write ability"
+ "/external/zapier/validate":
+ get:
+ tags:
+ - Zapier
+ summary: Validate API Key
+ description: This endpoint is used by Zapier to test the validity of the API key.
+ responses:
+ "200":
+ description: API key is valid
+ "401":
+ description: Invalid API key
+ "/external/zapier/forms":
+ get:
+ tags:
+ - Zapier
+ summary: List Forms
+ description: Retrieve a list of forms available in a specific workspace.
+ parameters:
+ - name: workspace_id
+ in: query
+ description: The ID of the workspace for which to list forms
+ required: true
+ schema:
+ type: number
+ responses:
+ "200":
+ description: Successful response
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Form"
+ "/external/zapier/webhook":
+ post:
+ tags:
+ - Zapier
+ summary: New Submission Trigger
+ description: This endpoint is used to set up a webhook for new form submissions.
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ hookUrl:
+ type: string
+ description: The URL provided by Zapier to send the submission data
+ form_id:
+ type: number
+ description: The ID of the form for which to trigger the webhook
+ required:
+ - hookUrl
+ - form_id
+ responses:
+ "200":
+ description: Webhook successfully set up
+ delete:
+ tags:
+ - Zapier
+ summary: Unsubscribe Webhook
+ description: This endpoint is used to unsubscribe from the webhook.
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ hookUrl:
+ type: string
+ description: The URL provided by Zapier to stop sending the submission data
+ form_id:
+ type: number
+ description: The ID of the form for which to unsubscribe the webhook
+ required:
+ - hookUrl
+ - form_id
+ responses:
+ "200":
+ description: Webhook successfully unsubscribed
+ "/external/zapier/submissions/recent":
+ get:
+ tags:
+ - Zapier
+ summary: Sample Submission Polling
+ description: Retrieves the most recent submissions for a specified form.
+ parameters:
+ - name: form_id
+ in: query
+ description: The ID of the form to retrieve submissions for
+ required: true
+ schema:
+ type: number
+ responses:
+ "200":
+ description: Successful response
+ content:
+ application/json:
+ schema:
+ type: array
+ items:
+ $ref: "#/components/schemas/Submission"
+ "/users/{userId}":
+ get:
+ tags:
+ - Zapier
+ responses:
+ "200":
+ description: "Successful"
+
+components:
+ schemas:
+ Workspace:
+ type: object
+ properties:
+ id:
+ type: number
+ description: The unique identifier for the workspace.
+ example: 1
+ readOnly: true
+ name:
+ type: string
+ description: The name of the workspace.
+ example: "My Marketing Team"
+ icon:
+ type: string
+ description: The emoji or icon representing the workspace.
+ example: "πŸš€"
+ settings:
+ type: object
+ description: General settings for the workspace.
+ Form:
+ type: object
+ properties:
+ # Core form identification
+ id:
+ type: number
+ description: The unique identifier for the form.
+ readOnly: true
+ slug:
+ type: string
+ description: The URL-friendly slug for the form.
+ readOnly: true
+ workspace_id:
+ type: number
+ description: ID of the workspace that owns the form.
+ writeOnly: true
+ title:
+ type: string
+ description: The title of the form.
+ visibility:
+ type: string
+ enum: [public, draft, closed]
+ description: The current visibility state of the form.
+ tags:
+ type: array
+ items:
+ type: string
+ nullable: true
+ language:
+ type: string
+ description: Two-letter ISO language code.
+ custom_domain:
+ type: string
+ nullable: true
+
+ # Visual appearance and styling
+ theme:
+ type: string
+ enum: [default, simple, notion]
+ font_family:
+ type: string
+ nullable: true
+ color:
+ type: string
+ dark_mode:
+ type: string
+ enum: [light, dark, auto]
+ width:
+ type: string
+ enum: [centered, full]
+ size:
+ type: string
+ enum: [sm, md, lg]
+ border_radius:
+ type: string
+ enum: [none, small, full]
+ layout_rtl:
+ type: boolean
+ uppercase_labels:
+ type: boolean
+
+ # Media and branding
+ cover_picture:
+ type: string
+ format: uri
+ nullable: true
+ logo_picture:
+ type: string
+ format: uri
+ nullable: true
+ no_branding:
+ type: boolean
+ description: Whether to hide the OpnForm branding.
+ transparent_background:
+ type: boolean
+ description: Transparent background when form is embedded.
+
+ # Form behavior and submission settings
+ submit_button_text:
+ type: string
+ maxLength: 50
+ submitted_text:
+ type: string
+ maxLength: 2000
+ redirect_url:
+ type: string
+ format: uri
+ nullable: true
+ re_fillable:
+ type: boolean
+ re_fill_button_text:
+ type: string
+ maxLength: 50
+ confetti_on_submission:
+ type: boolean
+ show_progress_bar:
+ type: boolean
+
+ # Form closure and limits
+ closes_at:
+ type: string
+ format: date-time
+ nullable: true
+ closed_text:
+ type: string
+ nullable: true
+ max_submissions_count:
+ type: integer
+ minimum: 1
+ nullable: true
+ max_submissions_reached_text:
+ type: string
+ nullable: true
+
+ # User experience features
+ auto_save:
+ type: boolean
+ auto_focus:
+ type: boolean
+ enable_partial_submissions:
+ type: boolean
+ editable_submissions:
+ type: boolean
+ editable_submissions_button_text:
+ type: string
+ maxLength: 50
+
+ # Security and validation
+ password:
+ type: string
+ nullable: true
+ use_captcha:
+ type: boolean
+ captcha_provider:
+ type: string
+ enum: [recaptcha, hcaptcha]
+
+ # SEO and indexing
+ can_be_indexed:
+ type: boolean
+ seo_meta:
+ type: object
+ nullable: true
+
+ # Advanced features
+ custom_code:
+ type: string
+ nullable: true
+ database_fields_update:
+ type: array
+ items: {}
+ nullable: true
+ properties:
+ type: array
+ description: An array of field and layout blocks that make up the form.
+ items:
+ $ref: "#/components/schemas/FormProperty"
+ FormProperty:
+ type: object
+ description: A single field or layout block within a form.
+ properties:
+ id:
+ type: string
+ description: A unique identifier for the block.
+ format: uuid
+ type:
+ type: string
+ description: The type of block.
+ name:
+ type: string
+ description: The label or name of the field.
+ help:
+ type: string
+ description: "Help text displayed with the field."
+ hidden:
+ type: boolean
+ description: Whether the field is hidden from view.
+ required:
+ type: boolean
+ description: "Whether the field is required."
+ placeholder:
+ type: string
+ description: Placeholder text for the input.
+ width:
+ type: string
+ enum: [full, "1/2", "1/3", "2/3", "1/4", "3/4"]
+ description: The width of the block in the form layout.
+ additionalProperties: true
+ Submission:
+ type: object
+ properties:
+ submission_id:
+ type: number
+ readOnly: true
+ form_id:
+ type: number
+ readOnly: true
+ submitted_at:
+ type: string
+ format: date-time
+ readOnly: true
+ data:
+ type: object
+ additionalProperties: true
+ UserWorkspaceMember:
+ type: object
+ properties:
+ id:
+ type: number
+ name:
+ type: string
+ email:
+ type: string
+ format: email
+ role:
+ type: string
+ description: Role of the user inside the workspace (admin, member, viewer).
+ Invite:
+ type: object
+ properties:
+ id:
+ type: number
+ email:
+ type: string
+ format: email
+ role:
+ type: string
+ enum: [admin, user, readonly]
+ status:
+ type: string
+ enum: [pending, accepted]
+ valid_until:
+ type: string
+ format: date-time
+ description: Expiration timestamp for the invite
+ securitySchemes:
+ bearerAuth:
+ type: http
+ scheme: bearer
+ bearerFormat: JWT
+ description: "Personal Access Token"
+ x-bearer-scopemap:
+ "workspaces-read": "Read access to workspaces"
+ "workspaces-write": "Write access to workspaces"
+ "workspace-users-read": "Read access to workspace users"
+ "workspace-users-write": "Write access to workspace users"
+ "forms-read": "Read access to forms"
+ "forms-write": "Write access to forms"
diff --git a/docs/api-reference/submissions/delete-submission.mdx b/docs/api-reference/submissions/delete-submission.mdx
new file mode 100644
index 000000000..ca1941ef9
--- /dev/null
+++ b/docs/api-reference/submissions/delete-submission.mdx
@@ -0,0 +1,38 @@
+---
+openapi: delete /open/forms/{id}/submissions/{submission_id}
+---
+
+# Delete Submission
+
+Remove a single submission from a form.
+
+## Authentication & Scope
+
+Requires the `forms-write` ability.
+
+## Request
+
+```http
+DELETE /open/forms/{id}/submissions/{submission_id} HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|---------------|--------|----------------------------------------------|
+| id | number | Numeric ID of the parent form. |
+| submission_id | number | Numeric ID of the submission to permanently delete. |
+
+## Response
+
+`200 OK` – Returns a confirmation message.
+
+```json
+{
+ "message": "Record successfully removed."
+}
+```
+
+`403 Forbidden` – The token lacks `forms-write` or you don't have permission.
\ No newline at end of file
diff --git a/docs/api-reference/submissions/export-submissions-csv.mdx b/docs/api-reference/submissions/export-submissions-csv.mdx
new file mode 100644
index 000000000..38ed2f678
--- /dev/null
+++ b/docs/api-reference/submissions/export-submissions-csv.mdx
@@ -0,0 +1,50 @@
+---
+openapi: post /open/forms/{id}/submissions/export
+---
+
+# Export Submissions (CSV)
+
+Download a CSV file containing submissions for the specified form.
+
+## Authentication & Scope
+
+Requires `forms-read` ability.
+
+## Request
+
+```http
+POST /open/forms/{id}/submissions/export HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-----------|--------|-----------------------------|
+| id | number | Numeric ID of the form. |
+
+### Body Parameters
+
+| 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
+ }
+}
+```
+
+## Response
+
+`200 OK` – Returns a CSV file download. The response's `Content-Type` will be `text/csv` and include the `Content-Disposition` header.
+
+`403 Forbidden` – The token lacks `forms-read` or you don't have access.
\ No newline at end of file
diff --git a/docs/api-reference/submissions/list-submissions.mdx b/docs/api-reference/submissions/list-submissions.mdx
new file mode 100644
index 000000000..589047ebf
--- /dev/null
+++ b/docs/api-reference/submissions/list-submissions.mdx
@@ -0,0 +1,68 @@
+---
+openapi: get /open/forms/{id}/submissions
+---
+
+# List Submissions
+
+Retrieve submissions for a specific form.
+
+## Authentication & Scope
+
+Requires `forms-read` ability.
+
+## Request
+
+```http
+GET /open/forms/{id}/submissions?page=1 HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| 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. |
+
+## Response
+
+`200 OK` – Returns a paginated collection of `Submission` objects.
+
+```json
+{
+ "data": [
+ {
+ "submission_id": 1,
+ "form_id": 123,
+ "submitted_at": "2024-06-12T09:15:23Z",
+ "data": {
+ "First name": "Alice",
+ "Email": "[email protected]"
+ }
+ }
+ ],
+ "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
diff --git a/docs/api-reference/submissions/update-submission.mdx b/docs/api-reference/submissions/update-submission.mdx
new file mode 100644
index 000000000..434926c95
--- /dev/null
+++ b/docs/api-reference/submissions/update-submission.mdx
@@ -0,0 +1,66 @@
+---
+openapi: put /open/forms/{id}/submissions/{submission_id}
+---
+
+# Update Submission
+
+Modify an existing submission's answers. This endpoint is useful when you want to correct values or enrich a submission after it was created.
+
+## Authentication & Scope
+
+Requires `forms-write` ability.
+
+## Request
+
+```http
+PUT /open/forms/{id}/submissions/{submission_id} HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|----------------|--------|-------------------------------------------|
+| id | number | ID of the parent form. |
+| submission_id | number | ID of the submission you want to update. |
+
+### Body Parameters
+
+The payload should be an object whose keys correspond to the **field IDs** in the form definition. You only need to send the fields you intend to change. Other special meta-fields:
+
+| Field | Type | Description |
+|------------------|---------|---------------------------------------|
+| completion_time | integer | Optional; total time in seconds. |
+
+Example (updating two answers):
+
+```json
+{
+ "field_name": "Alice",
+ "field_email": "[email protected]",
+ "completion_time": 125
+}
+```
+
+## Response
+
+`200 OK` – Returns the updated `Submission` object plus a success message.
+
+```json
+{
+ "message": "Record successfully updated.",
+ "data": {
+ "submission_id": 17,
+ "form_id": 99,
+ "submitted_at": "2024-06-12T10:11:12Z",
+ "data": {
+ "field_name": "Alice",
+ "field_email": "[email protected]"
+ }
+ }
+}
+```
+
+`403 Forbidden` – Token lacks `forms-write` or you do not have permission.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/add-workspace-user.mdx b/docs/api-reference/workspace-users/add-workspace-user.mdx
new file mode 100644
index 000000000..8fd8c1458
--- /dev/null
+++ b/docs/api-reference/workspace-users/add-workspace-user.mdx
@@ -0,0 +1,60 @@
+---
+openapi: post /open/workspaces/{workspaceId}/users/add
+---
+
+# Add Workspace User
+
+Invite an existing OpnForm user to a workspace or send an email invite if the user doesn't yet have an account.
+
+## Authentication & Scope
+
+Requires the `workspace-users-write` ability and **admin** privileges in the workspace.
+
+## Request
+
+```http
+POST /open/workspaces/{workspaceId}/users/add HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|------------------------------|
+| workspaceId | number | ID of the target workspace. |
+
+### Body Parameters
+
+| Field | Type | Required | Description |
+|-------|--------|----------|--------------------------------------------------------------------|
+| email | string | Yes | Email address of the user to add/invite. |
+| role | string | Yes | Role to assign (`admin`, `user`, or `readonly`). |
+
+Example:
+
+```json
+{
+ "email": "[email protected]",
+ "role": "user"
+}
+```
+
+## Response
+
+`200 OK` – One of the following messages:
+
+* `"User has been successfully added to workspace."` – when the user account already exists.
+* `"Registration invitation email sent to user."` – when an invitation email was sent.
+* `"User is already in workspace."` – if the user is already a member.
+
+The response structure:
+
+```json
+{
+ "message": "User has been successfully added to workspace."
+}
+```
+
+`403 Forbidden` – Token lacks `workspace-users-write` or insufficient privileges.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/cancel-workspace-invite.mdx b/docs/api-reference/workspace-users/cancel-workspace-invite.mdx
new file mode 100644
index 000000000..ef64633ac
--- /dev/null
+++ b/docs/api-reference/workspace-users/cancel-workspace-invite.mdx
@@ -0,0 +1,45 @@
+---
+openapi: delete /open/workspaces/{workspaceId}/invites/{inviteId}/cancel
+---
+
+# Cancel Workspace Invite
+
+Delete an outstanding workspace invitation.
+
+## Authentication & Scope
+
+Requires `workspace-users-write` ability and **admin** privileges in the workspace.
+
+## Request
+
+```http
+DELETE /open/workspaces/{workspaceId}/invites/{inviteId}/cancel HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|-------------------------------------------|
+| workspaceId | number | ID of the workspace. |
+| inviteId | number | ID of the invite to cancel. |
+
+## Response
+
+`200 OK` – Confirmation message.
+
+```json
+{
+ "message": "Invite deleted successfully."
+}
+```
+
+Possible errors:
+
+* `Invite not found for this workspace.`
+* `Invite already accepted.`
+
+Both are returned with status **400**.
+
+`403 Forbidden` – Token lacks `workspace-users-write` or insufficient privileges.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/leave-workspace.mdx b/docs/api-reference/workspace-users/leave-workspace.mdx
new file mode 100644
index 000000000..aeb4b172d
--- /dev/null
+++ b/docs/api-reference/workspace-users/leave-workspace.mdx
@@ -0,0 +1,33 @@
+---
+openapi: post /open/workspaces/{workspaceId}/leave
+---
+
+# Leave Workspace
+
+Remove **your own** user account from a workspace.
+
+## Authentication & Scope
+
+Requires the `workspace-users-write` ability. Only the authenticated user can leave; admins cannot use this endpoint to kick others (see [Remove Workspace User](./remove-workspace-user)).
+
+## Request
+
+```http
+POST /open/workspaces/{workspaceId}/leave HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|-----------------------------|
+| workspaceId | number | ID of the workspace to quit |
+
+Request body is empty.
+
+## Response
+
+`204 No Content` – You successfully left the workspace.
+
+`403 Forbidden` – Token lacks `workspace-users-write` or you aren't a member.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/list-workspace-invites.mdx b/docs/api-reference/workspace-users/list-workspace-invites.mdx
new file mode 100644
index 000000000..85531ad1b
--- /dev/null
+++ b/docs/api-reference/workspace-users/list-workspace-invites.mdx
@@ -0,0 +1,43 @@
+---
+openapi: get /open/workspaces/{workspaceId}/invites
+---
+
+# List Workspace Invites
+
+Retrieve all pending or accepted invitations for a workspace.
+
+## Authentication & Scope
+
+Requires `workspace-users-read` ability. The requester must be a member of the workspace.
+
+## Request
+
+```http
+GET /open/workspaces/{workspaceId}/invites HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|-----------------------------|
+| workspaceId | number | ID of the workspace. |
+
+## Response
+
+`200 OK` – Array of Invite objects.
+
+```json
+[
+ {
+ "id": 55,
+ "email": "[email protected]",
+ "role": "user",
+ "status": "pending",
+ "valid_until": "2024-06-25T23:59:59Z"
+ }
+]
+```
+
+`403 Forbidden` – Token lacks `workspace-users-read` or you lack access.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/list-workspace-users.mdx b/docs/api-reference/workspace-users/list-workspace-users.mdx
new file mode 100644
index 000000000..27667035e
--- /dev/null
+++ b/docs/api-reference/workspace-users/list-workspace-users.mdx
@@ -0,0 +1,50 @@
+---
+openapi: get /open/workspaces/{workspaceId}/users
+---
+
+# List Workspace Users
+
+Fetch all members of a workspace, including their assigned role.
+
+## Authentication & Scope
+
+Requires `workspace-users-read` ability. The requesting user must belong to the workspace.
+
+## Request
+
+```http
+GET /open/workspaces/{workspaceId}/users HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|----------------------------------|
+| workspaceId | number | ID of the workspace to retrieve. |
+
+No query parameters are supported.
+
+## Response
+
+`200 OK` – An array of user objects, each including a `role` field (from the pivot table).
+
+```json
+[
+ {
+ "id": 3,
+ "name": "Alice Porter",
+ "email": "[email protected]",
+ "role": "admin"
+ },
+ {
+ "id": 8,
+ "name": "Bob Smith",
+ "email": "[email protected]",
+ "role": "member"
+ }
+]
+```
+
+`403 Forbidden` – Token lacks `workspace-users-read` or you are not a member.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/remove-workspace-user.mdx b/docs/api-reference/workspace-users/remove-workspace-user.mdx
new file mode 100644
index 000000000..a24668c33
--- /dev/null
+++ b/docs/api-reference/workspace-users/remove-workspace-user.mdx
@@ -0,0 +1,38 @@
+---
+openapi: delete /open/workspaces/{workspaceId}/users/{userId}/remove
+---
+
+# Remove Workspace User
+
+Kick a member out of a workspace. If the removed user has no remaining workspaces, a personal workspace will be automatically created.
+
+## Authentication & Scope
+
+Requires the `workspace-users-write` ability and **admin** privileges in the workspace.
+
+## Request
+
+```http
+DELETE /open/workspaces/{workspaceId}/users/{userId}/remove HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|-----------------------------------|
+| workspaceId | number | ID of the workspace. |
+| userId | number | ID of the user to remove. |
+
+## Response
+
+`200 OK` – Confirmation message.
+
+```json
+{
+ "message": "User removed from workspace successfully."
+}
+```
+
+`403 Forbidden` – Token lacks `workspace-users-write` or insufficient privileges.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/resend-workspace-invite.mdx b/docs/api-reference/workspace-users/resend-workspace-invite.mdx
new file mode 100644
index 000000000..8532212aa
--- /dev/null
+++ b/docs/api-reference/workspace-users/resend-workspace-invite.mdx
@@ -0,0 +1,47 @@
+---
+openapi: post /open/workspaces/{workspaceId}/invites/{inviteId}/resend
+---
+
+# Resend Workspace Invite
+
+Send the invitation email again to a pending workspace invite.
+
+## Authentication & Scope
+
+Requires `workspace-users-write` ability and **admin** privileges in the workspace.
+
+## Request
+
+```http
+POST /open/workspaces/{workspaceId}/invites/{inviteId}/resend HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|-------------------------------------------|
+| workspaceId | number | ID of the workspace. |
+| inviteId | number | ID of the invite to resend. |
+
+Request body is empty.
+
+## Response
+
+`200 OK` – Confirmation message.
+
+```json
+{
+ "message": "Invite email resent successfully."
+}
+```
+
+Possible errors:
+
+* `Invite not found for this workspace.`
+* `Invite already accepted.`
+
+Both are returned with status **400** (wrapped in the `errors` format).
+
+`403 Forbidden` – Token lacks `workspace-users-write` or insufficient privileges.
\ No newline at end of file
diff --git a/docs/api-reference/workspace-users/update-workspace-user-role.mdx b/docs/api-reference/workspace-users/update-workspace-user-role.mdx
new file mode 100644
index 000000000..48c6880ce
--- /dev/null
+++ b/docs/api-reference/workspace-users/update-workspace-user-role.mdx
@@ -0,0 +1,53 @@
+---
+openapi: put /open/workspaces/{workspaceId}/users/{userId}/update-role
+---
+
+# Update Workspace User Role
+
+Change a member's role within a workspace.
+
+## Authentication & Scope
+
+Requires the `workspace-users-write` ability and **admin** privileges in the workspace.
+
+## Request
+
+```http
+PUT /open/workspaces/{workspaceId}/users/{userId}/update-role HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|-----------------------------|
+| workspaceId | number | ID of the workspace. |
+| userId | number | ID of the user to update. |
+
+### Body Parameters
+
+| Field | Type | Required | Description |
+|-------|--------|----------|---------------------------------------------|
+| role | string | Yes | New role (`admin`, `user`, or `readonly`). |
+
+Example:
+
+```json
+{
+ "role": "readonly"
+}
+```
+
+## Response
+
+`200 OK` – Confirmation message.
+
+```json
+{
+ "message": "User role changed successfully."
+}
+```
+
+`403 Forbidden` – Token lacks `workspace-users-write` or you lack permission.
\ No newline at end of file
diff --git a/docs/api-reference/workspaces/create-workspace.mdx b/docs/api-reference/workspaces/create-workspace.mdx
new file mode 100644
index 000000000..ef3bc4027
--- /dev/null
+++ b/docs/api-reference/workspaces/create-workspace.mdx
@@ -0,0 +1,57 @@
+---
+openapi: post /open/workspaces/create
+---
+
+# Create Workspace
+
+Create a new workspace and automatically add the current user as an **admin** of that workspace.
+
+## Authentication & Scope
+
+Requires the `workspaces-write` ability.
+
+## Request
+
+```http
+POST /open/workspaces/create HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Body Parameters
+
+| Field | Type | Required | Description |
+|-------|--------|----------|----------------------------------------|
+| name | string | Yes | Display name of the workspace. |
+| emoji | string | No | Optional emoji/icon to represent it. |
+
+Example:
+
+```json
+{
+ "name": "Design Team",
+ "emoji": "🎨"
+}
+```
+
+## Response
+
+`200 OK` – Returns the newly created workspace information.
+
+```json
+{
+ "message": "Workspace created.",
+ "workspace_id": 7,
+ "workspace": {
+ "id": 7,
+ "name": "Design Team",
+ "icon": "🎨",
+ "settings": {},
+ "max_file_size": 25,
+ "is_readonly": false
+ }
+}
+```
+
+`403 Forbidden` – Token lacks `workspaces-write` or user not allowed.
\ No newline at end of file
diff --git a/docs/api-reference/workspaces/delete-workspace.mdx b/docs/api-reference/workspaces/delete-workspace.mdx
new file mode 100644
index 000000000..5709cc893
--- /dev/null
+++ b/docs/api-reference/workspaces/delete-workspace.mdx
@@ -0,0 +1,38 @@
+---
+openapi: delete /open/workspaces/{workspaceId}
+---
+
+# Delete Workspace
+
+Permanently remove a workspace. This operation is irreversible and will remove all associated forms, submissions, and settings.
+
+## Authentication & Scope
+
+Requires the `workspaces-write` ability. User must be an **admin** of the workspace.
+
+## Request
+
+```http
+DELETE /open/workspaces/{workspaceId} HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|-------------|--------|--------------------------------------------|
+| workspaceId | number | ID of the workspace to delete. |
+
+## Response
+
+`200 OK` – Confirmation message and the ID of the deleted workspace.
+
+```json
+{
+ "message": "Workspace deleted.",
+ "workspace_id": 12
+}
+```
+
+`403 Forbidden` – The token lacks `workspaces-write` or you lack permission.
\ No newline at end of file
diff --git a/docs/api-reference/workspaces/list-workspaces.mdx b/docs/api-reference/workspaces/list-workspaces.mdx
new file mode 100644
index 000000000..c57d483bc
--- /dev/null
+++ b/docs/api-reference/workspaces/list-workspaces.mdx
@@ -0,0 +1,44 @@
+---
+openapi: get /open/workspaces
+---
+
+# List Workspaces
+
+Return the workspaces the authenticated user belongs to.
+
+## Authentication & Scope
+
+Requires the `workspaces-read` ability.
+
+## Request
+
+```http
+GET /open/workspaces HTTP/1.1
+Host: api.opnform.com
+Authorization: Bearer <token>
+```
+
+No query parameters are supported.
+
+## Response
+
+`200 OK` – An array of Workspace objects.
+
+```json
+[
+ {
+ "id": 1,
+ "name": "Marketing",
+ "icon": "πŸš€",
+ "settings": {
+ "email_settings": {
+ "from_name": "OpnForm"
+ }
+ },
+ "max_file_size": 25,
+ "is_readonly": false
+ }
+]
+```
+
+`403 Forbidden` – The token lacks `workspaces-read` or you do not have the necessary permissions.
\ No newline at end of file
diff --git a/docs/api-reference/workspaces/update-workspace.mdx b/docs/api-reference/workspaces/update-workspace.mdx
new file mode 100644
index 000000000..00138935d
--- /dev/null
+++ b/docs/api-reference/workspaces/update-workspace.mdx
@@ -0,0 +1,61 @@
+---
+openapi: put /open/workspaces/{workspaceId}
+---
+
+# Update Workspace
+
+Rename a workspace or change its icon.
+
+## Authentication & Scope
+
+Requires the `workspaces-write` ability. The authenticated user must be an **admin** of the workspace.
+
+## Request
+
+```http
+PUT /open/workspaces/{workspaceId} HTTP/1.1
+Host: api.opnform.com
+Content-Type: application/json
+Authorization: Bearer <token>
+```
+
+### Path Parameters
+
+| Parameter | Type | Description |
+|---------------|--------|------------------------------------------|
+| workspaceId | number | Numeric identifier of the workspace. |
+
+### Body Parameters
+
+| Field | Type | Required | Description |
+|-------|--------|----------|----------------------------------------|
+| name | string | Yes | New name of the workspace. |
+| emoji | string | No | New emoji/icon (leave blank to clear). |
+
+Example:
+
+```json
+{
+ "name": "Marketing Team",
+ "emoji": "πŸš€"
+}
+```
+
+## Response
+
+`200 OK` – Returns a confirmation plus the updated workspace object.
+
+```json
+{
+ "message": "Workspace updated.",
+ "workspace": {
+ "id": 1,
+ "name": "Marketing Team",
+ "icon": "πŸš€",
+ "max_file_size": 25,
+ "is_readonly": false
+ }
+}
+```
+
+`403 Forbidden` – Token lacks `workspaces-write` or user lacks permission.
\ No newline at end of file
diff --git a/docs/api-reference/zapier/get-users.mdx b/docs/api-reference/zapier/get-users.mdx
new file mode 100644
index 000000000..1fce4bb32
--- /dev/null
+++ b/docs/api-reference/zapier/get-users.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /users/{userId}
+---
\ No newline at end of file
diff --git a/docs/api-reference/zapier/list-forms.mdx b/docs/api-reference/zapier/list-forms.mdx
new file mode 100644
index 000000000..0b504c438
--- /dev/null
+++ b/docs/api-reference/zapier/list-forms.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /external/zapier/forms
+---
\ No newline at end of file
diff --git a/docs/api-reference/zapier/new-submission-trigger.mdx b/docs/api-reference/zapier/new-submission-trigger.mdx
new file mode 100644
index 000000000..9ea1cf121
--- /dev/null
+++ b/docs/api-reference/zapier/new-submission-trigger.mdx
@@ -0,0 +1,3 @@
+---
+openapi: post /external/zapier/webhook
+---
\ No newline at end of file
diff --git a/docs/api-reference/zapier/sample-submission-polling.mdx b/docs/api-reference/zapier/sample-submission-polling.mdx
new file mode 100644
index 000000000..a1d783ca5
--- /dev/null
+++ b/docs/api-reference/zapier/sample-submission-polling.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /external/zapier/submissions/recent
+---
\ No newline at end of file
diff --git a/docs/api-reference/zapier/unsubscribe-webhook.mdx b/docs/api-reference/zapier/unsubscribe-webhook.mdx
new file mode 100644
index 000000000..658801fb6
--- /dev/null
+++ b/docs/api-reference/zapier/unsubscribe-webhook.mdx
@@ -0,0 +1,3 @@
+---
+openapi: delete /external/zapier/webhook
+---
\ No newline at end of file
diff --git a/docs/api-reference/zapier/validate-api-key.mdx b/docs/api-reference/zapier/validate-api-key.mdx
new file mode 100644
index 000000000..ac2ac5fe2
--- /dev/null
+++ b/docs/api-reference/zapier/validate-api-key.mdx
@@ -0,0 +1,3 @@
+---
+openapi: get /external/zapier/validate
+---
\ No newline at end of file
diff --git a/docs/docs.json b/docs/docs.json
new file mode 100644
index 000000000..0b524fefc
--- /dev/null
+++ b/docs/docs.json
@@ -0,0 +1,174 @@
+{
+ "$schema": "https://mintlify.com/docs.json",
+ "theme": "mint",
+ "name": "OpnForm Technical Docs",
+ "colors": {
+ "primary": "#3b82f6",
+ "light": "#60a5fa",
+ "dark": "#2563eb"
+ },
+ "favicon": "/logo.svg",
+ "navigation": {
+ "tabs": [
+ {
+ "tab": "Documentation",
+ "groups": [
+ {
+ "group": "Get Started",
+ "pages": [
+ "introduction",
+ "tech-stack"
+ ]
+ },
+ {
+ "group": "Deployment",
+ "pages": [
+ "deployment/docker",
+ "deployment/docker-development",
+ "deployment/local-deployment",
+ "deployment/cloud-vs-self-hosting"
+ ]
+ },
+ {
+ "group": "Configuration",
+ "pages": [
+ "configuration/environment-variables",
+ "configuration/aws-s3",
+ "configuration/email-setup",
+ "configuration/custom-domain",
+ "configuration/subdomain-redirect"
+ ]
+ }
+ ]
+ },
+ {
+ "tab": "API Reference",
+ "groups": [
+ {
+ "group": "Overview",
+ "pages": [
+ "api-reference/introduction",
+ "api-reference/api-keys",
+ "api-reference/changelog"
+ ]
+ },
+ {
+ "group": "Workspaces",
+ "pages": [
+ "api-reference/workspaces/list-workspaces",
+ "api-reference/workspaces/create-workspace",
+ "api-reference/workspaces/update-workspace",
+ "api-reference/workspaces/delete-workspace"
+ ]
+ },
+ {
+ "group": "Workspace Users",
+ "pages": [
+ "api-reference/workspace-users/list-workspace-users",
+ "api-reference/workspace-users/list-workspace-invites",
+ "api-reference/workspace-users/add-workspace-user",
+ "api-reference/workspace-users/remove-workspace-user",
+ "api-reference/workspace-users/update-workspace-user-role",
+ "api-reference/workspace-users/leave-workspace",
+ "api-reference/workspace-users/resend-workspace-invite",
+ "api-reference/workspace-users/cancel-workspace-invite"
+ ]
+ },
+ {
+ "group": "Forms",
+ "pages": [
+ "api-reference/forms/list-forms",
+ "api-reference/forms/create-form",
+ "api-reference/forms/get-form",
+ "api-reference/forms/update-form",
+ "api-reference/forms/delete-form"
+ ]
+ },
+ {
+ "group": "Submissions",
+ "pages": [
+ "api-reference/submissions/list-submissions",
+ "api-reference/submissions/export-submissions-csv",
+ "api-reference/submissions/update-submission",
+ "api-reference/submissions/delete-submission"
+ ]
+ },
+ {
+ "group": "Zapier",
+ "pages": [
+ "api-reference/zapier/validate-api-key",
+ "api-reference/zapier/list-forms",
+ "api-reference/zapier/new-submission-trigger",
+ "api-reference/zapier/unsubscribe-webhook",
+ "api-reference/zapier/sample-submission-polling"
+ ]
+ }
+ ]
+ },
+ {
+ "tab": "Contributing",
+ "groups": [
+ {
+ "group": "Contributing",
+ "pages": [
+ "contributing/getting-started",
+ "contributing/new-form-block",
+ "contributing/new-integration"
+ ]
+ }
+ ]
+ }
+ ],
+ "global": {
+ "anchors": [
+ {
+ "anchor": "Product Documentation",
+ "href": "https://help.opnform.com",
+ "icon": "book-open-cover"
+ },
+ {
+ "anchor": "Community",
+ "href": "https://discord.gg/YTSjU2a9TS",
+ "icon": "discord"
+ },
+ {
+ "anchor": "Changelog",
+ "href": "https://feedback.opnform.com/changelog",
+ "icon": "sparkles"
+ },
+ {
+ "anchor": "Roadmap",
+ "href": "https://feedback.opnform.com/roadmap",
+ "icon": "road"
+ }
+ ]
+ }
+ },
+ "logo": {
+ "light": "/logo.svg",
+ "dark": "/logo.svg"
+ },
+ "navbar": {
+ "links": [
+ {
+ "label": "OpnForm",
+ "href": "https://opnform.com?utm_source=docs&utm_medium=topbar&utm_campaign=technical_docs"
+ },
+ {
+ "label": "GitHub",
+ "href": "https://github.com/JhumanJ/OpnForm"
+ }
+ ],
+ "primary": {
+ "type": "button",
+ "label": "Dashboard",
+ "href": "https://opnform.com"
+ }
+ },
+ "footer": {
+ "socials": {
+ "twitter": "https://twitter.com/opnform",
+ "github": "https://github.com/JhumanJ/OpnForm"
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/mint.json b/docs/mint.json
deleted file mode 100644
index d34614cab..000000000
--- a/docs/mint.json
+++ /dev/null
@@ -1,124 +0,0 @@
-{
- "$schema": "https://mintlify.com/schema.json",
- "name": "OpnForm Technical Docs",
- "logo": {
- "light": "/logo.svg",
- "dark": "/logo.svg"
- },
- "favicon": "/logo.svg",
- "colors": {
- "primary": "#3b82f6",
- "light": "#60a5fa",
- "dark": "#2563eb",
- "anchors": {
- "from": "#2563eb",
- "to": "#60a5fa"
- }
- },
- "topbarLinks": [
- {
- "name": "OpnForm",
- "url": "https://opnform.com?utm_source=docs&utm_medium=topbar&utm_campaign=technical_docs"
- },
- {
- "name": "GitHub",
- "url": "https://github.com/JhumanJ/OpnForm"
- }
- ],
- "topbarCtaButton": {
- "name": "Dashboard",
- "url": "https://opnform.com"
- },
- "tabs": [
- {
- "name": "API Reference",
- "url": "api-reference"
- },
- {
- "name": "Contributing",
- "url": "contributing"
- }
- ],
- "anchors": [
- {
- "name": "Product Documentation",
- "icon": "book-open-cover",
- "url": "https://help.opnform.com"
- },
- {
- "name": "Community",
- "icon": "discord",
- "url": "https://discord.gg/YTSjU2a9TS"
- },
- {
- "name": "Changelog",
- "icon": "sparkles",
- "url": "https://feedback.opnform.com/changelog"
- },
- {
- "name": "Roadmap",
- "icon": "road",
- "url": "https://feedback.opnform.com/roadmap"
- }
- ],
- "navigation": [
- {
- "group": "Get Started",
- "pages": [
- "introduction",
- "tech-stack"
- ]
- },
- {
- "group": "Deployment",
- "pages": [
- "deployment/docker",
- "deployment/docker-development",
- "deployment/local-deployment",
- "deployment/cloud-vs-self-hosting"
- ]
- },
- {
- "group": "Configuration",
- "pages": [
- "configuration/environment-variables",
- "configuration/aws-s3",
- "configuration/email-setup",
- "configuration/custom-domain",
- "configuration/subdomain-redirect"
- ]
- },
- {
- "group": "API Reference",
- "pages": [
- "api-reference/introduction"
- ]
- },
- {
- "group": "Zapier Endpoints",
- "pages": [
- "api-reference/endpoint/validate-api-key",
- "api-reference/endpoint/list-forms",
- "api-reference/endpoint/new-submission-trigger",
- "api-reference/endpoint/unsubscribe-webhook",
- "api-reference/endpoint/sample-submission-polling"
- ]
- },
- {
- "group": "Contributing",
- "pages": [
- "contributing/getting-started",
- "contributing/new-form-block",
- "contributing/new-integration"
- ]
- }
- ],
- "footerSocials": {
- "twitter": "https://twitter.com/opnform",
- "github": "https://github.com/JhumanJ/OpnForm"
- },
- "openapi": "/api-reference/openapi.json",
- "feedback": {
- "suggestEdit": true
- }
-}
\ No newline at end of file
diff --git a/public_api_dual_auth_progress.md b/public_api_dual_auth_progress.md
new file mode 100644
index 000000000..943343a7f
--- /dev/null
+++ b/public_api_dual_auth_progress.md
@@ -0,0 +1,48 @@
+# Public API Dual Authentication Implementation Progress
+
+_Last updated: 2025-06-17 00:05 UTC_
+_Last updated: 2025-06-17 00:08 UTC_
+_Last updated: 2025-06-17 00:11 UTC_
+_Last updated: 2025-06-17 00:25 UTC_
+_Last updated: 2025-06-17 00:32 UTC_
+_Last updated: 2025-06-17 00:38 UTC_
+_Last updated: 2025-06-17 00:43 UTC_
+_Last updated: 2025-06-17 00:47 UTC_
+_Last updated: 2025-06-17 00:52 UTC_
+_Last updated: 2025-06-17 00:57 UTC_
+_Last updated: 2025-06-17 01:02 UTC_
+
+## Overview
+This document tracks the implementation progress for introducing a dual-authentication layer (JWT & Sanctum) to expose a public API while reusing existing endpoints. All updates to this file should refresh the **Last updated** timestamp and append a brief note to the **Progress log**.
+
+---
+
+## Task Checklist
+- [x] Create `api/config/sanctum_routes.php` with the full list of whitelisted route names.
+- [x] Update `api/app/Enums/AccessTokenAbility.php` with `read`/`write` cases for all resources.
+- [x] Create the `api/app/Http/Middleware/AuthenticateWithJwtOrSanctum.php` middleware class.
+- [x] Register the middleware alias `auth.multi` in `api/app/Http/Kernel.php`.
+- [x] Change `auth:api` to `auth.multi` in `api/routes/api.php`.
+- [x] Create/Update `FormPolicy` with Sanctum ability checks.
+- [x] Create/Update Policy for Submissions with Sanctum ability checks.
+- [x] Create/Update `WorkspacePolicy` with Sanctum ability checks.
+- [x] Create/Update Policy for Workspace Users with Sanctum ability checks.
+- [x] Update `client/components/AccessTokenModal.vue` (or similar) to display new abilities.
+- [ ] Run all tests described in the "Testing Instructions" section.
+- [x] Document all newly exposed endpoints in `openapi.json` and the Mintlify markdown files.
+
+---
+
+## Progress Log
+- 2025-06-17 00:00 UTC – Initialized progress tracking file.
+- 2025-06-17 00:05 UTC – Created `api/config/sanctum_routes.php` whitelist configuration.
+- 2025-06-17 00:08 UTC – Added granular read/write abilities to `AccessTokenAbility` enum.
+- 2025-06-17 00:11 UTC – Implemented `AuthenticateWithJwtOrSanctum` middleware.
+- 2025-06-17 00:25 UTC – Added `auth.multi` alias to Kernel and updated routes to use new middleware.
+- 2025-06-17 00:32 UTC – Added Sanctum ability checks to `FormPolicy`.
+- 2025-06-17 00:38 UTC – Added `SubmissionPolicy` with Sanctum read/write checks and registered it.
+- 2025-06-17 00:43 UTC – Added Sanctum ability checks to `WorkspacePolicy`.
+- 2025-06-17 00:47 UTC – Added Sanctum write ability enforcement to workspace admin actions.
+- 2025-06-17 00:52 UTC – Updated token modal and store to include granular abilities and enable selection.
+- 2025-06-17 00:57 UTC – Added new paths to `openapi.json` and created markdown doc `open-forms-list.mdx`.
+- 2025-06-17 01:02 UTC – Completed docs for Submissions, Workspaces, Workspace Users and updated OpenAPI accordingly.
\ No newline at end of file