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.

This page covers the two ways Item Price records are pushed from ERPNext to Medusa: automatically when a price is saved, and on-demand via a bulk sync endpoint that catches any prices that were missed during initial import.

POST sync missing prices to Medusa

POST /api/method/medusa_integration.api.sync_missing_prices_to_medusa Identifies Website Items that have a medusa_id but whose Item Price records have no medusa_price_id, then creates Medusa price lists for them. Use this endpoint after a bulk item import to catch any prices that were not synced automatically.
This endpoint is open to unauthenticated callers (allow_guest=True). Restrict it at the network or firewall level if needed.
What it does
  1. Fetches all Website Items that have medusa_id set.
  2. Finds Standard Selling Item Price records for those items where customer is empty and medusa_price_id is not yet set.
  3. For each unsynced price, calls POST /admin/price-lists on the Medusa Admin API.
  4. Writes the returned prices[0].id back to the medusa_price_id field on the Item Price record.
No request body is required.

Response

This endpoint has no explicit return value. All work is performed as side effects — Item Price records are updated in place.
curl --request POST \
  --url 'https://your-erpnext.example.com/api/method/medusa_integration.api.sync_missing_prices_to_medusa'

Automatic price sync on Item Price save

Price records are also synced to Medusa whenever an Item Price document is saved in ERPNext. This is driven by the validate document event defined in hooks.py:
hooks.py
doc_events = {
    "Item Price": {
        "validate": "medusa_integration.api.create_medusa_price_list"
    },
    ...
}

Sync conditions

Only Item Prices that match all of the following criteria are pushed to Medusa:
  • price_list is Standard Selling
  • customer is empty (no customer-specific pricing)
  • The Website Item for the item_code has a medusa_variant_id

Price conversion

Medusa stores monetary amounts in the smallest currency unit (for example, baisa for OMR). The ERPNext price is converted with:
medusa_amount = int(price_list_rate × 1000)
So a price of 1.500 OMR becomes 1500 in Medusa.

Create vs. update

ConditionAction
medusa_id is not set on the Item PriceCalls POST /admin/price-lists to create a new price list; stores the returned ID in medusa_id and medusa_price_id.
medusa_id is already setCalls POST /admin/price-lists/{medusa_id} to update the existing price list in place.

Medusa payload

{
  "name": "Item web name",
  "description": "Standard Selling",
  "type": "override",
  "customer_groups": [],
  "status": "active",
  "starts_at": null,
  "ends_at": null,
  "prices": [
    {
      "amount": 1500,
      "variant_id": "variant_01ABCD...",
      "currency_code": "omr"
    }
  ]
}

GET get Medusa prices

GET /api/method/medusa_integration.api.get_medusa_prices Returns live ERPNext prices for a list of Medusa product or variant IDs, including customer-specific negotiated prices and a payment URL when a draft order is provided. See Quotations for full documentation on this endpoint.

Build docs developers (and LLMs) love