Notifications
Use this endpoint to obtain details on Mautic’s notifications.
<?php
use Mautic\MauticApi;
use Mautic\Auth\ApiAuth;
// ...
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings);
$apiUrl = "https://example.com";
$api = new MauticApi();
$notificationApi = $api->newApi("notifications", $auth, $apiUrl);
Get notification
<?php
//...
$notification = $notificationApi->get($id);
Get an individual notification by ID.
HTTP Request
GET /notifications/ID
Response
Expected Response Code: 200
{
"notification":{
"isPublished":true,
"dateAdded":"2016-09-14T14:03:05+00:00",
"createdBy":1,
"createdByUser":"John Doe",
"dateModified":"2016-09-15T08:40:46+00:00",
"modifiedBy":1,
"modifiedByUser":"John Doe",
"id":1,
"name":"The first notification",
"heading":"The first notification Heading",
"message":"The first notification Message",
"url":"http:\/\/mautic.org",
"language":"en",
"category":null,
"publishUp":null,
"publishDown":null,
"readCount":0,
"sentCount":0
}
}
Notification Properties
Name |
Type |
Description |
---|---|---|
|
int |
ID of the notification |
|
string |
Title of the notification |
|
string |
Heading of the notification |
|
string |
Message of the notification |
|
string |
URL to go to when the notification gets clicked |
|
boolean |
Published state |
|
datetime/null |
Notification publish date/time |
|
datetime/null |
Notification unpublish date/time |
|
|
Date/time notification got created |
|
int |
ID of the User that created the notification |
|
string |
Name of the User that created the notification |
|
datetime/null |
Date/time notification was last modified |
|
int |
ID of the User that last modified the notification |
|
string |
Name of the User that last modified the notification |
|
string |
Language locale of the notification |
|
int |
Total notification read count |
|
int |
Unique notification sent count |
|
null/object |
Category |
List notifications
<?php
// ...
$notifications = $notificationApi->getList($searchFilter, $start, $limit, $orderBy, $orderByDir, $publishedOnly, $minimal);
HTTP Request
GET /notifications
Query Parameters
Name |
Description |
---|---|
|
String or search command to filter entities by. |
|
Starting row for the entities returned. Defaults to 0. |
|
Limit number of entities to return. Defaults to the system configuration for pagination - defaults to 30 |
|
Column to sort by. Can use any column listed in the response. |
|
Sort direction: |
|
Only return currently published entities. |
|
Return only array of entities without additional lists in it. |
Response
Expected Response Code: 200
{
"total":1,
"notifications":[
{
"isPublished":true,
"dateAdded":"2016-09-14T14:03:05+00:00",
"createdBy":1,
"createdByUser":"John Doe",
"dateModified":"2016-09-15T08:40:46+00:00",
"modifiedBy":1,
"modifiedByUser":"John Doe",
"id":1,
"name":"The first notification",
"heading":"The first notification Heading",
"message":"The first notification Message",
"url":"http:\/\/mautic.org",
"language":"en",
"category":null,
"publishUp":null,
"publishDown":null,
"readCount":0,
"sentCount":0
}
]
}
Properties
Same as Get Notification.
Create notification
<?php
$data = array(
'name' => 'Notification A',
'heading' => 'Hello World!'
'message' => 'This is my first notification created via API.',
);
$notification = $notificationApi->create($data);
Create a new notification.
HTTP Request
POST /notifications/new
POST Parameters
Name |
Type |
Description |
---|---|---|
|
int |
ID of the notification |
|
string |
Title of the notification |
|
string |
Heading of the notification |
|
string |
Message of the notification |
|
string |
URL to go to when the notification gets clicked |
|
boolean |
Published state |
|
datetime/null |
Notification publish date/time |
|
datetime/null |
Notification unpublish date/time |
|
string |
Language locale of the notification |
Response
Expected Response Code: 201
Properties
Same as Get Notification.
Edit notification
<?php
$id = 1;
$data = array(
'name' => 'Notification A',
'heading' => 'Hello World!'
'message' => 'This is my first notification created via API.',
);
// Create new a notification of ID 1 isn't found?
$createIfNotFound = true;
$notification = $notificationApi->edit($id, $data, $createIfNotFound);
Edit a new notification. Note that this supports PUT or PATCH depending on the desired behavior.
PUT creates a notification if the given ID doesn’t exist and clears all the notification information, adds the information from the request. PATCH fails if the notification with the given ID doesn’t exist and updates the notification field values with the values from the request.
HTTP Request
To edit a notification and return a 404 if the notification isn’t found:
PATCH /notifications/ID/edit
To edit a notification and create a new one if the notification isn’t found:
PUT /notifications/ID/edit
POST Parameters
Name |
Type |
Description |
---|---|---|
|
int |
ID of the notification |
|
string |
Title of the notification |
|
string |
Heading of the notification |
|
string |
Message of the notification |
|
string |
URL to go to when the notification gets clicked |
|
boolean |
Published state |
|
datetime/null |
Notification publish date/time |
|
datetime/null |
Notification unpublish date/time |
|
string |
Language locale of the notification |
Response
If PUT
, the expected response code is 200
if the notification got edited or 201
if created.
If PATCH
, the expected response code is 200
.
Properties
Same as Get Notification.
Delete notification
<?php
$notification = $notificationApi->delete($id);
Delete a notification.
HTTP Request
DELETE /notifications/ID/delete
Response
Expected Response Code: 200
Properties
Same as Get Notification.