authorizeCurrentWorkspace( $request, 'manageWebhooks', 'Not authorized to manage webhooks.', ); if (! $workspace instanceof Workspace) { return $workspace; } $validated = $request->validate(CreateWebhookRequest::rules()); try { $webhook = CreateWebhook::execute($workspace, $validated, $this->webhooks); } catch (RuntimeException $e) { return Response::error($e->getMessage()); } return Response::structured( (new WebhookResource($webhook->makeVisible('signing_secret')))->resolve(), ); } /** * @return array */ public function schema(JsonSchema $schema): array { return [ 'endpoint' => $schema->string()->required()->description('Public URL that will receive signed webhook payloads. Private or local addresses are rejected.'), 'events' => $schema->array() ->items($schema->string()->enum(array_column(EventType::cases(), 'value'))) ->required() ->description('At least one event to subscribe to: post.created, post.scheduled, post.unscheduled, post.published, post.partially_published, post.failed, post.deleted.'), ]; } }