Summary

The notify() mutation sends a notification to one or more recipients in LogScale. Use the target field in the input to specify the recipient type: individual users, groups, organization roots, or all users. The notification includes a title, message body, severity level, and display type.

Syntax

graphql
notify(
      input: NotificationInput!
   ): Notification!

The mutation accepts a single required input argument of type NotificationInput!. The input specifies the recipient target, title, message body, severity level, notification display type, and whether the notification is dismissable by the recipient. See the Input Parameters section for all available fields.

The mutation returns a non-null Notification object. Request the id field to obtain the notification identifier, which you can pass to dismissNotification() or deleteNotification(). See the Returned Values section for all available fields.

Example

Raw
graphql
mutation {
  notify( input: {
         dismissable: true,
         title: "Ding",
         message: "Hey! Wake up!",
         target: All
         severity: Info,
         notificationType: Bell,
  } )
  {id}
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  notify( input: {
         dismissable: true,
         title: \"Ding\",
         message: \"Hey! Wake up!\",
         target: All
         severity: Info,
         notificationType: Bell,
  } )
  {id}
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  notify( input: {
         dismissable: true,
         title: \"Ding\",
         message: \"Hey! Wake up!\",
         target: All
         severity: Info,
         notificationType: Bell,
  } )
  {id}
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  notify( input: { ^
         dismissable: true, ^
         title: \"Ding\", ^
         message: \"Hey! Wake up!\", ^
         target: All ^
         severity: Info, ^
         notificationType: Bell, ^
  } ) ^
  {id} ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  notify( input: {
         dismissable: true,
         title: \"Ding\",
         message: \"Hey! Wake up!\",
         target: All
         severity: Info,
         notificationType: Bell,
  } )
  {id}
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "mutation {
  notify( input: {
         dismissable: true,
         title: \"Ding\",
         message: \"Hey! Wake up!\",
         target: All
         severity: Info,
         notificationType: Bell,
  } )
  {id}
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  notify( input: {
         dismissable: true,
         title: \"Ding\",
         message: \"Hey! Wake up!\",
         target: All
         severity: Info,
         notificationType: Bell,
  } )
  {id}
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  notify( input: {
         dismissable: true,
         title: \"Ding\",
         message: \"Hey! Wake up!\",
         target: All
         severity: Info,
         notificationType: Bell,
  } )
  {id}
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "notify": {
      "id": "abc123"
    }
  }
}

Input Parameters

The NotificationInput type defines the recipient target, message content, title, severity, and notification display type. The following table describes each field:

Table: NotificationInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
dismissableBooleanyes Long-Term Whether the notification is dismissable by the user.
idsStringyes Long-Term The unique identifiers of the notifications.
linkString  Long-Term A link that may be included, if preferred, in the notification.
linkDescriptionString  Long-Term A description of the link given in the notification.
messageStringyes Long-Term The message to be used when notifying.
notificationTypeNotificationTypesyes Long-Term The type of notification. See NotificationTypes.
severityNotificationSeverityyes Long-Term The severity level of the notification. See NotificationSeverity.
targetTargetsyes Long-Term The target users for the notification. See Targets.
titleStringyes Long-Term The title for the notification.

Returned Values

The mutation returns a Notification object containing the notification identifier, title, message body, severity level, and target information. Request id to obtain the identifier for use with dismissNotification() or deleteNotification(). The following table describes all available fields:

Table: Notification Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
dismissableBooleanyes Long-Term Whether the notification is dismissable.
idStringyes Long-Term The unique identifier for the notification.
linkString  Long-Term Link accompanying the notification.
linkDescriptionString  Long-Term A description for the link.
messageStringyes Long-Term The message for the notification.
severityNotificationSeverityyes Long-Term The severity of the notification. See NotificationSeverity.
titleStringyes Long-Term The title or heading of the notification.
typeNotificationTypesyes Long-Term The type of the notification. See NotificationTypes.