How to Receive DiscoverSnoop Alerts Programmatically in JSON

If you want to receive alerts in a computer-readable format to integrate them into your own system (e.g., displaying the alerts in your CMS, sending them through your internal communication systems, etc.), you can use the "JSON push" notification channel. This channel sends the alert, formatted in JSON, directly to your endpoint.

To set up "JSON push" alerts, follow these steps:

1. Create Your Endpoint:
Use your preferred programming language to create an endpoint that is accessible over the internet via HTTPS (preferred) or HTTP. Your endpoint must return a 200 HTTP response code after receiving the content; otherwise, the alert will continue to be sent until a 200 response is received.

Example: PHP Endpoint
   <?php
   http_response_code(200); // Send a 200 HTTP response code to confirm receipt of the alert. Otherwise, the alert will keep being sent until a 200 response is received.
   $payload = file_get_contents('php://input');
   $alert = json_decode($payload, TRUE);
   
   echo "Customer email: " . $alert['Customer_email'] . "\n";
   echo "Customer Firstname: " . $alert['Customer_FirstName'] . "\n";
   echo "Customer Lastname: " . $alert['Customer_LastName'] . "\n";
   echo "Alert name: " . $alert['Alert_Name'] . "\n";
   echo "Alert ID: " . $alert['Alert_ID'] . "\n";
   echo "Element URL: " . $alert['Element_URL'] . "\n";
   echo "Element Image: " . $alert['Element_Image'] . "\n";
   echo "Element Title: " . $alert['Element_Title'] . "\n";
   echo "Element Headline: " . $alert['Element_Headline'] . "\n";

2. Configure Your Alerts in DiscoverSnoop:
Go to the alerts section in your DiscoverSnoop dashboard. Either edit an existing alert or create a new one. In the "Notification channel" section, select "JSON push" and input the endpoint URL you created in step 1.

Alternatively, if you are using our API, you can edit or create the alert using the `AlertsChangeGet` method (https://www.discoversnoop.com/api/docs/#api-Alerts-alertsChangeGet) and set the `channel` variable to 4. Enter the endpoint URL in the `recipient` variable.