authorizeCurrentWorkspace( $request, 'manageWebhooks', 'Not authorized to manage webhooks.', ); if (! $workspace instanceof Workspace) { return $workspace; } $validated = $request->validate(WebhookIdRequest::rules()); $webhook = $this->webhookInWorkspace($workspace, data_get($validated, 'webhook_id')); if (! $webhook instanceof Webhook) { return $webhook; } try { SendWebhookTest::execute($webhook, $this->webhooks); } catch (RuntimeException $e) { return Response::error($e->getMessage()); } return Response::structured(['tested' => true]); } /** * @return array */ public function schema(JsonSchema $schema): array { return [ 'webhook_id' => $schema->string()->required()->description('The webhook ID to ping.'), ]; } }