Integrate Ecommerce Stack Recipe

This recipe provides the general steps to integrate your ecommerce stack with Medusa.

Overview#

Integrating third-party systems, such as ERP or a CMS, into your ecommerce stack requires:

  • Establishing connections with the different systems based on each of their APIs.
  • Building flows that span across multiple systems.
  • Maintaining data consistency and syncing between your systems.

Medusa’s architecture and functionalities allow you to integrate third-party systems and build flows around them. It also provides error-handling mechanisms and webhook capabilities that prevent data inconsistency between your systems.


Integrate External System with a Module#

To integrate an external system, such as an ERP, into your Medusa application, create a module whose service has methods to connect to the external system.

Then, resolve the module's main service in other resources, such as API routes or workflows, to perform actions in the external system.

Create a Module
Learn how to create a module in Medusa.
Example: Create a module integrating an ERP system

Build Flows Across Systems#

With Medusa’s workflows, build flows with steps that perform actions across systems.

For example, you can create a workflow that creates a product in integrated systems like ERPs, WMSs, and CMSs.

Workflows can be executed from anywhere. So, taking the workflow described above, you can listen to the product.created event using a subscriber and execute the workflow whenever the event is triggered.

A flowchart of how the workflow is executed when the product.updated event is triggered

Workflows guarantee data consistency through their compensation feature. You can provide a compensation function to steps that roll back the actions of that step. Then, if an error occurs in any step, the actions of previous steps are rolled back using their compensation function.

Workflows
Learn more about Workflows and how to create them.
Example: Create products across systems with workflows

Create Webhook Listeners#

You can provide webhook listeners that your external systems call when their data is updated. This lets you synchronize data between your systems. To create webhook listeners, create an API route.

For example, suppose an administrator changes the product data in the ERP system. The system then sends a request to the webhook you define in your Medusa application, which updates the product data in the application.

Create an API Route
Learn how to create an API Route in Medusa.
Example: Create a webhook listener for ERP changes
Was this page helpful?
Edit this page