Beautiful Open-Source Form Builder
API + Update authorization and routing for form integrations (#931)
Julien Nahum8eb1b923b660
diff --git a/api/app/Http/Controllers/Forms/Integration/FormIntegrationsController.php b/api/app/Http/Controllers/Forms/Integration/FormIntegrationsController.phpindex 2a71cb22c..5404b94d0 100644--- a/api/app/Http/Controllers/Forms/Integration/FormIntegrationsController.php+++ b/api/app/Http/Controllers/Forms/Integration/FormIntegrationsController.php@@ -17,7 +17,7 @@ class FormIntegrationsController extends Controllerpublic function index(Form $form){- $this->authorize('update', $form);+ $this->authorize('manageIntegrations', $form);$integrations = FormIntegration::query()->where('form_id', $form->id)@@ -29,7 +29,7 @@ class FormIntegrationsController extends Controllerpublic function create(FormIntegrationsRequest $request, Form $form){- $this->authorize('update', $form);+ $this->authorize('manageIntegrations', $form);/** @var FormIntegration $formIntegration */$formIntegration = FormIntegration::create(@@ -49,7 +49,7 @@ class FormIntegrationsController extends Controllerpublic function update(FormIntegrationsRequest $request, Form $form, string $integrationid){- $this->authorize('update', $form);+ $this->authorize('manageIntegrations', $form);$formIntegration = FormIntegration::findOrFail((int)$integrationid);$formIntegration->update($request->toIntegrationData());@@ -63,7 +63,7 @@ class FormIntegrationsController extends Controllerpublic function destroy(Form $form, string $integrationid){- $this->authorize('update', $form);+ $this->authorize('manageIntegrations', $form);$formIntegration = FormIntegration::findOrFail((int)$integrationid);$formIntegration->delete();diff --git a/api/app/Http/Controllers/Forms/Integration/FormIntegrationsEventController.php b/api/app/Http/Controllers/Forms/Integration/FormIntegrationsEventController.phpindex 8657879e7..249238892 100644--- a/api/app/Http/Controllers/Forms/Integration/FormIntegrationsEventController.php+++ b/api/app/Http/Controllers/Forms/Integration/FormIntegrationsEventController.php@@ -16,7 +16,7 @@ class FormIntegrationsEventController extends Controllerpublic function index(Form $form, string $integrationid){- $this->authorize('update', $form);+ $this->authorize('manageIntegrations', $form);return FormIntegrationsEventResource::collection(FormIntegrationsEvent::where('integration_id', (int)$integrationid)->orderByDesc('created_at')->get()diff --git a/api/app/Http/Middleware/ImpersonationMiddleware.php b/api/app/Http/Middleware/ImpersonationMiddleware.phpindex a75ce6d32..3b51f70f4 100644--- a/api/app/Http/Middleware/ImpersonationMiddleware.php+++ b/api/app/Http/Middleware/ImpersonationMiddleware.php@@ -39,7 +39,7 @@ class ImpersonationMiddleware'open.forms.submissions','open.forms.submissions.file','open.providers',- 'open.forms.integrations',+ 'open.forms.integrations.index','open.forms.integrations.events',// Workspacesdiff --git a/api/app/Policies/FormPolicy.php b/api/app/Policies/FormPolicy.phpindex ffa8595ec..39447420a 100644--- a/api/app/Policies/FormPolicy.php+++ b/api/app/Policies/FormPolicy.php@@ -104,6 +104,29 @@ class FormPolicyreturn $this->canPerformWriteOperation($user, $form);}+ /**+ * Determine whether the user can manage integrations on the model.+ * For Sanctum tokens, requires the manage-integrations ability.+ * For other auth methods, allows if user has write permission.+ *+ * @return mixed+ */+ public function manageIntegrations(User $user, Form $form)+ {+ // First check if user has write permission+ if (!$this->canPerformWriteOperation($user, $form)) {+ return false;+ }++ // If using Sanctum token, ensure it has manage-integrations ability+ if ($token = $user->currentAccessToken()) {+ return $token->can('manage-integrations');+ }++ // For non-Sanctum auth (JWT/session), allow if they can write+ return true;+ }+/*** Determine whether the user can permanently delete the model.*diff --git a/api/config/sanctum-routes.php b/api/config/sanctum-routes.phpindex d763b0ad8..e82840cc9 100644--- a/api/config/sanctum-routes.php+++ b/api/config/sanctum-routes.php@@ -15,6 +15,13 @@ return ['open.forms.submissions.export','open.forms.submissions.destroy',+ // Form Integrations+ 'open.forms.integrations.index',+ 'open.forms.integrations.create',+ 'open.forms.integrations.update',+ 'open.forms.integrations.destroy',+ 'open.forms.integrations.events',+// Workspace CRUD'open.workspaces.index','open.workspaces.create',diff --git a/api/routes/api.php b/api/routes/api.phpindex 06bbc8427..aa5e0464b 100644--- a/api/routes/api.php+++ b/api/routes/api.php@@ -198,21 +198,21 @@ Route::group(['middleware' => 'auth.multi'], function () {Route::get('/{form}/integrations',[FormIntegrationsController::class, 'index']- )->name('integrations');+ )->name('integrations.index');Route::post(- '/{form}/integration',+ '/{form}/integrations',[FormIntegrationsController::class, 'create']- )->name('integration.create');+ )->name('integrations.create');Route::put(- '/{form}/integration/{integrationid}',+ '/{form}/integrations/{integrationid}',[FormIntegrationsController::class, 'update']- )->name('integration.update');+ )->name('integrations.update');Route::delete(- '/{form}/integration/{integrationid}',+ '/{form}/integrations/{integrationid}',[FormIntegrationsController::class, 'destroy']- )->name('integration.destroy');+ )->name('integrations.destroy');Route::get(- '/{form}/integration/{integrationid}/events',+ '/{form}/integrations/{integrationid}/events',[FormIntegrationsEventController::class, 'index'])->name('integrations.events');});diff --git a/api/tests/Feature/Forms/FormIntegrationEventTest.php b/api/tests/Feature/Forms/FormIntegrationEventTest.phpindex c85f49acb..421c46f1e 100644--- a/api/tests/Feature/Forms/FormIntegrationEventTest.php+++ b/api/tests/Feature/Forms/FormIntegrationEventTest.php@@ -20,7 +20,7 @@ it('can fetch form integration events', function () {]];- $response = $this->postJson(route('open.forms.integration.create', $form), $data)+ $response = $this->postJson(route('open.forms.integrations.create', $form), $data)->assertSuccessful()->assertJson(['type' => 'success',diff --git a/api/tests/Feature/Forms/FormIntegrationTest.php b/api/tests/Feature/Forms/FormIntegrationTest.phpindex c805414a1..2b1b11f44 100644--- a/api/tests/Feature/Forms/FormIntegrationTest.php+++ b/api/tests/Feature/Forms/FormIntegrationTest.php@@ -20,25 +20,25 @@ it('can CRUD form integration', function () {]];- $response = $this->postJson(route('open.forms.integration.create', $form), $data)+ $response = $this->postJson(route('open.forms.integrations.create', $form), $data)->assertSuccessful()->assertJson(['type' => 'success','message' => 'Form Integration was created.']);- $this->getJson(route('open.forms.integrations', $form))+ $this->getJson(route('open.forms.integrations.index', $form))->assertSuccessful()->assertJsonCount(1);- $this->putJson(route('open.forms.integration.update', [$form, $response->json('form_integration.id')]), $data)+ $this->putJson(route('open.forms.integrations.update', [$form, $response->json('form_integration.id')]), $data)->assertSuccessful()->assertJson(['type' => 'success','message' => 'Form Integration was updated.']);- $this->deleteJson(route('open.forms.integration.destroy', [$form, $response->json('form_integration.id')]), $data)+ $this->deleteJson(route('open.forms.integrations.destroy', [$form, $response->json('form_integration.id')]), $data)->assertSuccessful()->assertJson(['type' => 'success',@@ -52,7 +52,7 @@ it('forbids non-admin users from viewing integrations and events', function () {$form = $this->createForm($owner, $workspace);// Create one integration as owner- $this->postJson(route('open.forms.integration.create', $form), [+ $this->postJson(route('open.forms.integrations.create', $form), ['status' => true,'integration_id' => 'email','logic' => null,@@ -72,7 +72,7 @@ it('forbids non-admin users from viewing integrations and events', function () {$viewer->workspaces()->sync([$workspace->id => ['role' => 'readonly']], false);$this->actingAs($viewer, 'api');- $this->getJson(route('open.forms.integrations', $form))+ $this->getJson(route('open.forms.integrations.index', $form))->assertStatus(403);// Events require an integration id; fetch as owner first@@ -132,7 +132,7 @@ it('can create form integration with checkbox logic', function () {]];- $this->postJson(route('open.forms.integration.create', $form), $data)+ $this->postJson(route('open.forms.integrations.create', $form), $data)->assertSuccessful()->assertJson(['type' => 'success',diff --git a/api/tests/Feature/Integrations/Email/EmailIntegrationTest.php b/api/tests/Feature/Integrations/Email/EmailIntegrationTest.phpindex f2cdd83ea..858dede00 100644--- a/api/tests/Feature/Integrations/Email/EmailIntegrationTest.php+++ b/api/tests/Feature/Integrations/Email/EmailIntegrationTest.php@@ -8,7 +8,7 @@ test('free user can create one email integration to their own email', function ($form = $this->createForm($user, $workspace);// First email integration should succeed with user's own email- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -24,7 +24,7 @@ test('free user can create one email integration to their own email', function (expect(FormIntegration::where('form_id', $form->id)->count())->toBe(1);// Second email integration should fail- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -49,7 +49,7 @@ test('free user cannot send to other email addresses', function () {$workspace = $this->createUserWorkspace($user);$form = $this->createForm($user, $workspace);- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -78,7 +78,7 @@ test('pro user can create multiple email integrations', function () {$form = $this->createForm($user, $workspace);// First email integration- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -93,7 +93,7 @@ test('pro user can create multiple email integrations', function () {$response->assertSuccessful();// Second email integration should also succeed for pro users- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -114,7 +114,7 @@ test('free user cannot add multiple emails', function () {$workspace = $this->createUserWorkspace($user);$form = $this->createForm($user, $workspace);- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -140,7 +140,7 @@ test('pro user can add multiple emails', function () {$workspace = $this->createUserWorkspace($user);$form = $this->createForm($user, $workspace);- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -167,7 +167,7 @@ test('free user can update their single email integration to their own email', f$form = $this->createForm($user, $workspace);// Create initial integration with user's email- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -183,7 +183,7 @@ test('free user can update their single email integration to their own email', f$integrationId = $response->json('form_integration.id');// Update the integration - still with user's email- $response = $this->putJson(route('open.forms.integration.update', [$form, $integrationId]), [+ $response = $this->putJson(route('open.forms.integrations.update', [$form, $integrationId]), ['integration_id' => 'email','status' => true,'settings' => [@@ -208,7 +208,7 @@ test('free user cannot update integration to other email addresses', function ()$form = $this->createForm($user, $workspace);// Create initial integration with user's email- $response = $this->postJson(route('open.forms.integration.create', $form), [+ $response = $this->postJson(route('open.forms.integrations.create', $form), ['integration_id' => 'email','status' => true,'settings' => [@@ -224,7 +224,7 @@ test('free user cannot update integration to other email addresses', function ()$integrationId = $response->json('form_integration.id');// Try to update to another email address - should fail- $response = $this->putJson(route('open.forms.integration.update', [$form, $integrationId]), [+ $response = $this->putJson(route('open.forms.integrations.update', [$form, $integrationId]), ['integration_id' => 'email','status' => true,'settings' => [diff --git a/api/tests/TestHelpers.php b/api/tests/TestHelpers.phpindex 68951ea54..507d4d7b3 100644--- a/api/tests/TestHelpers.php+++ b/api/tests/TestHelpers.php@@ -260,7 +260,7 @@ trait TestHelpers'settings' => $settings];- $response = $this->postJson(route('open.forms.integration.create', $formId), $data)+ $response = $this->postJson(route('open.forms.integrations.create', $formId), $data)->assertSuccessful()->assertJson(['type' => 'success',diff --git a/client/api/forms.js b/client/api/forms.jsindex 4d750c3f5..d803a87b0 100644--- a/client/api/forms.js+++ b/client/api/forms.js@@ -59,10 +59,10 @@ export const formsApi = {// Integrationsintegrations: {list: (formId, options) => apiService.get(`/open/forms/${formId}/integrations`, options),- create: (formId, data) => apiService.post(`/open/forms/${formId}/integration`, data),- update: (formId, integrationId, data) => apiService.put(`/open/forms/${formId}/integration/${integrationId}`, data),- delete: (formId, integrationId) => apiService.delete(`/open/forms/${formId}/integration/${integrationId}`),- events: (formId, integrationId, options) => apiService.get(`/open/forms/${formId}/integration/${integrationId}/events`, options)+ create: (formId, data) => apiService.post(`/open/forms/${formId}/integrations`, data),+ update: (formId, integrationId, data) => apiService.put(`/open/forms/${formId}/integrations/${integrationId}`, data),+ delete: (formId, integrationId) => apiService.delete(`/open/forms/${formId}/integrations/${integrationId}`),+ events: (formId, integrationId, options) => apiService.get(`/open/forms/${formId}/integrations/${integrationId}/events`, options)},// Zapier webhooksdiff --git a/docs/api-reference/integrations/create-webhook-integration.mdx b/docs/api-reference/integrations/create-webhook-integration.mdxnew file mode 100644index 000000000..cdd0f34ad--- /dev/null+++ b/docs/api-reference/integrations/create-webhook-integration.mdx@@ -0,0 +1,88 @@+---+openapi: post /open/forms/{form}/integrations+---++# Create Webhook Integration++Add a new webhook integration to send form submissions to an external endpoint.++## Authentication & Scope++This endpoint requires a **Personal Access Token** with the `manage-integrations` ability.++## Request++<ParamField path="form" type="number" required>+The ID of the form to which the webhook will be added.+</ParamField>++<ParamField body="integration_id" type="string" required>+Must be set to `"webhook"` for webhook integrations.+</ParamField>++<ParamField body="status" type="string">+The initial status of the webhook. Allowed values: `"active"` (default), `"inactive"`.+</ParamField>++<ParamField body="data" type="object" required>+Configuration object containing webhook details.++<Expandable title="data properties">+<ParamField body="webhook_url" type="string" required>+The URL where form submissions will be sent. Must be a valid HTTP/HTTPS URL.+</ParamField>+</Expandable>+</ParamField>++<RequestExample>+```bash cURL+curl -X POST 'https://api.opnform.com/open/forms/123/integrations' \+ -H 'Authorization: Bearer YOUR_PAT' \+ -H 'Content-Type: application/json' \+ -d '{+ "integration_id": "webhook",+ "status": "active",+ "data": {+ "webhook_url": "https://example.com/opnform-hook"+ }+ }'+```+</RequestExample>++## Response++`200 OK` – Webhook created successfully.++<ResponseExample>+```json Success+{+ "message": "Form Integration was created.",+ "form_integration": {+ "id": 42,+ "form_id": 123,+ "integration_id": "webhook",+ "status": "active",+ "data": {+ "webhook_url": "https://example.com/opnform-hook"+ }+ }+}+```+</ResponseExample>++`403 Forbidden` – The token does not have `manage-integrations` ability or insufficient form permissions.++`404 Not Found` – Form not found.++`422 Unprocessable Entity` – Validation error (e.g., invalid webhook URL).++<ResponseExample>+```json Error+{+ "message": "The webhook url must be a valid URL.",+ "errors": {+ "data.webhook_url": ["The webhook url must be a valid URL."]+ }+}+```+</ResponseExample>diff --git a/docs/api-reference/integrations/delete-webhook-integration.mdx b/docs/api-reference/integrations/delete-webhook-integration.mdxnew file mode 100644index 000000000..cb01ea3d7--- /dev/null+++ b/docs/api-reference/integrations/delete-webhook-integration.mdx@@ -0,0 +1,50 @@+---+openapi: delete /open/forms/{form}/integrations/{integrationid}+---++# Delete Webhook Integration++Remove a webhook integration from a form.++## Authentication & Scope++This endpoint requires a **Personal Access Token** with the `manage-integrations` ability.++## Request++<ParamField path="form" type="number" required>+The ID of the form containing the webhook.+</ParamField>++<ParamField path="integrationid" type="number" required>+The ID of the webhook integration to delete.+</ParamField>++```http+DELETE /open/forms/{form}/integrations/{integrationid} HTTP/1.1+Host: api.opnform.com+Authorization: Bearer <token>+```++<RequestExample>+```bash cURL+curl -X DELETE 'https://api.opnform.com/open/forms/123/integrations/42' \+ -H 'Authorization: Bearer YOUR_PAT'+```+</RequestExample>++## Response++`200 OK` – Webhook deleted successfully.++<ResponseExample>+```json Success+{+ "message": "Form Integration was deleted."+}+```+</ResponseExample>++`403 Forbidden` – The token does not have `manage-integrations` ability or insufficient form permissions.++`404 Not Found` – Form or integration not found.diff --git a/docs/api-reference/integrations/list-form-integrations.mdx b/docs/api-reference/integrations/list-form-integrations.mdxnew file mode 100644index 000000000..68ae517ec--- /dev/null+++ b/docs/api-reference/integrations/list-form-integrations.mdx@@ -0,0 +1,54 @@+---+openapi: get /open/forms/{form}/integrations+---++# List Form Integrations++Retrieve all integrations configured for a specific form.++## Authentication & Scope++This endpoint requires a **Personal Access Token** with the `manage-integrations` ability.++## Request++<ParamField path="form" type="number" required>+The ID of the form for which to list integrations.+</ParamField>++```http+GET /open/forms/{form}/integrations HTTP/1.1+Host: api.opnform.com+Authorization: Bearer <token>+```++## Response++`200 OK` – Returns an array of integration objects.++<ResponseExample>+```json Success+[+ {+ "id": 42,+ "form_id": 123,+ "integration_id": "webhook",+ "status": "active",+ "data": {+ "webhook_url": "https://example.com/opnform-hook"+ }+ },+ {+ "id": 43,+ "form_id": 123,+ "integration_id": "webhook",+ "status": "inactive",+ "data": {+ "webhook_url": "https://old-endpoint.com/hook"+ }+ }+]+```+</ResponseExample>++`403 Forbidden` – The token does not include the `manage-integrations` ability, or you don't have permission to update this form.diff --git a/docs/api-reference/integrations/list-webhook-events.mdx b/docs/api-reference/integrations/list-webhook-events.mdxnew file mode 100644index 000000000..ba168eed2--- /dev/null+++ b/docs/api-reference/integrations/list-webhook-events.mdx@@ -0,0 +1,112 @@+---+openapi: get /open/forms/{form}/integrations/{integrationid}/events+---++# List Webhook Events++Retrieve a paginated list of webhook dispatch events for a specific integration.++## Authentication & Scope++This endpoint requires a **Personal Access Token** with the `manage-integrations` ability.++## Request++<ParamField path="form" type="number" required>+The ID of the form containing the webhook.+</ParamField>++<ParamField path="integrationid" type="number" required>+The ID of the webhook integration for which to list events.+</ParamField>++```http+GET /open/forms/{form}/integrations/{integrationid}/events HTTP/1.1+Host: api.opnform.com+Authorization: Bearer <token>+```++<RequestExample>+```bash cURL+curl -X GET 'https://api.opnform.com/open/forms/123/integrations/42/events' \+ -H 'Authorization: Bearer YOUR_PAT'+```+</RequestExample>++## Response++`200 OK` – Returns an array of event objects, ordered by creation date (newest first).++<ResponseExample>+```json Success+[+ {+ "id": 1001,+ "integration_id": 42,+ "event": "submission.created",+ "status": "success",+ "response_code": 200,+ "created_at": "2024-01-15T10:30:00Z"+ },+ {+ "id": 1000,+ "integration_id": 42,+ "event": "submission.created",+ "status": "failed",+ "response_code": 500,+ "error_message": "Internal Server Error",+ "created_at": "2024-01-15T10:25:00Z"+ },+ {+ "id": 999,+ "integration_id": 42,+ "event": "submission.created",+ "status": "success",+ "response_code": 200,+ "created_at": "2024-01-15T10:20:00Z"+ }+]+```+</ResponseExample>++## Event object properties++<ResponseField name="id" type="number">+Unique identifier for the event record.+</ResponseField>++<ResponseField name="integration_id" type="number">+The ID of the webhook integration that generated this event.+</ResponseField>++<ResponseField name="event" type="string">+The type of event. Currently: `"submission.created"`.+</ResponseField>++<ResponseField name="status" type="string">+Result of the webhook dispatch. Values: `"success"`, `"failed"`, `"timeout"`.+</ResponseField>++<ResponseField name="response_code" type="number | null">+HTTP status code returned by your webhook endpoint (if applicable).+</ResponseField>++<ResponseField name="error_message" type="string | null">+Error details if the webhook dispatch failed.+</ResponseField>++<ResponseField name="created_at" type="string">+ISO 8601 timestamp of when the webhook was dispatched.+</ResponseField>++## Error responses++`403 Forbidden` – The token does not have `manage-integrations` ability or insufficient form permissions.++`404 Not Found` – Form or integration not found.++## Use cases++- **Debugging**: Check recent events to verify your webhook is receiving requests.+- **Monitoring**: Track success/failure rates to identify reliability issues.+- **Audit trail**: Review when submissions were sent to your endpoint.diff --git a/docs/api-reference/integrations/update-webhook-integration.mdx b/docs/api-reference/integrations/update-webhook-integration.mdxnew file mode 100644index 000000000..383af38b4--- /dev/null+++ b/docs/api-reference/integrations/update-webhook-integration.mdx@@ -0,0 +1,92 @@+---+openapi: put /open/forms/{form}/integrations/{integrationid}+---++# Update Webhook Integration++Modify an existing webhook integration's URL or status.++## Authentication & Scope++This endpoint requires a **Personal Access Token** with the `manage-integrations` ability.++## Request++<ParamField path="form" type="number" required>+The ID of the form containing the webhook.+</ParamField>++<ParamField path="integrationid" type="number" required>+The ID of the webhook integration to update.+</ParamField>++<ParamField body="integration_id" type="string" required>+Must be set to `"webhook"`.+</ParamField>++<ParamField body="status" type="string">+The status of the webhook. Allowed values: `"active"`, `"inactive"`.+</ParamField>++<ParamField body="data" type="object" required>+Configuration object containing webhook details.++<Expandable title="data properties">+<ParamField body="webhook_url" type="string">+The updated URL where form submissions will be sent. Must be a valid HTTP/HTTPS URL.+</ParamField>+</Expandable>+</ParamField>++<RequestExample>+```bash cURL+curl -X PUT 'https://api.opnform.com/open/forms/123/integrations/42' \+ -H 'Authorization: Bearer YOUR_PAT' \+ -H 'Content-Type: application/json' \+ -d '{+ "integration_id": "webhook",+ "status": "active",+ "data": {+ "webhook_url": "https://new-endpoint.com/opnform-hook"+ }+ }'+```+</RequestExample>++## Response++`200 OK` – Webhook updated successfully.++<ResponseExample>+```json Success+{+ "message": "Form Integration was updated.",+ "form_integration": {+ "id": 42,+ "form_id": 123,+ "integration_id": "webhook",+ "status": "active",+ "data": {+ "webhook_url": "https://new-endpoint.com/opnform-hook"+ }+ }+}+```+</ResponseExample>++`403 Forbidden` – The token does not have `manage-integrations` ability or insufficient form permissions.++`404 Not Found` – Form or integration not found.++`422 Unprocessable Entity` – Validation error.++<ResponseExample>+```json Error+{+ "message": "The webhook url must be a valid URL.",+ "errors": {+ "data.webhook_url": ["The webhook url must be a valid URL."]+ }+}+```+</ResponseExample>diff --git a/docs/api-reference/openapi.yaml b/docs/api-reference/openapi.yamlindex 3ebe31023..95151a724 100644--- a/docs/api-reference/openapi.yaml+++ b/docs/api-reference/openapi.yaml@@ -16,6 +16,8 @@ tags:description: Manage and retrieve forms.- name: Submissionsdescription: Access and manage form submissions.+ - name: Integrations+ description: Manage form integrations (webhooks) via API.- name: Zapierdescription: Legacy endpoints for the Zapier integration.paths:@@ -777,6 +779,231 @@ paths:example: Record successfully removed."403":description: "Forbidden – token lacks forms-write ability"+ "/open/forms/{form}/integrations":+ get:+ tags:+ - Integrations+ summary: List Form Integrations+ description: "List all integrations configured for a form. Requires `manage-integrations` ability."+ security:+ - bearerAuth: []+ parameters:+ - name: form+ in: path+ required: true+ schema:+ type: number+ description: The ID of the form.+ responses:+ "200":+ description: Successful+ content:+ application/json:+ schema:+ type: array+ items:+ $ref: "#/components/schemas/FormIntegration"+ "403":+ description: Forbidden – token lacks manage-integrations ability+ "404":+ description: Form not found+ post:+ tags:+ - Integrations+ summary: Create Webhook Integration+ description: "Create a new webhook integration for a form. Requires `manage-integrations` ability."+ security:+ - bearerAuth: []+ parameters:+ - name: form+ in: path+ required: true+ schema:+ type: number+ description: The ID of the form.+ requestBody:+ required: true+ content:+ application/json:+ schema:+ type: object+ required:+ - integration_id+ - data+ properties:+ integration_id:+ type: string+ enum: [webhook]+ description: Must be "webhook"+ status:+ type: string+ enum: [active, inactive]+ default: active+ description: The initial status of the webhook+ data:+ type: object+ required:+ - webhook_url+ properties:+ webhook_url:+ type: string+ format: uri+ description: The URL where submissions will be sent+ responses:+ "200":+ description: Webhook created successfully+ content:+ application/json:+ schema:+ type: object+ properties:+ message:+ type: string+ example: "Form Integration was created."+ form_integration:+ $ref: "#/components/schemas/FormIntegration"+ "403":+ description: Forbidden – insufficient permissions+ "404":+ description: Form not found+ "422":+ description: Validation error+ "/open/forms/{form}/integrations/{integrationid}":+ put:+ tags:+ - Integrations+ summary: Update Webhook Integration+ description: "Update an existing webhook integration. Requires `manage-integrations` ability."+ security:+ - bearerAuth: []+ parameters:+ - name: form+ in: path+ required: true+ schema:+ type: number+ description: The ID of the form.+ - name: integrationid+ in: path+ required: true+ schema:+ type: number+ description: The ID of the integration.+ requestBody:+ required: true+ content:+ application/json:+ schema:+ type: object+ required:+ - integration_id+ - data+ properties:+ integration_id:+ type: string+ enum: [webhook]+ description: Must be "webhook"+ status:+ type: string+ enum: [active, inactive]+ description: The status of the webhook+ data:+ type: object+ required:+ - webhook_url+ properties:+ webhook_url:+ type: string+ format: uri+ description: The URL where submissions will be sent+ responses:+ "200":+ description: Webhook updated successfully+ content:+ application/json:+ schema:+ type: object+ properties:+ message:+ type: string+ example: "Form Integration was updated."+ form_integration:+ $ref: "#/components/schemas/FormIntegration"+ "403":+ description: Forbidden – insufficient permissions+ "404":+ description: Form or integration not found+ "422":+ description: Validation error+ delete:+ tags:+ - Integrations+ summary: Delete Webhook Integration+ description: "Delete a webhook integration. Requires `manage-integrations` ability."+ security:+ - bearerAuth: []+ parameters:+ - name: form+ in: path+ required: true+ schema:+ type: number+ description: The ID of the form.+ - name: integrationid+ in: path+ required: true+ schema:+ type: number+ description: The ID of the integration.+ responses:+ "200":+ description: Webhook deleted successfully+ content:+ application/json:+ schema:+ type: object+ properties:+ message:+ type: string+ example: "Form Integration was deleted."+ "403":+ description: Forbidden – insufficient permissions+ "404":+ description: Form or integration not found+ "/open/forms/{form}/integrations/{integrationid}/events":+ get:+ tags:+ - Integrations+ summary: List Webhook Events+ description: "List past webhook dispatch events for an integration. Requires `manage-integrations` ability."+ security:+ - bearerAuth: []+ parameters:+ - name: form+ in: path+ required: true+ schema:+ type: number+ description: The ID of the form.+ - name: integrationid+ in: path+ required: true+ schema:+ type: number+ description: The ID of the integration.+ responses:+ "200":+ description: Successful+ content:+ application/json:+ schema:+ type: array+ items:+ $ref: "#/components/schemas/IntegrationEvent"+ "403":+ description: Forbidden – insufficient permissions+ "404":+ description: Form or integration not found"/external/zapier/validate":get:tags:@@ -1201,6 +1428,62 @@ components:type: stringformat: date-timedescription: "Last update timestamp"+ FormIntegration:+ type: object+ properties:+ id:+ type: number+ description: Unique identifier for the integration.+ readOnly: true+ form_id:+ type: number+ description: The ID of the associated form.+ readOnly: true+ integration_id:+ type: string+ description: Type of integration (currently only "webhook" is exposed via API).+ example: "webhook"+ status:+ type: string+ enum: [active, inactive]+ description: Whether the integration is active.+ data:+ type: object+ description: Integration-specific configuration. For webhooks, contains webhook_url.+ example:+ webhook_url: "https://example.com/opnform-hook"+ IntegrationEvent:+ type: object+ properties:+ id:+ type: number+ description: Unique identifier for the event record.+ readOnly: true+ integration_id:+ type: number+ description: The ID of the webhook integration that generated this event.+ readOnly: true+ event:+ type: string+ description: The type of event.+ example: "submission.created"+ status:+ type: string+ enum: [success, failed, timeout]+ description: Result of the webhook dispatch.+ response_code:+ type: number+ nullable: true+ description: HTTP status code returned by the webhook endpoint.+ error_message:+ type: string+ nullable: true+ description: Error details if the webhook dispatch failed.+ created_at:+ type: string+ format: date-time+ description: ISO 8601 timestamp of when the webhook was dispatched.+ readOnly: truesecuritySchemes:bearerAuth:type: http@@ -1214,3 +1497,4 @@ components:"workspace-users-write": "Write access to workspace users""forms-read": "Read access to forms""forms-write": "Write access to forms"+ "manage-integrations": "Manage form integrations (webhooks)"diff --git a/docs/docs.json b/docs/docs.jsonindex fb1e825b6..679ce9b8f 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -96,6 +96,16 @@"api-reference/submissions/delete-submission"]},+ {+ "group": "Integrations",+ "pages": [+ "api-reference/integrations/list-form-integrations",+ "api-reference/integrations/create-webhook-integration",+ "api-reference/integrations/update-webhook-integration",+ "api-reference/integrations/delete-webhook-integration",+ "api-reference/integrations/list-webhook-events"+ ]+ },{"group": "Zapier","pages": [