Skip to content
Closed
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
122 changes: 122 additions & 0 deletions docs/components/campaigns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -855,3 +855,125 @@
: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, expecially if you are working across many Mautic instances and domains.

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

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'expecially'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'expecially'?", "location": {"path": "docs/components/campaigns.rst", "range": {"start": {"line": 863, "column": 212}}}, "severity": "ERROR"}

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.

.. 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 (e.g. campaign)

Check failure on line 890 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": 890, "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 892 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": 892, "column": 70}}}, "severity": "ERROR"}
===================== ============================================================

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

Endpoint:
``GET 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.

Headers:

================= ===========================
Header Description
================= ===========================
``Authorization`` Bearer *<access_token>*
================= ===========================

Example Request (cURL):

.. code-block:: bash
curl --location 'https://{*your-mautic-domain*}/api/campaigns/export/{*<campaign_id>*}' \
--header 'Authorization: Bearer *<your_actual_access_token>*' \
--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.

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

View workflow job for this annotation

GitHub Actions / prose

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'Plugins' instead of 'plugins'. Raw Output: {"message": "[Vale.Terms] Use 'Plugins' instead of 'plugins'.", "location": {"path": "docs/components/campaigns.rst", "range": {"start": {"line": 930, "column": 19}}}, "severity": "ERROR"}
* 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:

.. 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 956 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": 956, "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 958 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": 958, "column": 70}}}, "severity": "ERROR"}
===================== ============================================================

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

Endpoint:
``POST https://{your-mautic-domain}/api/campaigns/import``

Headers:

================= ===================================
Header Description
================= ===================================
``Authorization`` Bearer *<access_token>*
``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