# How to switch from the Transactional API to the Profile API?

As part of the [migration from the Batch MEP to the CEP](https://doc.batch.com/getting-started/other/implementation-guides/how-to-get-ready-to-migrate-from-the-batch-mep-to-the-cep), you might want to switch from the [Transactional API](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/mep/transactional) (or its variant, the Partner API) to a more user-friendly option: sending custom events via the [Profile API](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/cep/profiles) and scheduling your Trigger Push Automations directly from the Automation Builder.

{% hint style="info" %}
This option is not applicable yet if you are targeting **Installation IDs** with the [Transactional API](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/mep/transactional). It will be available soon.
{% endhint %}

## Step-by-step

{% stepper %}
{% step %}

### Audit your current usage of the Transactional API

Establish the <mark style="background-color:yellow;">list of your running Transactional API calls</mark>. You can refer to the [Analytics > Notifications > Transactional](https://doc.batch.com/getting-started/features/mobile-engagement-platform/analytics/notifications#detailed-stats) tab on the Batch dashboard to get the list of messages sent via the Transactional API over a specific time period.
{% endstep %}

{% step %}

### \[Back-end] Prepare your calls to the Profile API

* Associate each Transactional message with a <mark style="background-color:yellow;">new Custom Event</mark>:
  * Event name: For consistency, you can use the "Group ID" of your current Transactional API call.
  * Additional data: If your transactional message contains personalization, associate the personalization values [as attributes of these events](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/cep/profiles/update#the-attributes-object).
* Get ready to <mark style="background-color:yellow;">send these events via the</mark> [<mark style="background-color:yellow;">Profile API</mark>](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/cep/profiles) each time you were calling the Transactional API.
  {% endstep %}

{% step %}

### \[Dashboard] Prepare your Trigger Automations

* [<mark style="background-color:yellow;">Create one trigger automation</mark>](https://doc.batch.com/getting-started/features/customer-engagement-platform/orchestration/trigger-automations) for each transactional message using the Batch Automation Builder. The trigger event must be the one defined in step 2.
* <mark style="background-color:yellow;">Activate</mark> these automations.
  {% endstep %}

{% step %}

### \[Back-end] Switch from the Transactional API to the Profile API

Once the automations are running on the dashboard, <mark style="background-color:yellow;">stop calling the Transactional API</mark> and <mark style="background-color:yellow;">start sending the custom events via the Profile API</mark> so that the automations created in step 3 are triggered.
{% endstep %}
{% endstepper %}

## Example: Order shipped 📦

Let's apply the above steps to an example:

{% stepper %}
{% step %}

### Audit your current usage of the Transactional API

You currently notify clients when their order has been shipped. To do so, you call the [Transactional API](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/mep/transactional) with a payload that looks like this:

<pre class="language-json"><code class="lang-json">{
	"group_id": "order_shipped",
	"recipients": {
		"custom_ids": ["<a data-footnote-ref href="#user-content-fn-1">129c7819-9c88-496e-9a5f-62db34a3ce61</a>"]
	},
	"message": {
		"title": "📦 Your order <a data-footnote-ref href="#user-content-fn-2">BC257637</a> has been shipped!",
		"body": "Click here to keep track of your parcel"
	},
	"deeplink" : "<a data-footnote-ref href="#user-content-fn-3">https://wwww.mybrand.com/BC257637</a>"
}
</code></pre>

{% endstep %}

{% step %}

### \[Back-end] Prepare your calls to the Profile API

* You prepare your calls to the Profile API by associating your transactional message with a new Custom Event:
  * Event name: You choose to call it `order_shipped`, just as the group ID of your call to the [Transactional API](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/mep/transactional).
  * Additional data: For personalization purposes, this use case requires the order ID and the parcel tracking link. So you add 2 [attributes](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/cep/profiles/update#the-attributes-object) to the new event: `id` (String) and `parcel_tracking_link` (URL).
* Here is how the payload you will include in your [Profile API](https://app.gitbook.com/s/CL8wF0y1T2vLnm3yR2MW/api/cep/profiles) call will look like:

<pre class="language-json"><code class="lang-json">[
    {
        "identifiers": {
            "custom_id": "<a data-footnote-ref href="#user-content-fn-1">129c7819-9c88-496e-9a5f-62db34a3ce61</a>"
        },
        "events": [
            {
                "name": "order_shipped",
                "attributes": {
                    "id": "<a data-footnote-ref href="#user-content-fn-2">BC257637</a>",
                    "url(parcel_tracking_link)": "<a data-footnote-ref href="#user-content-fn-3">https://wwww.mybrand.com/BC257637</a>"
                }
            }
        ]
    }
]
</code></pre>

{% endstep %}

{% step %}

### \[Dashboard] Prepare your Trigger Automations

* You [create a dedicated trigger automation](https://doc.batch.com/getting-started/features/customer-engagement-platform/orchestration/trigger-automations) for this use case:

<figure><img src="https://1464139620-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUIK868wiiK9XOVyETGZS%2Fuploads%2FuTLTZxDzMDPGU43JorWG%2FScreenshot%202025-09-03%20at%2012.10.12.png?alt=media&#x26;token=d3441a0d-5c41-4149-82c9-2c126f109689" alt="A screenshot of the Batch dashboard, in the automation builder section, that shows a push notification &#x22;order shipped&#x22;"><figcaption></figcaption></figure>

You add the personalization values from the trigger event `order_shipped` in the title (`id`) and the deeplink (`parcel_tracking_link`) fields of your message, using the **{...}** buttons:

<figure><img src="https://1464139620-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUIK868wiiK9XOVyETGZS%2Fuploads%2FX3MNUHFIFKVKnYRM4jtP%2FScreenshot%202025-09-03%20at%2012.15.31.png?alt=media&#x26;token=79d6b39c-3056-41f9-a759-2bddbe7d1133" alt="A screenshot of the Batch dashboard, in the automation builder section, that shows the details of a push notification &#x22;order shipped&#x22;"><figcaption></figcaption></figure>

* Then you <mark style="background-color:yellow;">activate</mark> this automation ("Run" button).
  {% endstep %}

{% step %}

### \[Back-end] Switch from the Transactional API to the Profile API

Now that the automation is running on the dashboard, you stop calling the Transactional API and start sending the custom event `order_shipped` via the Profile API so that the automation created in step 3 is triggered.
{% endstep %}
{% endstepper %}

[^1]: Custom User ID

[^2]: Order ID

[^3]: Parcel tracking link
