Contents
On this page

Test Alert Rule - Plugixa Activity Log

POST /plugixa-activity-log/v1/rules/{id}/test

Send one sample alert to every channel of a rule, now, and report what each channel answered.

Needs settings access (see who can call what). Needs Plugixa Activity Log Pro, with the Alert rules module on under Plugixa Activity Log -> Monitors.

Note. A failed delivery is not an HTTP error. The request answers 200 whatever happens, and each channel’s result says whether it got through: check ok on every item. The test is sent even when the rule is disabled, and ignores its conditions and throttle.

The sample is a high severity event with the code 0, a message naming the rule, your login as the user and an empty IP. A webhook channel receives it in the usual payload, signed with the channel’s secret: see Webhook events. Nothing is written to the log.

Request

POST https://your-site.example/wp-json/plugixa-activity-log/v1/rules/4/test

Path parameters

Name Type Description
id integer The rule’s id

Request body

None.

Responses

200 OK. data has one result per channel, in the rule’s order.

{
  "success": true,
  "data": [
    {
      "type": "email",
      "target": "security@example.com",
      "ok": true,
      "message": "Delivered."
    },
    {
      "type": "webhook",
      "target": "hooks.example.com",
      "ok": false,
      "message": "The receiving service answered with HTTP 500."
    }
  ]
}
Field Type Meaning
data[].type string The channel’s type
data[].target string The email address, or only the host name of a URL, so the full address (and any token in it) is not echoed
data[].ok boolean Whether the channel accepted the alert. A receiving service has to answer with a 2xx status
data[].message string Delivered., or why it failed

Deliveries time out after 5 seconds and do not follow redirects.

Errors

Status Code When
404 plugixa_activity_log_not_found No rule with that id.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-activity-log/v1/rules/4/test" \
  -u "admin:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-activity-log/v1/rules/4/test');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = Buffer.from(`admin:${process.env.WP_APP_PASSWORD}`).toString('base64');
const response = await fetch('https://your-site.example/wp-json/plugixa-activity-log/v1/rules/4/test', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
  },
});
const { data } = await response.json();
const failed = data.filter((result) => !result.ok);

Quick Links

Share