Stages
Use this endpoint to obtain details on Mautic’s Contact Stages.
<?php
use Mautic\MauticApi;
use Mautic\Auth\ApiAuth;
// ...
$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings);
$apiUrl = "https://your-mautic.com";
$api = new MauticApi();
$stageApi = $api->newApi("stages", $auth, $apiUrl);
Get a Stage
Get an individual Stage.
<?php
//...
$stage = $stageApi->get($id);
HTTP request
GET /stages/ID
Response
Returns
200when the request successfully gets a Stage.
{
"stage": {
"id": 47,
"isPublished": 1,
"dateAdded": "2015-07-21T12:27:12-05:00",
"createdBy": 1,
"createdByUser": "Joe Smith",
"dateModified": "2015-07-21T14:12:03-05:00",
"modifiedBy": 1,
"modifiedByUser": "Joe Smith",
"name": "Stage A",
"category": null,
"description": "This is my first stage created via API.",
"weight": 0,
"publishUp": "2015-07-21T14:12:03-05:00",
"publishDown": "2015-07-21T14:12:03-05:00"
}
}
Stage properties
Name |
Type |
Description |
|---|---|---|
|
int |
Stage ID |
|
boolean |
Stage publication status |
|
datetime |
Stage creation date and time |
|
int |
Stage creator User ID |
|
string |
Stage creator User name |
|
datetime/null |
Stage last modification date and time |
|
int |
Stage last modifier User ID |
|
string |
Stage last modifier User name |
|
string |
Stage name |
|
int |
Stage Category ID |
|
string |
Stage description |
|
int |
Stage weight |
|
datetime |
Stage publication start date and time |
|
datetime |
Stage publication end date and time |
List Contact Stages
Get a list of Stages.
<?php
//...
$stages = $stageApi->getList($searchFilter, $start, $limit, $orderBy, $orderByDir, $publishedOnly, $minimal);
HTTP request
GET /stages
Response
Returns
200when the request successfully gets the list of Stages.
{
"total": 4,
"stages": [
{
"id": 47,
"isPublished": 1,
"dateAdded": "2015-07-21T12:27:12-05:00",
"createdBy": 1,
"createdByUser": "Joe Smith",
"dateModified": "2015-07-21T14:12:03-05:00",
"modifiedBy": 1,
"modifiedByUser": "Joe Smith",
"name": "Stage A",
"category": null,
"description": "This is my first stage created via API.",
"weight": 0,
"publishUp": "2015-07-21T14:12:03-05:00",
"publishDown": "2015-07-21T14:12:03-05:00"
}
//...
]
}
Stage properties
Name |
Type |
Description |
|---|---|---|
|
int |
Total Stage count |
|
int |
Stage ID |
|
boolean |
Stage publication status |
|
datetime |
Stage creation date and time |
|
int |
Stage creator User ID |
|
string |
Stage creator User name |
|
datetime |
Stage last modification date and time |
|
int |
Stage last modifier User ID |
|
string |
Stage last modifier User name |
|
string |
Stage name |
|
int |
Stage Category ID |
|
string |
Stage description |
|
int |
Stage weight |
|
datetime |
Stage publication start date and time |
|
datetime |
Stage publication end date and time |
Create Stage
Create a new Stage.
<?php
$data = array(
'name' => 'Stage A',
'weight' => 5,
'description' => 'This is my first stage created via API.',
'isPublished' => 1
);
$stage = $stageApi->create($data);
HTTP request
POST /stages/new
POST parameters
Name |
Type |
Description |
|---|---|---|
|
string |
Stage name - required |
|
int |
Stage weight |
|
string |
Stage description |
|
boolean |
Stage publication status |
Response
Returns
201when the request successfully creates a Stage.
Properties
Name |
Type |
Description |
|---|---|---|
|
int |
Stage ID |
|
boolean |
Stage publication status |
|
datetime |
Stage creation date and time |
|
int |
Stage creator User ID |
|
string |
Stage creator User name |
|
datetime/null |
Stage last modification date and time |
|
int |
Stage last modifier User ID |
|
string |
Stage last modifier User name |
|
string |
Stage name |
|
int |
Stage Category ID |
|
string |
Stage description |
|
int |
Stage weight |
|
datetime |
Stage publication start date and time |
|
datetime |
Stage publication end date and time |
Edit Stage
Edit a Stage. This operation supports PUT or PATCH depending on the desired behavior:
PUT: creates a Stage when the ID doesn’t exist. If the ID exists, the request clears the Stage data and adds the request values.PATCH: updates field values for an existing Stage using the request data. The request fails when the ID doesn’t exist.
<?php
$id = 1;
$data = array(
'name' => 'New stage name',
'isPublished' => 0
);
// Create new a stage if ID 1 is not found?
$createIfNotFound = true;
$stage = $stageApi->edit($id, $data, $createIfNotFound);
HTTP request
PATCH /stages/ID/edit: edits an existing Stage. The request fails with a 404 error when the ID doesn’t exist.PUT /stages/ID/edit: edits an existing Stage or creates a new one when the ID doesn’t exist.
POST parameters
Name |
Type |
Description |
|---|---|---|
|
string |
Stage name - required |
|
string |
Stage alias - generated automatically if not set |
|
string |
Stage description |
|
boolean |
Stage publication status |
|
int |
Stage weight |
Response
PUT: returns200when the request successfully edits a Stage or201when the request creates a Stage.PATCH: returns200when the request successfully edits a Stage.
Properties
Name |
Type |
Description |
|---|---|---|
|
int |
Stage ID |
|
boolean |
Stage publication status |
|
datetime |
Stage creation date and time |
|
int |
Stage creator User ID |
|
string |
Stage creator User name |
|
datetime/null |
Stage last modification date and time |
|
int |
Stage last modifier User ID |
|
string |
Stage last modifier User name |
|
string |
Stage name |
|
int |
Stage Category ID |
|
string |
Stage description |
|
int |
Stage weight |
|
datetime |
Stage publication start date and time |
|
datetime |
Stage publication end date and time |
Delete Stage
Delete a Stage.
<?php
$stage = $stageApi->delete($id);
HTTP request
DELETE /stages/ID/delete
Response
Returns
200when the request successfully deletes a Stage.
Properties
Name |
Type |
Description |
|---|---|---|
|
int |
Stage ID |
|
boolean |
Stage publication status |
|
datetime |
Stage creation date and time |
|
int |
Stage creator User ID |
|
string |
Stage creator User name |
|
datetime/null |
Stage last modification date and time |
|
int |
Stage last modifier User ID |
|
string |
Stage last modifier User name |
|
string |
Stage name |
|
int |
Stage Category ID |
|
string |
Stage description |
|
int |
Stage weight |
|
datetime |
Stage publication start date and time |
|
datetime |
Stage publication end date and time |
Add Contact to a Stage
Add a Contact to a Stage manually.
<?php
//...
$response = $stageApi->addContact($stageId, $contactId);
if (!isset($response['success'])) {
// handle error
}
HTTP request
POST /stages/STAGE_ID/contact/CONTACT_ID/add
Response
Returns
200when the request successfully adds the Contact to the Stage.
{
"success": true
}
Remove Contact from a Stage
Remove a Contact from a Stage manually.
<?php
//...
$response = $stageApi->removeContact($stageId, $contactId);
if (!isset($response['success'])) {
// handle error
}
HTTP request
POST /stages/STAGE_ID/contact/CONTACT_ID/remove
Response
Returns
200when the request successfully removes the Contact from the Stage.
{
"success": true
}