authorizeCurrentWorkspace( $request, 'manageWebhooks', 'Not authorized to manage webhooks.', ); if (! $workspace instanceof Workspace) { return $workspace; } $validated = $request->validate(ListWebhookLogsRequest::rules()); $webhook = $this->webhookInWorkspace($workspace, data_get($validated, 'webhook_id')); if (! $webhook instanceof Webhook) { return $webhook; } $logs = $webhook->logs() ->orderByDesc('created_at') ->limit((int) data_get($validated, 'limit', 50)) ->get(); return Response::structured([ 'logs' => WebhookLogResource::collection($logs)->resolve(), ]); } /** * @return array */ public function schema(JsonSchema $schema): array { return [ 'webhook_id' => $schema->string()->required()->description('The webhook ID.'), 'limit' => $schema->integer()->description('Max results (1-100, default 50).'), ]; } }