### List Themes Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/themes.md Example JSON response when listing themes. It contains a 'themes' object with details for each installed theme. ```json { "themes": { "blank": { "name": "Blank", "key": "blank", "config": { "name": "Blank", "author": "Mautic team", "authorUrl": "https://mautic.org", "features": [ "page", "email", "form" ] } } } } ``` -------------------------------- ### Get Theme Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/themes.md Example JSON response when a theme is successfully retrieved. It indicates the path to the downloaded ZIP file. ```json { "file": "/absolute/path/to/the/system/temp/dir/with/the/theme/zip/file" } ``` -------------------------------- ### Start DDEV Environment Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/testing/e2e_test_suite.md Start the DDEV environment for Mautic development. Ensure DDEV is installed prior to running this command. ```bash ddev start ``` -------------------------------- ### HTTP Request Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/campaigns.md Demonstrates the GET request format to retrieve a campaign. Replace ID with the actual campaign identifier. ```http GET /campaigns/ID ``` -------------------------------- ### Fetch API Keys from Integration Configuration Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugin_integrations/integrations_configuration.md Retrieve API keys for an integration using the integration helper. This example shows how to get the 'username' from the stored API keys. ```php get(HelloWorldIntegration::NAME)->getIntegrationConfiguration()->getApiKeys(); $username = $apiKeys['username']; ``` -------------------------------- ### Start DDEV Environment for Mautic Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/development-environment/how_to_install_with_ddev.md Navigate to the Mautic directory and start the DDEV environment. ```bash cd mautic ddev start ``` -------------------------------- ### Run Mautic Command-Line Installation Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/development-environment/setup.md Execute this bash command to initiate the Mautic installation process via the command line, specifying the installation URL. ```bash php bin/console mautic:install https://mautic.example.com ``` -------------------------------- ### Get User API Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/users.md Provides an example of a successful JSON response when retrieving user details. It includes various properties of the user object. ```json { "user": { "isPublished": true, "dateAdded": "2026-02-21T05:19:56+00:00", "dateModified": "2026-02-21T05:20:13+00:00", "createdBy": 1, "createdByUser": "Admin Mautic", "modifiedBy": 1, "modifiedByUser": "Admin Mautic", "id": 3, "username": "r.green", "firstName": "Rachel", "lastName": "Green", "email": "rachel.green@acme.com", "position": "Marketing Staff", "role": { "createdByUser": "Admin Mautic", "modifiedByUser": null, "id": 2, "name": "Email Permissions", "description": null, "isAdmin": false, "rawPermissions": { "email:categories": [ "full" ], "email:emails": [ "full" ] } }, "timezone": "Europe/Paris", "locale": null, "lastLogin": "2026-02-22T04:28:00+00:00", "lastActive": "2026-02-22T04:28:00+00:00", "signature": "Best regards, \r\nRachel Green" } } ``` -------------------------------- ### Plugin Database Migration Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugins/installation.md Example of a Mautic plugin migration file. The `isApplicable` method checks if the migration needs to run, and the `up` method defines the SQL schema changes. ```php getTable($this->concatPrefix($this->table))->hasColumn('is_enabled'); } catch (SchemaException $e) { return false; } } protected function up(): void { $this->addSql("ALTER TABLE `{$this->concatPrefix($this->table)}` ADD `is_enabled` tinyint(1) 0"); $this->addSql("CREATE INDEX {$this->concatPrefix('is_enabled')} ON {$this->concatPrefix($this->table)}(is_enabled);"); } } ``` -------------------------------- ### Get Stage Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/stages.md Example JSON response when successfully retrieving an individual Stage. This includes properties like publication status, dates, creator, and stage-specific details. ```json { "stage": { "isPublished": true, "dateAdded": "2026-02-13T16:11:07+00:00", "dateModified": null, "createdBy": 1, "createdByUser": "John Doe", "modifiedBy": 1, "modifiedByUser": "John Doe", "id": 7, "name": "Stage A", "category": null, "weight": 0, "description": "This is my first stage created via API.", "publishUp": "2026-02-13T17:00:00+00:00", "publishDown": "2026-02-20T17:00:00+00:00" } } ``` -------------------------------- ### List Assets Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/assets.md An example of the JSON response when listing assets. It includes total count and an array of asset objects. ```json { "total": 1, "assets": [ { "id": 1, "title": "Product Whitepaper", "description": "Some description", "alias": "whitepaper", "language": "en", "isPublished": true, "publishUp": "2015-06-07T06:28:27+00:00", "publishDown": "2015-06-30T06:28:27+00:00", "dateAdded": "2015-06-07T06:28:27+00:00", "createdBy": 1, "createdByUser": "Wayne Costa", "dateModified": "2015-06-010T09:30:47+00:00", "modifiedBy": 1, "modifiedByUser": "Wayne Costa", "downloadCount": 10, "uniqueDownloadCount": 8, "revision": 1, "category": null, "extension": "pdf", "mime": "application/pdf", "size": 269128, "downloadUrl": "https://example.com/asset/1:whitepaper" } ] } ``` -------------------------------- ### HTTP Request Examples for Reports Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/reports.md Examples of HTTP GET requests to retrieve report data. Demonstrates fetching a report by ID and specifying query parameters for filtering and pagination. ```http GET /reports/ID ``` ```http GET /reports/3?dateFrom=2017-01-01&dateTo=2018-01-01&limit=5&page=3 ``` -------------------------------- ### Get Tag Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/tags.md Example JSON response when successfully retrieving an individual Tag. It includes the tag's ID, name, and description. ```json { "tag": { "id": 34, "tag": "tagA", "description": "A tag for grouping contacts" } } ``` -------------------------------- ### Lead Event Subscriber Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugins/event_listeners.md This example demonstrates how to create an event subscriber to listen for lead-related events like post-save and post-delete. Ensure the subscriber class is correctly namespaced and implements `EventSubscriberInterface`. ```php ['onLeadPostSave', 0], LeadEvents::LEAD_POST_DELETE => ['onLeadDelete', 0], ]; } public function onLeadPostSave(LeadEvent $event): void { $lead = $event->getLead(); // do something } public function onLeadDelete(LeadEvent $event): void { $lead = $event->getLead(); $deletedId = $lead->deletedId; // do something } } // ... ``` -------------------------------- ### Example Acceptance Test Class Structure Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/testing/e2e_test_suite.md Defines the basic structure of an acceptance test class in Codeception. Includes setup and teardown methods, and a sample test scenario for login. ```PHP amOnPage('/s/login'); $I->fillField('#username', $name); $I->fillField('#password', $password); $I->click('button[type=submit]'); $I->see('Dashboard'); } } ``` -------------------------------- ### List All Installed Themes Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/themes.md Retrieves a list of all installed themes, including details from their respective `config.json` files. ```php getList(); ``` -------------------------------- ### Set Temporary File Path Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/themes.md Example JSON response after successfully changing the temporary file path. It confirms the new path and indicates a ZIP file within it. ```json { "file": "/absolute/path/to/a/different/temp/dir/zipfile" } ``` -------------------------------- ### Complete Accordion Component Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/design_templates/accordion.md A comprehensive example demonstrating the integration of the Accordion Component, including defining content with a set block and including the component with specific item configurations. ```twig {% set utmTagsContent %} {% for i, utmTag in form.utmTags %} {{ form_row(utmTag) }} {% endfor %} {% endset %} {% include '@MauticCore/Helper/accordion.html.twig' with { 'items': [ { 'id': 'UTM', 'title': 'mautic.email.utm_tags', 'padding_inline': false, 'content': utmTagsContent, } ] } %} ``` -------------------------------- ### FormController Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugins/mvc.md Demonstrates extending Mautic's FormController to create custom actions for managing forms and handling user input. Includes examples for retrieving data, creating forms, and processing submissions. ```php getWorldDetails($world); return $this->delegateView( [ 'viewParameters' => [ 'world' => $world, 'details' => $worldDetails ], 'contentTemplate' => 'HelloWorldBundle:World:details.html.php', 'passthroughVars' => [ 'activeLink' => 'plugin_helloworld_world', 'route' => $this->generateUrl('plugin_helloworld_world', ['world' => $world]), 'mauticContent' => 'helloWorldDetails' ] ] ); } public function contactAction(ContactModel $model): Response { // Create the form object $form = $this->formFactory->create(ContactFormType::class); // Handle form submission if POST if ($this->request->getMethod() == 'POST') { $flashes = []; // isFormCancelled() checks if the cancel button was clicked if ($cancelled = $this->isFormCancelled($form)) { // isFormValid() will bind the request to the form object and validate the data if ($valid = $this->isFormValid($form)) { // Send the email $model->sendContactEmail($form->getData()); // Set success flash message $flashes[] = [ 'type' => 'notice', 'msg' => 'plugin.helloworld.notice.thank_you', 'msgVars' => [ '%name%' => $form['name']->getData() ] ]; } } if ($cancelled || $valid) { // Redirect to /hello/world return $this->postActionRedirect( [ 'returnUrl' => $this->generateUrl('plugin_helloworld_world'), 'contentTemplate' => 'MauticPlugin\HelloWorldBundle\Controller\DefaultController:worldAction', 'flashes' => $flashes ] ); } // Otherwise show the form again with validation error messages } // Display the form return $this->delegateView( [ 'viewParameters' => [ 'form' => $form->createView() ), 'contentTemplate' => '@HelloWorld/Contact/form.html.twig', 'passthroughVars' => [ 'activeLink' => 'plugin_helloworld_contact', 'route' => $this->generateUrl('plugin_helloworld_contact') ] ] ); } } ``` -------------------------------- ### Plugin Install and Update Event Listener Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugins/installation.md Implement this listener to react to plugin installation and update events. Available since Mautic 4.2.0. ```php ['onPluginInstall', 0], PluginEvents::ON_PLUGIN_UPDATE => ['onPluginUpdate', 0], ]; } public function onPluginInstall(PluginInstallEvent $event) { // Handle your logic here } public function onPluginUpdate(PluginUpdateEvent $event) { // Handle your logic here } } ``` -------------------------------- ### List Notifications Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/notifications.md An example of the JSON response when listing notifications. It includes total count and an array of notification objects. ```json { "total":1, "notifications":[ { "isPublished":true, "dateAdded":"2016-09-14T14:03:05+00:00", "createdBy":1, "createdByUser":"John Doe", "dateModified":"2016-09-15T08:40:46+00:00", "modifiedBy":1, "modifiedByUser":"John Doe", "id":1, "name":"The first notification", "heading":"The first notification Heading", "message":"The first notification Message", "url":"http:\/\/mautic.org", "language":"en", "category":null, "publishUp":null, "publishDown":null, "readCount":0, "sentCount":0 } ] } ``` -------------------------------- ### List Themes Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/themes.md Lists all installed Themes along with details extracted from their `config.json` files. ```APIDOC ## List Themes ### Description Lists all installed Themes with details from their `config.json` files. ### Method GET ### Endpoint `/themes` ### Response #### Success Response (200) - **themes** (object) - A dictionary where keys are theme keys and values are theme objects. #### Theme object properties - **name** (string) - Display name of the Theme. - **key** (string) - Directory name and unique identifier of the Theme. - **config** (object) - Theme configuration from `config.json`. #### Config object properties - **name** (string) - Theme name. - **author** (string) - Theme author. - **authorUrl** (string) - Author’s website URL. - **features** (array) - List of supported features such as `page`, `email`, or `form`. - **builder** (array) - Optional list of compatible builders such as `legacy` or `grapeJs`. ### Response Example ```json { "themes": { "blank": { "name": "Blank", "key": "blank", "config": { "name": "Blank", "author": "Mautic team", "authorUrl": "https://mautic.org", "features": [ "page", "email", "form" ] } } } } ``` ``` -------------------------------- ### List Themes HTTP Request Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/themes.md This is the HTTP request format for listing all installed themes. ```http GET /themes ``` -------------------------------- ### Configure OAuth2 Credentials and Initiate Token Process Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugin_integrations/integrations_authentication.md This example demonstrates how to retrieve integration configuration, generate a redirect URI, and set up the necessary credentials for OAuth2 authentication. It prepares the client for the token exchange process using the authorization code. ```php getIntegration(HelloWorldIntegration::NAME); /** @var Router $router */ $redirectUrl = $router->generate('mautic_integration_public_callback', ['integration' => HelloWorldIntegration::NAME]); $configuration = $integration->getIntegrationConfiguration(); $apiKeys = $configuration->getApiKeys(); /** @var Request $request */ $code = $request->get('code'); $credentials = new class( 'https://example.com/api/oauth/authorize', 'https://example.com/api/oauth/token', $redirectUrl, 'scope1,scope2', $apiKeys['client_id'], $apiKeys['client_secret'], $code ) implements CredentialsInterface, RedirectUriInterface, ScopeInterface, CodeInterface { private $authorizeUrl; private $tokenUrl; private $redirectUrl; private $scope; private $clientId; private $clientSecret; private $code; public function __construct(string $authorizeUrl, string $tokenUrl, string $redirectUrl, string $scope, string $clientId, string $clientSecret, ?string $code) { $this->authorizeUrl = $authorizeUrl; $this->tokenUrl = $tokenUrl; $this->redirectUrl = $redirectUrl; $this->scope = $scope; $this->clientId = $clientId; $this->clientSecret = $clientSecret; $this->code = $code; } public function getAuthorizationUrl(): string { return $this->authorizeUrl; } public function getTokenUrl(): string { return $this->tokenUrl; } public function getRedirectUri(): string { return $this->redirectUrl; } public function getClientId(): ?string { return $this->clientId; } public function getClientSecret(): ?string { return $this->clientSecret; } public function getScope(): ?string { ``` -------------------------------- ### Implement AuthenticationInterface for Hello World Integration Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugin_integrations/integrations_authentication.md Provides the full implementation of the AuthenticationInterface for a sample 'Hello World' integration. It includes methods to check authentication status and handle the authentication process by obtaining an access token. ```php client = $client; } public function getName(): string { return HelloWorldIntegration::NAME; } public function getDisplayName(): string { return 'Hello World'; } /** * Returns true if the integration has already been authorized with the third party service. * * @return bool */ public function isAuthenticated(): bool { $apiKeys = $this->getIntegrationConfiguration()->getApiKeys(); return !empty($apiKeys['access_token']) && !empty($apiKeys['refresh_token']); } /** * Authenticate and obtain the access token * * @param Request $request * * @return string */ public function authenticateIntegration(Request $request): string { $code = $request->query->get('code'); $this->client->authenticate($code); return 'Success!'; } } ``` -------------------------------- ### Get User HTTP Request Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/users.md Illustrates the HTTP GET request format for retrieving a specific user by their ID. The endpoint is /users/ID. ```http GET /users/ID ``` -------------------------------- ### Combining Flex Utilities Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/design/utilities.md This example demonstrates combining multiple flex utilities to create a responsive and centered layout. It sets up a flex container that behaves as a column on small screens and a row on medium screens and up, with wrapping, centering, and a fixed gap between items. ```html
``` -------------------------------- ### Include List Toolbar with Quick Filters Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/design/quick_filters.md This example shows how to include the 'list_toolbar.html.twig' template and pass an array of quick filter definitions. Ensure the 'quickFilters' key is present in the passed options. ```twig {{ include('@MauticCore/Helper/list_toolbar.html.twig', { 'searchValue': searchValue, 'searchHelp': 'mautic.form.form.help.searchcommands', 'searchId': 'list-search', 'action': currentRoute, 'quickFilters': [ { 'search': 'has:results', 'label': 'mautic.core.search.quickfilter.form_results', 'tooltip': 'mautic.core.search.quickfilter.form_results.tooltip', 'icon': 'ri-file-list-2-line' } ] }) }} ``` -------------------------------- ### Client Credentials Grant Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugin_integrations/integrations_authentication.md Demonstrates the client credentials grant for a service requiring a scope. Assumes token persistence is configured for a one-hour token validity. ```php getIntegration(HelloWorldIntegration::NAME); $configuration = $integration->getIntegrationConfiguration(); $apiKeys = $configuration->getApiKeys(); $credentials = new class( 'https://example.com/api/oauth/token', 'scope1,scope2', $apiKeys['client_id'], $apiKeys['client_secret'] ) implements ClientCredentialsGrantInterface, ScopeInterface { private $authorizeUrl; private $scope; private $clientId; private $clientSecret; public function getAuthorizationUrl(): string { return $this->authorizeUrl; } public function getClientId(): ?string { return $this->clientId; } public function getClientSecret(): ?string { return $this->clientSecret; } public function getScope(): ?string { return $this->scope; } }; /** @var $tokenPersistenceFactory TokenPersistenceFactory */ $tokenPersistence = $tokenPersistenceFactory->create($integration); $config = new class($tokenPersistence) implements ConfigTokenPersistenceInterface { private $tokenPersistence; public function __construct(TokenPersistenceInterface$tokenPersistence) { $this->tokenPersistence = $tokenPersistence; } public function getTokenPersistence(): TokenPersistenceInterface { return $this->tokenPersistence; } }; /** @var $factory HttpFactory */ $client = $factory->getClient($credentials, $config); $response = $client->get('https://example.com/api/fetch'); ``` -------------------------------- ### Get Form Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/forms.md This JSON structure represents a successful response when retrieving a specific form. It includes details about the form's properties, creator, and cached HTML. ```json { "form": { "isPublished": true, "dateAdded": "2026-02-19T07:06:12+00:00", "dateModified": "2026-02-19T07:10:06+00:00", "createdBy": 1, "createdByUser": "Admin Mautic", "modifiedBy": 1, "modifiedByUser": "Admin Mautic", "id": 2, "name": "Acme Global Conference Registration", "alias": "acme_globa", "category": { "createdByUser": "Admin Mautic", "modifiedByUser": null, "id": 1, "title": "Company attendees", "alias": "company-attendees", "description": null, "color": null, "bundle": "form" }, "description": "

Acme Global Conference registration.

", "cachedHtml": "\n\n\n\n
newAuth($settings); $apiUrl = "https://example.com"; $api = new MauticApi(); $assetApi = $api->newApi("assets", $auth, $apiUrl); // Get Contact field context: $fieldApi = $api->newApi("contactFields", $auth, $apiUrl); // Or use 'companyFields' for company fields: $fieldApi = $api->newApi("companyFields", $auth, $apiUrl); ``` -------------------------------- ### Basic services.php Configuration for Autowiring Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugins/autowiring.md This snippet demonstrates a basic `services.php` file structure for a Mautic plugin. It enables autowiring and autoconfiguration for services within the plugin's namespace and excludes specified directories. ```php services() ->defaults() ->autowire() ->autoconfigure() ->public(); $excludes = [ 'SomeDirectoryYouWantToExclude', ]; $services->load('MauticPlugin\[YourPluginName]Bundle\', '../') ->exclude('../{'.implode(',', array_merge(MauticCoreExtension::DEFAULT_EXCLUDES, $excludes)).'}'); }; ``` -------------------------------- ### Behavior Action Filter Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/segments.md Filter leads based on their behavior actions, specifically by checking if a URL title starts with a given string using the 'startsWith' operator. This is useful for segmenting users who interacted with specific content. ```json { "glue": "and", "field": "url_title", "object": "behaviors", "type": "text", "operator": "startsWith", "properties": { "filter": "acme" } } ``` -------------------------------- ### cURL Example with Query Parameters Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/stats.md Demonstrates how to make a GET request to the Stats API using cURL, including how to properly encode array parameters like 'where' for the query string. This is useful for command-line data retrieval. ```bash curl "https://example.com/api/stats/asset_downloads?where%5B0%5D%5Bcol%5D=id&where%5B0%5D%5Bexpr%5D=eq&where%5B0%5D%5Bval%5D=3" ``` -------------------------------- ### Form Validation Start Hook: onValidateStart() Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/form_hooks/validation_hooks.md The onValidateStart hook is called at the very beginning of the default form validation process. This hook is useful for performing any setup or initial checks before validation commences. It is not called if an onValidate hook returns TRUE. ```javascript MauticFormCallback['formname'] = { onValidateStart: function () { // do some custom stuff }, }; ``` -------------------------------- ### Build Test Dependencies Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/testing/e2e_test_suite.md Build the necessary test dependencies for the Codeception framework. This command prepares the testing environment. ```bash bin/codecept build ``` -------------------------------- ### Initiate Sync Engine Command Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/plugin_integrations/integrations_sync.md Use this command to start the bidirectional sync process between Mautic and an integration. Specify the integration name and the date range for the sync. ```bash php bin/console mautic:integrations:sync HelloWorld --start-datetime="2020-01-01 00:00:00" --end-datetime="2020-01-02 00:00:00" ``` -------------------------------- ### Send Email Response Example Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/emails.md Example of a successful response when sending an email to segments. ```json { "success": 1, "sentCount": 1, "failedRecipients": 0 } ``` -------------------------------- ### Example Response for Listing Text Messages Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/text_messages.md An example of the JSON response when listing text messages. ```json { "total":1, "smses":[ { "isPublished":true, "dateAdded":"2016-09-14T12:14:45+00:00", "createdBy":1, "createdByUser":"Kevin Bulgarelli", "dateModified":null, "modifiedBy":null, "modifiedByUser":null, "id":1, "name":"Message A", "message":"Hello", "language":"en", "category":null, "publishUp":null, "publishDown":null, "sentCount":0 } ] } ``` -------------------------------- ### List Campaigns using PHP API Client Source: https://github.com/mautic/developer-documentation-new/blob/7.1/docs/rest_api/campaigns.md Demonstrates how to fetch a list of campaigns using the Mautic PHP API client. Ensure the API client is properly initialized before use. ```php getList($searchFilter, $start, $limit, $orderBy, $orderByDir, $publishedOnly, $minimal); ```