Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/aerele/medusa_integration/llms.txt

Use this file to discover all available pages before exploring further.

These endpoints handle outbound synchronization from ERPNext to Medusa. The primary endpoint pushes Sales Order status and payment status back to the Medusa storefront. A secondary utility endpoint bulk-syncs item prices that were created before the Medusa price ID was recorded.
Both endpoints are decorated with @frappe.whitelist(allow_guest=True), but they are primarily invoked by ERPNext document event hooks rather than by the Medusa storefront directly.

Export sales order

POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.export_sales_order
Pushes the current status and payment status of an ERPNext Sales Order back to Medusa. Called automatically by the following document events:
  • Sales Order on_update — when from_ecommerce is set
  • Sales Invoice on_submit / on_update — propagates invoice status to the linked Sales Order
  • Delivery Note on_submit — propagates delivery status to the linked Sales Order
  • Payment Entry on_submit — propagates payment status through the linked Sales Invoice
The payment status is derived from the linked Sales Invoice status. If no submitted invoice exists, it defaults to "Unpaid".
This endpoint sends a POST request to {medusa_url}/store/order-update?order_id={medusa_order_id} on the Medusa server. The Sales Order must have a medusa_order_id field set for the sync to occur.

Request parameters

self
string
required
The ERPNext Sales Order document name (e.g. "SAL-ORD-2024-00001").

Payload sent to Medusa

The following fields are sent to the Medusa order-update endpoint:
FieldTypeDescription
customer_idstringMedusa customer ID from the linked Customer record
order_statusstringSales Order status ("Pending" if Draft, otherwise the ERPNext status)
payment_statusstringSales Invoice status, or "Unpaid" if no invoice exists
discount_amountnumberDiscount amount on the Sales Order
net_totalnumberNet total before taxes
grand_totalnumberGrand total including taxes

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.export_sales_order" \
  --header "Content-Type: application/json" \
  --data '{"self": "SAL-ORD-2024-00001"}'
If the Sales Order’s customer does not have a medusa_id set, this endpoint throws a validation error. Ensure all ecommerce customers have a linked Medusa ID before triggering this sync.

Sync missing prices to Medusa

POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.sync_missing_prices_to_medusa
Finds all Item Price records on the Standard Selling price list that are linked to published Website Items but do not yet have a medusa_price_id. For each, creates a new price list in Medusa and stores the returned price ID back on the Item Price record. This endpoint is useful during initial setup or after bulk-importing items to ensure all prices are reflected in Medusa.
No request body is required. The endpoint operates on the full set of qualifying Item Price records and may take significant time to complete for large catalogues. Consider running it during off-peak hours.

Sync criteria

An Item Price is synced if all of the following conditions are met:
  • The item_code is linked to a Website Item with a medusa_variant_id
  • The price list is "Standard Selling" with no customer-specific override
  • The Item Price does not yet have a medusa_price_id

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.sync_missing_prices_to_medusa" \
  --header "Content-Type: application/json"
The endpoint returns no response body on success. Check the Medusa Request Log in ERPNext for per-item sync results and any failures.

Build docs developers (and LLMs) love