A (not so?) simple API call?

Your software
My Mautic version is: 4.4.7
My PHP version is: 7.4
My Database type and version is:

Your problem
My problem is:

The solution I want seems quite simple, finding the answer to it seems not so simple.

We are using ManageEngine ADManager to create user account within our Windows AD environment.
After/while creating the new account, ADManager kicks off a PowerShell script which does some logging and sends 2 emails to the newly created user.
1 email containing the username and 1 email with the password.

What we want:
Create 2 email templates within Mautic, 1 with some text and the {username}, 1 with some text and the {password}.
Instead of making PowerShell send the 2 emails, we want PowerShell to make two API calls to Mautic which sends the “welcome” emails.

  • First API call includes the new user email and username and sends this information to the given email
  • Second API call includes the new user email and password and sends this information to the given email

I did find this ( How send emails with Mautic with a custom text using API? - Stack Overflow) article (among a few others) on how to use custom inputs for email (such as the username and password).

It would be nice if the emails can be send without the need to create a contact, but if that’s not possible we can create the contact and then delete it.
Also, if it’s not possible to make the API calls with PowerShell, I could use PHP to make the API calls (but preferable with PowerShell).

Does anyone have or know such a solution?
I’ve been searching for a few days but haven’t found how I should do this yet.

Hi @criskolkman

In order for Mautic to be able to send an email the user must exist in Mautic.

You can do as you say, create the user with the api/contacts/new and then delete the user after that.

You can also use tokens to send inside an email, inside the email you would need to use the syntax {token_name} that you are passing through.

The call would be https://your_mautic/api/emails/[email_id]/contacts/[contact_id]/send
where email_id is the id of the email you want to send and contact_id the id of the contact you want to send to.

Inside your payload you would define your body parameter with name token and the values you would send would be something like this:


and similar for the password email.

I am unfamiliar with Powershell, but I guess it is the same as using bash, and this is definelty possible.

A good reference is https://developer.mautic.org/

Hope this helps

1 Like

Hello @mikew,

Thank you for the fast response, I will try this out and update the post!