Dynamic Content
Use this endpoint to obtain details on Mautic’s Dynamic Web Content.
Using Mautic’s API Library
You can interact with this API through the Mautic API Library as follows, or use the various http endpoints as described in this document.
<?php
use Mautic\MauticApi;
use Mautic\Auth\ApiAuth;
// ...
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings);
$apiUrl = "https://mautic.example.com";
$api = new MauticApi();
$dynamicContentApi = $api->newApi("dynamicContents", $auth, $apiUrl);
Get Dynamic Content
<?php
//...
$dynamicContent = $dynamicContentApi->get($id);
Get an individual dynamicContent by ID.
HTTP Request
GET /dynamiccontents/ID
Response
Expected Response Code: 200
{
"dynamicContent":{
"isPublished":true,
"dateAdded":"2016-06-20T11:26:51+00:00",
"createdBy":1,
"createdByUser":"John Doe",
"dateModified":"2016-08-08T16:36:27+00:00",
"modifiedBy":1,
"modifiedByUser":"John Doe",
"id":1,
"name":"DC13",
"category":null,
"publishUp":null,
"publishDown":null,
"sentCount":0,
"variantParent":null,
"variantChildren":[]
}
}
Dynamic Content Properties
Name |
Type |
Description |
---|---|---|
|
int |
ID of the Dynamic Content |
|
string |
Name of the Dynamic Content |
|
string/null |
Description of the Dynamic Content |
|
boolean |
Published state |
|
datetime/null |
Dynamic Content publish date/time |
|
datetime/null |
Dynamic Content unpublish date/time |
|
|
Dynamic Content creation date |
|
int |
ID of the User that created the Dynamic Content |
|
string |
Name of the User that created the Dynamic Content |
|
datetime/null |
Date/time Dynamic Content was last modified |
|
int |
ID of the User that last modified the Dynamic Content |
|
string |
Name of the User that last modified the Dynamic Content |
|
array |
Array of Dynamic Content entities for variants of this landing Dynamic Content |
|
object |
The parent/main Dynamic Content if this is a variant, also known as A/B test |
|
int |
Count of how many times the Dynamic Content got sent |
List Dynamic Contents
<?php
// ...
$dynamicContents = $dynamicContentApi->getList($searchFilter, $start, $limit, $orderBy, $orderByDir, $publishedOnly, $minimal);
HTTP Request
GET /dynamiccontents
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":30,
"dynamicContents":[
{
"isPublished":true,
"dateAdded":"2016-06-20T11:27:09+00:00",
"createdBy":1,
"createdByUser":"John Doe",
"dateModified":"2016-08-22T17:14:01+00:00",
"modifiedBy":1,
"modifiedByUser":"John Doe",
"id":2,
"name":"CD2",
"category":null,
"publishUp":null,
"publishDown":null,
"sentCount":0,
"variantParent":null,
"variantChildren":[]
}
]
}
Properties
Same as Get Dynamic Content.
Create Dynamic Content
<?php
$data = array(
'name' => 'Dynamic Content A',
'isPublished' => 1
);
$dynamicContent = $dynamicContentApi->create($data);
Create a new Dynamic Content.
HTTP Request
POST /dynamiccontents/new
POST Parameters
Name |
Type |
Description |
---|---|---|
|
int |
ID of the Dynamic Content |
|
string |
Name of the Dynamic Content |
|
string/null |
Description of the Dynamic Content |
|
boolean |
Published state |
|
datetime/null |
Dynamic Content publish date/time |
|
datetime/null |
Dynamic Content unpublish date/time |
|
|
Dynamic Content creation date |
|
int |
ID of the User that created the Dynamic Content |
|
string |
Name of the User that created the Dynamic Content |
|
datetime/null |
Date/time Dynamic Content was last modified |
|
int |
ID of the User that last modified the Dynamic Content |
|
string |
Name of the User that last modified the Dynamic Content |
|
array |
Array of Dynamic Content entities for variants of this landing Dynamic Content |
|
object |
The parent/main Dynamic Content if this is a variant, also known as A/B test |
|
int |
Count of how many times the Dynamic Content got sent |
Response
Expected Response Code: 201
Properties
Same as Get Dynamic Content.
Edit Dynamic Content
<?php
$id = 1;
$data = array(
'name' => 'New dynamicContent name',
'isPublished' => 0
);
// Create new a dynamicContent of ID 1 isn't found?
$createIfNotFound = true;
$dynamicContent = $dynamicContentApi->edit($id, $data, $createIfNotFound);
Edit a new Dynamic Content. Note that this supports PUT or PATCH depending on the desired behavior.
PUT creates a Dynamic Content if the given ID doesn’t exist and clears all the Dynamic Content information, adds the information from the request. PATCH fails if the Dynamic Content with the given ID doesn’t exist and updates the Dynamic Content field values with the values from the request.
HTTP Request
To edit a Dynamic Content and return a 404 if the Dynamic Content isn’t found:
PATCH /dynamiccontents/ID/edit
To edit a Dynamic Content and create a new one if the Dynamic Content isn’t found:
PUT /dynamiccontents/ID/edit
POST Parameters
Name |
Type |
Description |
---|---|---|
|
int |
ID of the Dynamic Content |
|
string |
Name of the Dynamic Content |
|
string/null |
Description of the Dynamic Content |
|
boolean |
Published state |
|
datetime/null |
Dynamic Content publish date/time |
|
datetime/null |
Dynamic Content unpublish date/time |
|
|
Dynamic Content creation date |
|
int |
ID of the User that created the Dynamic Content |
|
string |
Name of the User that created the Dynamic Content |
|
datetime/null |
Date/time Dynamic Content was last modified |
|
int |
ID of the User that last modified the Dynamic Content |
|
string |
Name of the User that last modified the Dynamic Content |
|
array |
Array of Dynamic Content entities for variants of this landing Dynamic Content |
|
object |
The parent/main Dynamic Content if this is a variant, also known as A/B test |
|
int |
Count of how many times the Dynamic Content got sent |
Response
If PUT
, the expected response code is 200
if editing an existing Dynamic Content entry or 201
if creating a new one.
If PATCH
, the expected response code is 200
.
Properties
Same as Get Dynamic Content.
Delete Dynamic Content
<?php
$dynamicContent = $dynamicContentApi->delete($id);
Delete a Dynamic Content.
HTTP Request
DELETE /dynamiccontents/ID/delete
Response
Expected Response Code: 200
Properties
Same as Get Dynamic Content.