Overview
You can use this request to add contacts to a workflow.
The Method
| API | - | Method |
|---|---|---|
| REST | POST | https://[Your URL]/api/3.0/workflows/subscribe-contacts |
Your URL is the address of your install.
Parameters
Required Parameters
You must specify the name and email of the customer you want to create.
| Property | Type | Description | Required |
|---|---|---|---|
| workflow_id | integer | The ID of the Workflow you with to add the contacts to. This can be found by hovering over the checkbox of the Workflow on the Workflow History page. | yes |
| contacts | array | Array of contacts to add to the workflow. These contacts need to already exist in the system on the list that the workflow is linked to. | yes |
Contacts
The contacts parameter can use one of two ways to identify the contact. See the following table:
| Property | Description |
|---|---|
| contact_email | If you use this option, the contact will be found using their email address. If more than one contact exists with this email address, use the other field. |
| contact_unique_id | Use this field if you want to select the contact using their unique ID. You can set this field to whatever you like. |
Responses
| Property | Type | Description |
|---|---|---|
| result | string | A string that can either be “error” or “success”. “success” means all contacts successfully added to the Workflow. “error” means that one or more contacts failed to add to the Workflow. |
| message | string | A string that describes the result. It will state what the error was if there was an error. |
| contacts not found | array | Array of contacts that either do not exist in the product, or they are not subscribed to the list assigned to the Workflow provided. |
| contacts failed | array | Array of contacts that failed to add to the Workflow. |
| contacts succeeded | array | Array of contacts that succeeded if there was an error. This property is not returned if all contacts succeeded, because there is no need. |
Code Samples
The following is a code sample for the create customer request:
<?php
$user = '(Your username)';
$apiKey = '(Your API Key)';
$host = '(Your URL)';
$path = '/api/3.0/workflows/subscribe-contacts';
$method = 'POST';
$json = '
{
"workflow_id": 13,
"contacts":[
{"contact_unique_id":"abc"},
{"contact_unique_id":"xyz"}
]
}
';
$cSession = curl_init();
$auth = base64_encode($user . ':' . $apiKey);
$headers = array();
$headers[] = 'Authorization: Basic ' . $auth;
$headers[] = 'Content-Type: application/json';
curl_setopt($cSession, CURLOPT_HTTPHEADER, $headers);
curl_setopt($cSession, CURLOPT_URL, $host . $path);
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cSession, CURLOPT_HEADER, false);
curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($cSession, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($cSession);
curl_close($cSession);
echo $result;
?>