An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat: add UUIDs and URLs to webhook notifications
Andras Bacsai0303f529d310
diff --git a/app/Notifications/Application/DeploymentFailed.php b/app/Notifications/Application/DeploymentFailed.phpindex dec361e782..8fff7f03bb 100644--- a/app/Notifications/Application/DeploymentFailed.php+++ b/app/Notifications/Application/DeploymentFailed.php@@ -185,4 +185,30 @@ class DeploymentFailed extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ $data = [+ 'success' => false,+ 'message' => 'Deployment failed',+ 'event' => 'deployment_failed',+ 'application_name' => $this->application_name,+ 'application_uuid' => $this->application->uuid,+ 'deployment_uuid' => $this->deployment_uuid,+ 'deployment_url' => $this->deployment_url,+ 'project' => data_get($this->application, 'environment.project.name'),+ 'environment' => $this->environment_name,+ ];++ if ($this->preview) {+ $data['pull_request_id'] = $this->preview->pull_request_id;+ $data['preview_fqdn'] = $this->preview->fqdn;+ }++ if ($this->fqdn) {+ $data['fqdn'] = $this->fqdn;+ }++ return $data;+ }}diff --git a/app/Notifications/Application/DeploymentSuccess.php b/app/Notifications/Application/DeploymentSuccess.phpindex 9b59d9162a..415df5831d 100644--- a/app/Notifications/Application/DeploymentSuccess.php+++ b/app/Notifications/Application/DeploymentSuccess.php@@ -205,4 +205,30 @@ class DeploymentSuccess extends CustomEmailNotificationcolor: SlackMessage::successColor());}++ public function toWebhook(): array+ {+ $data = [+ 'success' => true,+ 'message' => 'New version successfully deployed',+ 'event' => 'deployment_success',+ 'application_name' => $this->application_name,+ 'application_uuid' => $this->application->uuid,+ 'deployment_uuid' => $this->deployment_uuid,+ 'deployment_url' => $this->deployment_url,+ 'project' => data_get($this->application, 'environment.project.name'),+ 'environment' => $this->environment_name,+ ];++ if ($this->preview) {+ $data['pull_request_id'] = $this->preview->pull_request_id;+ $data['preview_fqdn'] = $this->preview->fqdn;+ }++ if ($this->fqdn) {+ $data['fqdn'] = $this->fqdn;+ }++ return $data;+ }}diff --git a/app/Notifications/Application/StatusChanged.php b/app/Notifications/Application/StatusChanged.phpindex fab5487ef4..ef61b7e6a5 100644--- a/app/Notifications/Application/StatusChanged.php+++ b/app/Notifications/Application/StatusChanged.php@@ -113,4 +113,19 @@ class StatusChanged extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ return [+ 'success' => false,+ 'message' => 'Application stopped',+ 'event' => 'status_changed',+ 'application_name' => $this->resource_name,+ 'application_uuid' => $this->resource->uuid,+ 'url' => $this->resource_url,+ 'project' => data_get($this->resource, 'environment.project.name'),+ 'environment' => $this->environment_name,+ 'fqdn' => $this->fqdn,+ ];+ }}diff --git a/app/Notifications/Container/ContainerRestarted.php b/app/Notifications/Container/ContainerRestarted.phpindex f6ae694819..2d7eb58b50 100644--- a/app/Notifications/Container/ContainerRestarted.php+++ b/app/Notifications/Container/ContainerRestarted.php@@ -102,4 +102,22 @@ class ContainerRestarted extends CustomEmailNotificationcolor: SlackMessage::warningColor());}++ public function toWebhook(): array+ {+ $data = [+ 'success' => true,+ 'message' => 'Resource restarted automatically',+ 'event' => 'container_restarted',+ 'container_name' => $this->name,+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ ];++ if ($this->url) {+ $data['url'] = $this->url;+ }++ return $data;+ }}diff --git a/app/Notifications/Container/ContainerStopped.php b/app/Notifications/Container/ContainerStopped.phpindex fc9410a851..f518cd2fdd 100644--- a/app/Notifications/Container/ContainerStopped.php+++ b/app/Notifications/Container/ContainerStopped.php@@ -102,4 +102,22 @@ class ContainerStopped extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ $data = [+ 'success' => false,+ 'message' => 'Resource stopped unexpectedly',+ 'event' => 'container_stopped',+ 'container_name' => $this->name,+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ ];++ if ($this->url) {+ $data['url'] = $this->url;+ }++ return $data;+ }}diff --git a/app/Notifications/Database/BackupFailed.php b/app/Notifications/Database/BackupFailed.phpindex a19fb04317..c2b21b1d51 100644--- a/app/Notifications/Database/BackupFailed.php+++ b/app/Notifications/Database/BackupFailed.php@@ -88,4 +88,21 @@ class BackupFailed extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ $url = base_url().'/project/'.data_get($this->database, 'environment.project.uuid').'/environment/'.data_get($this->database, 'environment.uuid').'/database/'.$this->database->uuid;++ return [+ 'success' => false,+ 'message' => 'Database backup failed',+ 'event' => 'backup_failed',+ 'database_name' => $this->name,+ 'database_uuid' => $this->database->uuid,+ 'database_type' => $this->database_name,+ 'frequency' => $this->frequency,+ 'error_output' => $this->output,+ 'url' => $url,+ ];+ }}diff --git a/app/Notifications/Database/BackupSuccess.php b/app/Notifications/Database/BackupSuccess.phpindex 78bcfafe35..3d2d8ece3b 100644--- a/app/Notifications/Database/BackupSuccess.php+++ b/app/Notifications/Database/BackupSuccess.php@@ -85,4 +85,20 @@ class BackupSuccess extends CustomEmailNotificationcolor: SlackMessage::successColor());}++ public function toWebhook(): array+ {+ $url = base_url().'/project/'.data_get($this->database, 'environment.project.uuid').'/environment/'.data_get($this->database, 'environment.uuid').'/database/'.$this->database->uuid;++ return [+ 'success' => true,+ 'message' => 'Database backup successful',+ 'event' => 'backup_success',+ 'database_name' => $this->name,+ 'database_uuid' => $this->database->uuid,+ 'database_type' => $this->database_name,+ 'frequency' => $this->frequency,+ 'url' => $url,+ ];+ }}diff --git a/app/Notifications/Database/BackupSuccessWithS3Warning.php b/app/Notifications/Database/BackupSuccessWithS3Warning.phpindex 75ae2824cd..ee24ef17de 100644--- a/app/Notifications/Database/BackupSuccessWithS3Warning.php+++ b/app/Notifications/Database/BackupSuccessWithS3Warning.php@@ -113,4 +113,27 @@ class BackupSuccessWithS3Warning extends CustomEmailNotificationcolor: SlackMessage::warningColor());}++ public function toWebhook(): array+ {+ $url = base_url().'/project/'.data_get($this->database, 'environment.project.uuid').'/environment/'.data_get($this->database, 'environment.uuid').'/database/'.$this->database->uuid;++ $data = [+ 'success' => true,+ 'message' => 'Database backup succeeded locally, S3 upload failed',+ 'event' => 'backup_success_with_s3_warning',+ 'database_name' => $this->name,+ 'database_uuid' => $this->database->uuid,+ 'database_type' => $this->database_name,+ 'frequency' => $this->frequency,+ 's3_error' => $this->s3_error,+ 'url' => $url,+ ];++ if ($this->s3_storage_url) {+ $data['s3_storage_url'] = $this->s3_storage_url;+ }++ return $data;+ }}diff --git a/app/Notifications/ScheduledTask/TaskFailed.php b/app/Notifications/ScheduledTask/TaskFailed.phpindex eb4fc7e79f..bd060112ae 100644--- a/app/Notifications/ScheduledTask/TaskFailed.php+++ b/app/Notifications/ScheduledTask/TaskFailed.php@@ -114,4 +114,28 @@ class TaskFailed extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ $data = [+ 'success' => false,+ 'message' => 'Scheduled task failed',+ 'event' => 'task_failed',+ 'task_name' => $this->task->name,+ 'task_uuid' => $this->task->uuid,+ 'output' => $this->output,+ ];++ if ($this->task->application) {+ $data['application_uuid'] = $this->task->application->uuid;+ } elseif ($this->task->service) {+ $data['service_uuid'] = $this->task->service->uuid;+ }++ if ($this->url) {+ $data['url'] = $this->url;+ }++ return $data;+ }}diff --git a/app/Notifications/ScheduledTask/TaskSuccess.php b/app/Notifications/ScheduledTask/TaskSuccess.phpindex c45784db24..58c959bd8d 100644--- a/app/Notifications/ScheduledTask/TaskSuccess.php+++ b/app/Notifications/ScheduledTask/TaskSuccess.php@@ -105,4 +105,28 @@ class TaskSuccess extends CustomEmailNotificationcolor: SlackMessage::successColor());}++ public function toWebhook(): array+ {+ $data = [+ 'success' => true,+ 'message' => 'Scheduled task succeeded',+ 'event' => 'task_success',+ 'task_name' => $this->task->name,+ 'task_uuid' => $this->task->uuid,+ 'output' => $this->output,+ ];++ if ($this->task->application) {+ $data['application_uuid'] = $this->task->application->uuid;+ } elseif ($this->task->service) {+ $data['service_uuid'] = $this->task->service->uuid;+ }++ if ($this->url) {+ $data['url'] = $this->url;+ }++ return $data;+ }}diff --git a/app/Notifications/Server/DockerCleanupFailed.php b/app/Notifications/Server/DockerCleanupFailed.phpindex 0291eed19d..9cbdeb4888 100644--- a/app/Notifications/Server/DockerCleanupFailed.php+++ b/app/Notifications/Server/DockerCleanupFailed.php@@ -66,4 +66,19 @@ class DockerCleanupFailed extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ $url = base_url().'/server/'.$this->server->uuid;++ return [+ 'success' => false,+ 'message' => 'Docker cleanup job failed',+ 'event' => 'docker_cleanup_failed',+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ 'error_message' => $this->message,+ 'url' => $url,+ ];+ }}diff --git a/app/Notifications/Server/DockerCleanupSuccess.php b/app/Notifications/Server/DockerCleanupSuccess.phpindex 1a652d1890..d28f25c6c8 100644--- a/app/Notifications/Server/DockerCleanupSuccess.php+++ b/app/Notifications/Server/DockerCleanupSuccess.php@@ -66,4 +66,19 @@ class DockerCleanupSuccess extends CustomEmailNotificationcolor: SlackMessage::successColor());}++ public function toWebhook(): array+ {+ $url = base_url().'/server/'.$this->server->uuid;++ return [+ 'success' => true,+ 'message' => 'Docker cleanup job succeeded',+ 'event' => 'docker_cleanup_success',+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ 'cleanup_message' => $this->message,+ 'url' => $url,+ ];+ }}diff --git a/app/Notifications/Server/HighDiskUsage.php b/app/Notifications/Server/HighDiskUsage.phpindex 983e6d81e7..149d1bbc86 100644--- a/app/Notifications/Server/HighDiskUsage.php+++ b/app/Notifications/Server/HighDiskUsage.php@@ -88,4 +88,18 @@ class HighDiskUsage extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ return [+ 'success' => false,+ 'message' => 'High disk usage detected',+ 'event' => 'high_disk_usage',+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ 'disk_usage' => $this->disk_usage,+ 'threshold' => $this->server_disk_usage_notification_threshold,+ 'url' => base_url().'/server/'.$this->server->uuid,+ ];+ }}diff --git a/app/Notifications/Server/Reachable.php b/app/Notifications/Server/Reachable.phpindex e03aef6b79..e64b0af2ac 100644--- a/app/Notifications/Server/Reachable.php+++ b/app/Notifications/Server/Reachable.php@@ -74,4 +74,18 @@ class Reachable extends CustomEmailNotificationcolor: SlackMessage::successColor());}++ public function toWebhook(): array+ {+ $url = base_url().'/server/'.$this->server->uuid;++ return [+ 'success' => true,+ 'message' => 'Server revived',+ 'event' => 'server_reachable',+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ 'url' => $url,+ ];+ }}diff --git a/app/Notifications/Server/ServerPatchCheck.php b/app/Notifications/Server/ServerPatchCheck.phpindex 1686a6f37c..4d3053569b 100644--- a/app/Notifications/Server/ServerPatchCheck.php+++ b/app/Notifications/Server/ServerPatchCheck.php@@ -345,4 +345,47 @@ class ServerPatchCheck extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ // Handle error case+ if (isset($this->patchData['error'])) {+ return [+ 'success' => false,+ 'message' => 'Failed to check patches',+ 'event' => 'server_patch_check_error',+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ 'os_id' => $this->patchData['osId'] ?? 'unknown',+ 'package_manager' => $this->patchData['package_manager'] ?? 'unknown',+ 'error' => $this->patchData['error'],+ 'url' => $this->serverUrl,+ ];+ }++ $totalUpdates = $this->patchData['total_updates'] ?? 0;+ $updates = $this->patchData['updates'] ?? [];++ // Check for critical packages+ $criticalPackages = collect($updates)->filter(function ($update) {+ return str_contains(strtolower($update['package']), 'docker') ||+ str_contains(strtolower($update['package']), 'kernel') ||+ str_contains(strtolower($update['package']), 'openssh') ||+ str_contains(strtolower($update['package']), 'ssl');+ });++ return [+ 'success' => false,+ 'message' => 'Server patches available',+ 'event' => 'server_patch_check',+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ 'total_updates' => $totalUpdates,+ 'os_id' => $this->patchData['osId'] ?? 'unknown',+ 'package_manager' => $this->patchData['package_manager'] ?? 'unknown',+ 'updates' => $updates,+ 'critical_packages_count' => $criticalPackages->count(),+ 'url' => $this->serverUrl,+ ];+ }}diff --git a/app/Notifications/Server/Unreachable.php b/app/Notifications/Server/Unreachable.phpindex fe90cc6105..99742f3b73 100644--- a/app/Notifications/Server/Unreachable.php+++ b/app/Notifications/Server/Unreachable.php@@ -82,4 +82,18 @@ class Unreachable extends CustomEmailNotificationcolor: SlackMessage::errorColor());}++ public function toWebhook(): array+ {+ $url = base_url().'/server/'.$this->server->uuid;++ return [+ 'success' => false,+ 'message' => 'Server unreachable',+ 'event' => 'server_unreachable',+ 'server_name' => $this->server->name,+ 'server_uuid' => $this->server->uuid,+ 'url' => $url,+ ];+ }}diff --git a/resources/views/livewire/notifications/webhook.blade.php b/resources/views/livewire/notifications/webhook.blade.phpindex 29391a7551..4646aaccd8 100644--- a/resources/views/livewire/notifications/webhook.blade.php+++ b/resources/views/livewire/notifications/webhook.blade.php@@ -10,24 +10,27 @@Save</x-forms.button>@if ($webhookEnabled)- <x-forms.button canGate="sendTest" :canResource="$settings" class="normal-case dark:text-white btn btn-xs no-animation btn-primary"+ <x-forms.button canGate="sendTest" :canResource="$settings"+ class="normal-case dark:text-white btn btn-xs no-animation btn-primary"wire:click="sendTestNotification">Send Test Notification</x-forms.button>@else- <x-forms.button canGate="sendTest" :canResource="$settings" disabled class="normal-case dark:text-white btn btn-xs no-animation btn-primary">+ <x-forms.button canGate="sendTest" :canResource="$settings" disabled+ class="normal-case dark:text-white btn btn-xs no-animation btn-primary">Send Test Notification</x-forms.button>@endif</div><div class="w-48">- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="instantSaveWebhookEnabled" id="webhookEnabled" label="Enabled" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="instantSaveWebhookEnabled"+ id="webhookEnabled" label="Enabled" /></div><div class="flex items-end gap-2">- <span class="px-3 py-2 text-sm font-mono font-semibold rounded btn btn-sm btn-primary no-animation">POST</span>+<x-forms.input canGate="update" :canResource="$settings" type="password"helper="Enter a valid HTTP or HTTPS URL. Coolify will send POST requests to this endpoint when events occur."- required id="webhookUrl" label="Webhook URL" />+ required id="webhookUrl" label="Webhook URL (POST)" /></div></form><h2 class="mt-4">Notification Settings</h2>@@ -38,10 +41,10 @@<div class="border dark:border-coolgray-300 border-neutral-200 p-4 rounded-lg"><h3 class="font-medium mb-3">Deployments</h3><div class="flex flex-col gap-1.5 pl-1">- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="deploymentSuccessWebhookNotifications"- label="Deployment Success" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="deploymentFailureWebhookNotifications"- label="Deployment Failure" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="deploymentSuccessWebhookNotifications" label="Deployment Success" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="deploymentFailureWebhookNotifications" label="Deployment Failure" /><x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"helper="Send a notification when a container status changes. It will notify for Stopped and Restarted events of a container."id="statusChangeWebhookNotifications" label="Container Status Changes" />@@ -50,36 +53,36 @@<div class="border dark:border-coolgray-300 border-neutral-200 p-4 rounded-lg"><h3 class="font-medium mb-3">Backups</h3><div class="flex flex-col gap-1.5 pl-1">- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="backupSuccessWebhookNotifications"- label="Backup Success" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="backupFailureWebhookNotifications"- label="Backup Failure" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="backupSuccessWebhookNotifications" label="Backup Success" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="backupFailureWebhookNotifications" label="Backup Failure" /></div></div><div class="border dark:border-coolgray-300 border-neutral-200 p-4 rounded-lg"><h3 class="font-medium mb-3">Scheduled Tasks</h3><div class="flex flex-col gap-1.5 pl-1">- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="scheduledTaskSuccessWebhookNotifications"- label="Scheduled Task Success" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="scheduledTaskFailureWebhookNotifications"- label="Scheduled Task Failure" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="scheduledTaskSuccessWebhookNotifications" label="Scheduled Task Success" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="scheduledTaskFailureWebhookNotifications" label="Scheduled Task Failure" /></div></div><div class="border dark:border-coolgray-300 border-neutral-200 p-4 rounded-lg"><h3 class="font-medium mb-3">Server</h3><div class="flex flex-col gap-1.5 pl-1">- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="dockerCleanupSuccessWebhookNotifications"- label="Docker Cleanup Success" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="dockerCleanupFailureWebhookNotifications"- label="Docker Cleanup Failure" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="serverDiskUsageWebhookNotifications"- label="Server Disk Usage" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="serverReachableWebhookNotifications"- label="Server Reachable" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="serverUnreachableWebhookNotifications"- label="Server Unreachable" />- <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel" id="serverPatchWebhookNotifications"- label="Server Patching" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="dockerCleanupSuccessWebhookNotifications" label="Docker Cleanup Success" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="dockerCleanupFailureWebhookNotifications" label="Docker Cleanup Failure" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="serverDiskUsageWebhookNotifications" label="Server Disk Usage" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="serverReachableWebhookNotifications" label="Server Reachable" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="serverUnreachableWebhookNotifications" label="Server Unreachable" />+ <x-forms.checkbox canGate="update" :canResource="$settings" instantSave="saveModel"+ id="serverPatchWebhookNotifications" label="Server Patching" /></div></div></div>