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 the full quotation lifecycle between Medusa and ERPNext. They cover creating a Quotation from a Medusa draft order, updating approval status, refreshing item lists, generating PDF URLs, and fetching real-time prices for cart items. All endpoints are guest-accessible.

Create quotation

POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.create_quotation
Creates an ERPNext Quotation from a Medusa draft order. The customer is resolved by customer_id — first against the Customer doctype, then against Leads. If the party is a Lead and create_so is true, the Lead is automatically converted to a Customer before the quotation is saved. A billing address is created or updated if provided.
Taxes are applied from item tax templates automatically. Only templates associated with the configured company are included.

Request body

customer_id
string
required
Medusa customer ID. Must match a Customer or Lead with a medusa_id field in ERPNext.
draft_order_id
string
required
Medusa draft order ID. Stored as medusa_draft_order_id on the Quotation.
quotation_id
string
required
Medusa quotation ID. Stored as medusa_quotation_id on the Quotation.
items
object[]
required
Line items to add to the quotation.
billing_address
object
Billing address to create or update for the customer.
create_so
boolean
default:"false"
When true and the party is a Lead, converts the Lead to a Customer before saving the quotation.

Response fields

message
string
"Quotation created successfully" on success.
quotationId
string
The ERPNext name (ID) of the created Quotation.

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.create_quotation" \
  --header "Content-Type: application/json" \
  --data '{
    "customer_id": "cus_01HXYZ",
    "draft_order_id": "dor_01ABC",
    "quotation_id": "quot_01ABC",
    "items": [
      { "variant_id": "var_01DEF", "quantity": 2 }
    ],
    "billing_address": {
      "address_1": "123 Main Street",
      "city": "Muscat",
      "country_code": "om",
      "postal_code": "100",
      "is_default": true
    },
    "create_so": false
  }'

Update quotation

POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.update_quotation
Updates the workflow state of a Quotation to "Approved" or "Rejected". When approved with create_so: true, a Sales Order and Payment Request are automatically created and the payment URL is returned.
Approval submits the Quotation. Rejection submits and then cancels it. Both actions are irreversible through this endpoint.

Request body

quotation_id
string
required
Medusa quotation ID (stored as medusa_quotation_id on the ERPNext Quotation).
approval
string
required
Approval decision. Accepted values: "Approved" or "Rejected".
order_id
string
Medusa order ID. Stored as medusa_order_id on the Quotation when approved.
create_so
boolean
default:"false"
When true and approval is "Approved", creates a Sales Order from the Quotation and generates a Payment Request.
is_courier_required
boolean
When create_so is true, sets custom_is_courier_required on the Sales Order.
location_and_contact_no
string
Delivery location and contact number. Set as custom_location_and_contact_no on the Sales Order when create_so is true.

Response fields

When approval: "Approved" and create_so: true:
message
string
"Quotation updated successfully, Sales Order created & Payment URL generated"
quotation_id
string
ERPNext Quotation name.
sales_order_id
string
ERPNext Sales Order name.
payment_id
string
ERPNext Payment Request name.
payment_url
string
Payment gateway URL for the customer to complete payment.
Otherwise:
message
string
"Quotation updated successfully"
Quotation ID
string
ERPNext Quotation name.

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.update_quotation" \
  --header "Content-Type: application/json" \
  --data '{
    "quotation_id": "quot_01ABC",
    "approval": "Approved",
    "order_id": "ord_01XYZ",
    "create_so": true,
    "is_courier_required": true,
    "location_and_contact_no": "Muscat, +968 91234567"
  }'

Update quotation (new items)

POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.update_quotation_new
Replaces the full item list on an existing Quotation. Also sets the unapproved items and increased items tables, and applies delivery charges for non-Muscat addresses. Triggers the quotation export to Medusa after saving.

Request body

quotation_id
string
required
Medusa quotation ID (medusa_quotation_id on the ERPNext Quotation).
items
object[]
required
Replacement item list for the quotation.
unapproved_items
object[]
Items that were not approved, stored in the unapproved_items child table.
increased_items
object[]
Items whose quantities were increased, stored in the custom_increased_items table.
billing_address
object
required
Billing address used to determine delivery charges. If the city is not Muscat, a delivery charge is appended to the taxes table.

Response fields

message
string
"Quotation updated successfully"
Quotation ID
string
ERPNext Quotation name.

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.update_quotation_new" \
  --header "Content-Type: application/json" \
  --data '{
    "quotation_id": "quot_01ABC",
    "items": [
      { "variant_id": "var_01DEF", "quantity": 2, "rate": 12.5, "amount": 25.0 }
    ],
    "unapproved_items": [],
    "increased_items": [],
    "billing_address": { "city": "Salalah" }
  }'

Fetch quotation PDF URL

POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.fetch_quotation_pdf_url
Returns a print URL for a Quotation using the configured print format. The URL points to ERPNext’s printview and renders the quotation as a PDF in the browser.

Request body

quotation_id
string
required
ERPNext Quotation name (e.g. "QTN-2024-00001").

Response

Returns a plain string URL on success:
https://erp.example.com/printview?doctype=Quotation&name=QTN-2024-00001&format=Alfarsi%20Quote%20Print&no_letterhead=0&_lang=en
Returns an error object if the quotation is not found:
{
  "error": "Quotation with ID QTN-2024-00001 not found."
}

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.fetch_quotation_pdf_url" \
  --header "Content-Type: application/json" \
  --data '{"quotation_id": "QTN-2024-00001"}'

Get Medusa prices

GET / POST Guest
POST https://<erpnext-site>/api/method/medusa_integration.api.get_medusa_prices
Returns the standard and negotiated prices for a list of Medusa product or variant IDs. Each item is resolved to an ERPNext item code via the Website Item. When a draft_order_id is provided, the associated Payment Request URL is also returned.
Prices are suppressed (returned as 0) if they exceed the configured price_visibility_threshold from the Homepage Landing settings.

Request body

items
object[]
required
List of products to price.
price_list
string
ERPNext price list name. Defaults to the customer’s default price list if not specified.
customer_id
string
Medusa customer ID. Used to resolve negotiated prices from the customer’s specific price list entries.
draft_order_id
string
Medusa draft order ID. When provided, the response is wrapped to include the associated payment URL.

Response fields

Without draft_order_id: a dictionary keyed by medusa_product_id or medusa_variant_id.
<medusa_id>
object
Price entry for the given Medusa ID.
With draft_order_id:
prices
object
Same per-item dictionary as above.
payment_url
string | null
Payment URL from the Payment Request linked to the Sales Order for this draft order, or null if none.

Example

curl --request POST \
  --url "https://erp.example.com/api/method/medusa_integration.api.get_medusa_prices" \
  --header "Content-Type: application/json" \
  --data '{
    "items": [
      { "medusa_product_id": "prod_01ABC" },
      { "medusa_variant_id": "var_01DEF" }
    ],
    "customer_id": "cus_01HXYZ"
  }'

Build docs developers (and LLMs) love