Landing Pages API
Use this endpoint to obtain details on Mautic’s Landing Pages.
<?php
use Mautic\MauticApi;
use Mautic\Auth\ApiAuth;
// ...
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings);
$apiUrl = "https://example.com";
$api = new MauticApi();
$pageApi = $api->newApi("pages", $auth, $apiUrl);
Get Landing Page
<?php
//...
$page = $pageApi->get($id);
Get an individual Landing Page by ID.
HTTP Request
GET /pages/ID
Response
Expected Response Code: 200
{
"page": {
"id": 3,
"title": "Webinar Landing Page",
"description": null,
"isPublished": true,
"publishUp": null,
"publishDown": null,
"dateAdded": "2015-07-15T15:06:02-05:00",
"createdBy": 1,
"createdByUser": "Joe Smith",
"dateModified": "2015-07-20T13:11:56-05:00",
"modifiedBy": 1,
"modifiedByUser": "Joe Smith",
"category": "Events",
"language": "en",
"template": "blank",
"customHtml": "<!DOCTYPE ...",
"hits": 0,
"uniqueHits": 0,
"variantHits": 0,
"revision": 1,
"metaDescription": null,
"redirectType": null,
"redirectUrl": null,
"translationChildren": [],
"translationParent": null,
"variantChildren": [],
"variantParent": null,
"variantSettings": [],
"variantStartDate": null
}
}
Landing Page Properties
Name |
Type |
Description |
---|---|---|
|
int |
ID of the Landing Page |
|
string |
Title of the Landing Page |
|
string/null |
Description of the Landing Page |
|
string |
Used to generate the URL for the Landing Page |
|
boolean |
Published state |
|
datetime/null |
Landing Page publish date/time |
|
datetime/null |
Landing Page unpublish date/time |
|
|
Landing Page creation date/time |
|
int |
ID of the User that created the Landing Page |
|
string |
Name of the User that created the Landing Page |
|
datetime/null |
Date/time Landing Page was last modified |
|
int |
ID of the User that last modified the Landing Page |
|
string |
Name of the User that last modified the Landing Page |
|
string |
Language locale of the Landing Page |
|
string |
Template of the Landing Page |
|
string |
Static HTML of the Landing Page |
|
int |
Total Landing Page hit count |
|
int |
Unique Landing Page hit count |
|
int |
Landing Page revision |
|
string |
Meta description which gets rendered in the Landing Page’s |
|
int |
If unpublished, redirect with 301 or 302 |
|
string |
If unpublished, the URL to redirect to if |
|
array |
Array of Landing Page entities for translations of this Landing Page |
|
object |
The parent/main Landing Page if this is a translation |
|
int |
Hit count since variantStartDate |
|
array |
Array of Landing Page entities for variants of this Landing Page |
|
object |
The parent/main Landing Page if this is a variant, also known as A/B test |
|
array |
The properties of the A/B test |
|
datetime/null |
The date/time the A/B test began |
List Landing Pages
<?php
// ...
$pages = $pageApi->getList($searchFilter, $start, $limit, $orderBy, $orderByDir, $publishedOnly, $minimal);
{
"total": 1,
"pages": [
{
"id": 3,
"title": "Webinar Landing Page",
"description": null,
"isPublished": true,
"publishUp": null,
"publishDown": null,
"dateAdded": "2015-07-15T15:06:02-05:00",
"createdBy": 1,
"createdByUser": "Joe Smith",
"dateModified": "2015-07-20T13:11:56-05:00",
"modifiedBy": 1,
"modifiedByUser": "Joe Smith",
"category": "Events",
"language": "en",
"template": "blank",
"hits": 0,
"uniqueHits": 0,
"variantHits": 0,
"revision": 1,
"metaDescription": null,
"redirectType": null,
"redirectUrl": null,
"translationChildren": [],
"translationParent": null,
"variantChildren": [],
"variantParent": null,
"variantSettings": [],
"variantStartDate": null
}
]
}
HTTP Request
GET /pages
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
See JSON code example.
Properties
Same as Get Landing Page.
Create Landing Page
<?php
$data = array(
'title' => 'Page A',
'description' => 'This is my first Landing Page created via API.',
'isPublished' => 1
);
$page = $pageApi->create($data);
Create a new Landing Page.
HTTP Request
POST /pages/new
POST Parameters
Name |
Type |
Description |
---|---|---|
|
string |
Landing Page title is the only required field |
|
string |
Used to generate the URL for the Landing Page |
|
string |
A description of the Landing Page. |
|
int |
A value of 0 or 1 |
|
string |
Language locale of the Landing Page |
|
string |
Meta description for the Landing Page’s |
|
int |
If unpublished, redirect with 301 or 302 |
|
string |
If unpublished, the URL to redirect to if |
Response
Expected Response Code: 201
Properties
Same as Get Landing Page.
Edit Landing Page
<?php
$id = 1;
$data = array(
'title' => 'New Landing Page title',
'isPublished' => 0
);
// Create new a Landing Page of ID 1 isn't found?
$createIfNotFound = true;
$page = $pageApi->edit($id, $data, $createIfNotFound);
Edit a new Landing Page. Note that this supports PUT or PATCH depending on the desired behavior.
PUT creates a Landing Page if the given ID doesn’t exist and clears all the Landing Page information, adds the information from the request.
PATCH fails if the Landing Page with the given ID doesn’t exist and updates the Landing Page field values with the values from the request.
HTTP Request
To edit a Landing Page and return a 404 if the Landing Page isn’t found:
PATCH /pages/ID/edit
To edit a Landing Page and create a new one if the Landing Page isn’t found:
PUT /pages/ID/edit
POST Parameters
Name |
Type |
Description |
---|---|---|
|
string |
Landing Page title is the only required field |
|
string |
Name alias generated automatically if not set |
|
string |
A description of the Landing Page. |
|
int |
A value of 0 or 1 |
|
string |
Language locale of the Landing Page |
|
string |
Meta description for the Landing Page’s |
|
int |
If unpublished, redirect with 301 or 302 |
|
string |
If unpublished, the URL to redirect to if |
Response
If PUT
, the expected response code is 200
if editing a Landing Page or 201
if creating a new one.
If PATCH
, the expected response code is 200
.
Properties
Same as Get Landing Page.
Delete Landing Page
<?php
$page = $pageApi->delete($id);
Delete a Landing Page.
HTTP Request
DELETE /pages/ID/delete
Response
Expected Response Code: 200
Properties
Same as Get Landing Page.