Skip to content

Changes following review #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions docs/components/campaigns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -855,3 +855,118 @@
:param mixed $channelId: ID of the Channel entity.

:returntype: void


Exporting a campaign
********************

Mautic's export functionality provides campaign structures in formats that can be easily imported back into Mautic with the import feature. This helps ensure your marketing assets remain portable and preserved, especially if you are working across many Mautic instances and domains.

Mautic exports all data related to your campaign to a structured JSON file, complete with any files and assets required. The resulting files are archived to a zip file that is saved to your browser.

The export command can be called from the command line or via the API as well as in the Mautic UI.


Exporting via Command line
==========================

First, copy the campaign zip file into the correct place to be imported into Mautic. (The below assumes you have installed via Docker Compose and you are running Mautic locally. Use the appropriate file copying mechanism - for example SFTP or SCP - for your environment.)

.. code-block:: bash

docker cp ./campaign_data.zip ddev-mautic-web:/tmp/entity_data.zip

Then, run the import command:

.. code-block:: bash

bin/console mautic:entity:import --entity=campaign --file=/tmp/entity_data.zip --user=*{<user_id>}*

Options:

===================== ============================================================
Option Description
===================== ============================================================
``--entity=campaign`` Specifies the entity type being imported (for example, campaign)
``--file`` Path to the file you want to import (ZIP)
``--user=`` User ID to associate with the import process (for example, 1 (admin))
===================== ============================================================

Exporting via API
=================

Endpoint:
``POST https://{your-mautic-domain}/api/campaigns/export/{*<campaign_id>*}``

The final part of the URL, ``{*<campaign_id>*}``, specifies the ID of the campaign to be exported.

Please see `REST API Authentication <https://developer.mautic.org/?php#basic-authentication>`_ for authentication details.

Example Request (cURL):

.. code-block:: bash

curl --location 'https://{*your-mautic-domain*}/api/campaigns/export/{*<campaign_id>*}' \
--data ''

:download:`Example campaign JSON file <images/campaign-sample.json>`


Importing a campaign
********************

Mautic allows you to import campaigns using JSON files that were previously exported. This feature helps you transfer campaigns between Mautic instances.

During the import process, Mautic performs the following actions:

* Verifies that the importing user has the necessary permissions and access to all relevant entities.
* Checks if all Plugins and other dependencies required by the campaign are present in the current Mautic instance.
* Identifies any ID conflicts with existing entities. If conflicts are found, Mautic will prompt you to either update the existing entities or create new ones.
* Creates the campaign along with all its related entities to ensure it functions correctly after import.

You can trigger the import command from the command line or via API.

Importing via Command line
==========================

First, copy the campaign data ZIP file to your DDEV container or the appropriate location for your environment. (The below assumes you have installed using Docker Compose; you may require SFTP or SCP for your environment.):

.. code-block:: bash

docker cp ./campaign_data.zip ddev-mautic-web:/tmp/entity_data.zip

Then, run the import command:

.. code-block:: bash

ddev exec bin/console mautic:entity:import --entity=campaign --file=/tmp/entity_data.zip --user=*{<user_id>}*

Options:

===================== ============================================================
Option Description
===================== ============================================================
``--entity=campaign`` Specifies the entity type being imported (e.g. campaign)

Check failure on line 949 in docs/components/campaigns.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Latin] Use 'for example' instead of 'e.g.'. Raw Output: {"message": "[Google.Latin] Use 'for example' instead of 'e.g.'.", "location": {"path": "docs/components/campaigns.rst", "range": {"start": {"line": 949, "column": 66}}}, "severity": "ERROR"}
``--file`` Path to the file you want to import (ZIP)
``--user=`` User ID to associate with the import process (e.g. 1 (admin))

Check failure on line 951 in docs/components/campaigns.rst

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Google.Latin] Use 'for example' instead of 'e.g.'. Raw Output: {"message": "[Google.Latin] Use 'for example' instead of 'e.g.'.", "location": {"path": "docs/components/campaigns.rst", "range": {"start": {"line": 951, "column": 70}}}, "severity": "ERROR"}
===================== ============================================================

Importing via API
=================

Endpoint:
``POST https://{your-mautic-domain}/api/campaigns/import``
Refer to `REST API Authentication <https://developer.mautic.org/?php#basic-authentication>`_ for authentication details.

Headers:

================= ===================================
Header Description
================= ===================================
``Content-Type`` ``application/json`` or ``application/zip``
================= ===================================

Request Body:

* **If sending JSON data:** Provide the raw JSON payload directly in the request body.
* **If sending a ZIP file:** Upload the ZIP file using form-data.
Loading
Loading