Twig Templates API
Use the Mautic API to manage your Twig Templates for advanced personalization.
The Twig Templates plugin extends the Mautic API, allowing you to manage your custom templates programmatically. This is useful for automation, integration with other systems, or bulk operations.
Ensure you have enabled and configured API access in your Mautic settings and have the necessary permissions for twigtemplates
.
Get List of Twig Templates
Retrieves a collection of all configured Twig Templates.
Successful Response (Example)
Get a Specific Twig Template
Fetches the details of a single Twig Template using its unique ID.
Path Parameters
{templateId}
(integer, required): The ID of the Twig Template you want to retrieve.
Successful Response (Example)
Create a Twig Template
Allows you to add a new Twig Template to your Mautic instance.
Request Body Parameters
name
(string, required): The name for the new template.template
(string, required): The Twig code for the template.description
(string, optional): A brief description of the template’s purpose.
Example Request Body
Successful Response
Returns the newly created Twig Template object, similar to the response for GET /api/twigTemplates/{templateId}
.
Edit a Twig Template
Updates an existing Twig Template identified by its ID. You only need to send the fields you want to change.
Path Parameters
{templateId}
(integer, required): The ID of the Twig Template to edit.
Request Body Parameters
name
(string, optional): The updated name for the template.template
(string, optional): The updated Twig code.description
(string, optional): The updated description.
Example Request Body (Updating only the template code)
The documentation states that if the template doesn’t exist, it might create a new one. Please verify this behavior in your Mautic version.
Successful Response Returns the updated Twig Template object.
Delete a Twig Template
Permanently removes a Twig Template from Mautic based on its ID.
Path Parameters
{templateId}
(integer, required): The ID of the Twig Template to delete.
Successful Response Typically returns a success status code (e.g., 200 OK or 204 No Content) and potentially a confirmation message in the response body.