{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Send Notification","description":"Developer documentation for the WHMCS API — the","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"send-notification","__idx":0},"children":["Send Notification"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sendNotification"]}," method is responsible for delivering a notification to the end user."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This method will be called by WHMCS when a notification rule is triggered and all conditions for it are met."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this method, you should craft an appropriately formatted message and transmit it to the messaging service."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The method receives 3 input arguments:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["$notification"]}," - A notification to send. This will be an instance of the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.whmcs.com/classes/7.4/WHMCS/Notification/Contracts/NotificationInterface.html"},"children":["NotificationInterface"]}," class."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["$moduleSettings"]}," - An array containing all the provider settings defined for your notification module in the Provider Settings method."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["$notificationSettings"]}," - An array containing all the notification settings defined for the currently triggered notification rule."]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"public function sendNotification(NotificationInterface $notification, $moduleSettings, $notificationSettings)\n{\n    $api_username = $moduleSettings['api_username'];\n    $api_password = $moduleSettings['api_password'];\n\n    $priority = $notificationSettings['priority'];\n    $channel = $notificationSettings['channel'];\n\n    // Build API Request to remote service\n\n    $postData = [\n        'username' => $api_username,\n        'password' => $api_password,\n        'priority' => $priority,\n        'channel' => $channel,\n        'title' => $notification->getTitle(),\n        'message' => $notification->getMessage(),\n        'url' => $notification->getUrl(),\n        'attributes' => [],\n    ];\n\n    // Attributes vary depending on the event trigger. Loop through as necessary.\n    foreach ($notification->getAttributes() as $attribute) {\n        $postData['attributes'][] = [\n            'label' => $attribute->getLabel(),\n            'value' => $attribute->getValue(),\n            'url' => $attribute->getUrl(),\n            'style' => $attribute->getStyle(),\n            'icon' => $attribute->getIcon(),\n        ];\n    }\n\n    // Call the remote API\n    $response = file_get_contents('https://www.example.com/?' . http_build_query($postData));\n\n    if (!$response) {\n        // Throw a human friendly exception on error\n        throw new Exception('No response received from API');\n    }\n}\n"},"children":[]}]},"headings":[{"value":"Send Notification","id":"send-notification","depth":1}],"frontmatter":{"title":"Send Notification","seo":{"title":"Send Notification"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/notification-providers/send-notification","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}