This feature introduces a new campaign action in Mautic that allows campaigns to send outbound API requests.
Tip
Other releases of this plugin may cover different Mautic versions!
- Mautic 6
- PHP >= 8.1
-
Campaign action: Send API request with comprehensive configuration options
-
HTTP methods: Choose between GET, POST, PUT, or PATCH
-
Custom request body: Define raw request body with token replacement support
-
Authentication options:
- Basic HTTP authentication (username/password)
- Custom authorization headers (Bearer tokens, API keys, etc.)
-
Response tracking: Capture raw response headers and body and make them visible in the contact's timeline history
-
Contact field storage: Store response data in selected contact fields with regex or JSON parsing
-
GET request parameters: Support for URL parameters when using GET method
-
Token replacement: Use contact field tokens in URLs and request bodies
-
Redirect handling: Automatic handling of HTTP redirects
composer require leuchtfeuer/mautic-apicalls-bundle- Download the plugin
- Unzip to the Mautic
pluginsdirectory - Rename folder to
LeuchtfeuerAPICallsBundle - In the Mautic backend, go to the
Pluginspage as an administrator - Click on the
Install/Upgrade Pluginsbutton to install the Plugin - OR run:
php bin/console cache:clearphp bin/console mautic:plugins:reload
After installation, navigate to Settings → Plugins → API Calls by Leuchtfeuer and configure your API endpoints and settings as needed.
- In the Campaign Builder, add the "Send API Request" action to your campaign.
- Configure the API request details in the action settings.
- The plugin will send the API request when the campaign action is executed.
Choose from the following HTTP methods:
- GET: For retrieving data from endpoints
- POST: For sending data to create new resources
- PUT: For updating existing resources
- PATCH: For partial updates
When using the GET method, you can define URL parameters in a dedicated field:
- Format:
email={contactfield=email}&category=7 - Use
{contactfield=fieldname}to insert contact field values - The leading
?is automatically added - do not include it in your parameter string
Configure authentication for your API requests:
- Username: Enter the username for basic HTTP authentication
- Password: Enter the password for basic HTTP authentication
Add custom authorization headers for API authentication:
- Additional HTTP Header line: Add any custom header (e.g.,
Authorization: Bearer eyJhbGc) - The header is sent exactly as entered with the request
- Common example:
Authorization: Bearer eyJhbGc
Store and process API response data in contact fields with two powerful options:
Extract specific values from JSON responses using intuitive dot notation:
- Object Key: Specify the parent object to search within (optional)
- Value Key: Use dot notation to extract the desired value
JSON Parser Examples:
{
"user": {
"email": "john@example.com",
"profile": {
"name": "John Doe",
"age": 30
}
},
"items": [
{"name": "Product A", "price": 19.99},
{"name": "Product B", "price": 29.99}
]
}- To get
john@example.com: Object Key:user, Value Key:email - To get
John Doe: Object Key:user, Value Key:profile.name - To get first item name: Value Key:
items[0].name - To get user's age: Object Key:
user, Value Key:profile.age
Apply regular expressions to extract specific data from any response format:
- Use standard regex patterns to filter or transform response data
- Leave empty to store the entire response body
Regex Examples:
- Extract email:
/[\w\.-]+@[\w\.-]+\.\w+/ - Extract numbers:
/\d+/ - Extract JSON value:
/"email"\s*:\s*"([^"]+)"/
- Make sure you have installed and enabled the plugin.
- If the action does not appear, clear the cache and reload plugins:
php bin/console cache:clearphp bin/console mautic:plugins:reload
- If you update the plugin code, repeat the above commands.
- Only text-type contact fields are available for response storage
- JSON Parser: If the response is valid JSON and keys are found, the extracted value is stored
- Regex Processing: If regex processing fails, the original response body will be stored
- Verify that the selected contact field has sufficient length to store the response data
- Verify that your authorization header format is correct (e.g.,
Authorization: Bearer eyJhbGc) - Ensure that custom headers contain a colon (
:) to separate the header name from the value - Basic authentication and custom headers can be used together if needed
For complete version history, see GitHub.
For support or custom features, contact mautic-plugins@leuchtfeuer.com
This plugin is licensed under the GPL v3 License.