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 manage customer data between ERPNext and the Medusa storefront. They cover finding ERPNext customers not yet linked to Medusa, updating billing addresses, and linking an existing Customer to a Medusa Lead. Two endpoints are guest-accessible; the lead-linking endpoint requires authentication.

Fetch all customers

GET Guest
GET https://<erpnext-site>/api/method/medusa_integration.api.fetch_all_customers
Returns ERPNext Customer records that do not yet have a medusa_id set. Optionally filters by customer name to support typeahead search. Intended for customer import and linking workflows in the admin panel.

Request parameters

name
string
Search string. Each whitespace-separated word is matched as a LIKE '%word%' condition against customer_name. All words must match.

Response

Returns an array of customer objects on success, or the string "No relevant customers found" when there are no results.
name
string
ERPNext internal document name (customer ID).
customer_name
string
Display name of the customer.
email_id
string
Customer email address.
mobile_no
string
Customer mobile number.

Example

curl "https://erp.example.com/api/method/medusa_integration.api.fetch_all_customers?name=Al+Farsi"

Update address

POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.update_address
Updates the billing address fields for a customer. The address is looked up via the Dynamic Link table — the first address linked to the given customer_id is updated. Only fields present in the request body are modified.

Request body

customer_id
string
required
ERPNext Customer document name (e.g. "CUST-00042").
address_line1
string
Primary street address.
address_line2
string
Secondary address line.
city
string
City.
state
string
State or emirate.
country
string
Country name as it appears in ERPNext (e.g. "Oman").
pincode
string
Postal or ZIP code.

Response

Returns the string "Address updated successfully" on success. Returns an error object on failure.
{ "error": "No address found for customer ID 'CUST-00042'" }

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.update_address" \
  --header "Content-Type: application/json" \
  --data '{
    "customer_id": "CUST-00042",
    "address_line1": "456 New Street",
    "city": "Muscat",
    "country": "Oman",
    "pincode": "112"
  }'

GET Auth required
GET https://<erpnext-site>/api/method/medusa_integration.utils.link_medusa_lead
Links an existing ERPNext Customer to a Medusa Lead. The Lead’s medusa_id is copied to the Customer and the Lead is set as the lead_name on the Customer record.
This endpoint requires a valid Frappe session or API key. It is not accessible to guest users.

Validation

Before linking, the endpoint checks:
  1. The Lead exists in ERPNext.
  2. The Lead has a medusa_id set.
  3. The medusa_id is not already linked to a different Customer.
If any check fails, the request is rejected with a ValidationError.

Request parameters

customer
string
required
ERPNext Customer document name (e.g. "CUST-00042").
lead
string
required
ERPNext Lead document name (e.g. "CRM-LEAD-2024-00001").

Response fields

status
string
"success" when the link is established.

Example

curl "https://erp.example.com/api/method/medusa_integration.utils.link_medusa_lead?customer=CUST-00042&lead=CRM-LEAD-2024-00001" \
  --header "Authorization: token <api_key>:<api_secret>"

Build docs developers (and LLMs) love