API basic authentication

Step 1: Set Up API Credentials in DesignDiverso Automata

  • Log in to your DesignDiverso Automata instance and navigate to “Configuration” -> “API Credentials.”
  • Create a new set of API credentials by clicking on the “New” button.
  • Fill in the required details, such as the name of the credentials, access token, and the IP address or range allowed to access the API.
  • Save the credentials and make note of the access token as you will need it in the PHP code.


Step 2: Install Required Libraries

    • Make sure you have the required libraries installed to make API requests in PHP. You can use Composer to manage dependencies.
    • Install the Guzzle HTTP client library by running the following command in your project directory:


    [code lang=”bash”]composer require guzzlehttp/guzzle[/code]

Step 3: Set Up the PHP Script

  • Create a new PHP file, e.g., post-to-designdiverso-automata.php, and open it in a text editor.
  • Require the Guzzle library at the top of the file:


[php classname=”rounded”]require ‘vendor/autoload.php’;[/php]

Step 4: Write the API Request Code

Start by initializing the Guzzle client and specifying the Mautic API endpoint:


[php  classname=”rounded”]$client = new GuzzleHttp\Client();
$apiUrl = ‘https://your-mautic-instance.com/api/contacts’;


Prepare the API request headers and body with the data you want to post:


[php toolbar=”true”]

$headers = [
‘Authorization’ => ‘Bearer YOUR_ACCESS_TOKEN’,
‘Content-Type’ => ‘application/json’,

$body = [
‘firstname’ => ‘John’,
‘lastname’ => ‘Doe’,
’email’ => ‘johndoe@example.com’,
// Include any other relevant contact data



Make the API POST request to DesignDiverso Automata:


[php toolbar=”true”]$response = $client->post($apiUrl, [‘headers’ => $headers,’json’ => $body,]);[/php]

Check the response status code to verify if the request was successful:


[php]if ($response->getStatusCode() === 200) {
echo ‘Contact added successfully!’;
} else {
echo ‘Failed to add contact.’;

Step 5: Replace Access Token and Test

  • Replace 'YOUR_ACCESS_TOKEN' in the $headers array with the actual access token you obtained from DesignDiverso Automata‘s API credentials.
  • Save the PHP file and run it from the command line or access it via a web server to test the API request.

Useful Tips:

  • Ensure that the DesignDiverso Automata API endpoint URL in the $apiUrl variable is correct and points to your DesignDiverso Automata instance.
  • Keep your API credentials secure and avoid sharing them in public repositories or code snippets.
  • Validate and sanitize user input before sending it to DesignDiverso Automata via the API to prevent potential security vulnerabilities.
  • Handle errors and exceptions gracefully by implementing error-handling mechanisms in your PHP script.
  • Familiarize yourself with DesignDiverso Automata‘s API documentation to understand available endpoints, request/response formats, and additional options.
  • Consider implementing pagination and batching if you need to handle a large number of contacts or perform multiple API requests in a loop.

By following these steps and tips, you can create a PHP script to post data to DesignDiverso Automata via the API, allowing you to automate contact creation and management in your Mautic instance.

  We can set this up for you if you are on one of our managed plans.


Do you have any questions? We are happy to help you via    email  phone or  video call.

Click here to go back to the main help page:

DesignDiverso Automata