Skip to main content

Usage

This page provides examples and API reference for using the Medusa.js integration.

API Endpoints Overview​

The Medusa.js integration exposes endpoints for Products, Orders, Carts, Checkout, Customers, and Payments. All endpoints follow the O2S framework API specification. For the full checkout flow, see Cart & Checkout.

Products API​

List Products​

Endpoint: GET /products

Query Parameters:

ParameterTypeDescriptionRequired
limitnumberNumber of products per pageNo
offsetnumberPagination offsetNo
typestringFilter by product typeNo
categorystringFilter by categoryNo
sortstringSort orderNo

Example:

GET /products?limit=20&offset=0
Authorization: Bearer {token}

Get Product​

Endpoint: GET /products/:id

Path Parameters:

ParameterTypeDescriptionRequired
idstringThe product IDYes

Example:

GET /products/prod_01ABC123
Authorization: Bearer {token}

Endpoint: GET /products/:id/variants/:variantId/related-products

Uses the Medusa Admin API (requires admin key). Returns products related to the given product variant.

Path Parameters:

ParameterTypeDescriptionRequired
idstringThe product IDYes
variantIdstringThe variant IDYes

Query Parameters:

ParameterTypeDescriptionRequired
typestringReference typeNo
limitnumberMax resultsNo
offsetnumberPagination offsetNo
sortstringSort orderNo

Example:

GET /products/prod_01ABC123/variants/var_01XYZ789/related-products
Authorization: Bearer {token}

Orders API​

List Orders​

Endpoint: GET /orders

Query Parameters:

ParameterTypeDescriptionRequired
limitnumberNumber of orders per pageNo
offsetnumberPagination offsetNo
statusstringFilter by order statusNo
paymentStatusstringFilter by payment statusNo
dateFromstringOrders from this date (ISO)No
dateTostringOrders until this date (ISO)No
sortstringSort orderNo

Example:

GET /orders?limit=20&status=completed
Authorization: Bearer {token}

Get Order​

Endpoint: GET /orders/:id

Path Parameters:

ParameterTypeDescriptionRequired
idstringThe order IDYes

Example:

GET /orders/order_01ABC123
Authorization: Bearer {token}

Carts API​

Create Cart​

Endpoint: POST /carts

Body:

FieldTypeDescriptionRequired
currencystringCurrency code (e.g., EUR, USD)Yes
regionIdstringMedusa region ID (required)Yes
metadataobjectOptional metadataNo

Example:

POST /carts
Content-Type: application/json

{
"currency": "EUR",
"regionId": "reg_01ABC123",
"metadata": {}
}

Get Cart​

Endpoint: GET /carts/:id

Path Parameters:

ParameterTypeDescriptionRequired
idstringThe cart IDYes

Example:

GET /carts/cart_01ABC123
Authorization: Bearer {token}

Update Cart​

Endpoint: PATCH /carts/:id

Body:

FieldTypeDescriptionRequired
regionIdstringMedusa region IDNo
emailstringEmail (for guest checkout)No
notesstringOrder notesNo
metadataobjectOptional metadataNo

Add Cart Item​

Endpoint: POST /carts/items

Body:

FieldTypeDescriptionRequired
cartIdstringExisting cart ID (omit to create new cart)No
skustringProduct variant SKUYes
variantIdstringMedusa variant ID — maps directly to Medusa variant_idYes (Medusa)
quantitynumberQuantityYes
currencystringRequired when creating new cartNo
regionIdstringRequired when creating new cartNo
metadataobjectOptional metadataNo

Example:

POST /carts/items
Content-Type: application/json

{
"cartId": "cart_01ABC123",
"sku": "var_01XYZ789",
"quantity": 2
}

Update Cart Item​

Endpoint: PATCH /carts/:cartId/items/:itemId

Remove Cart Item​

Endpoint: DELETE /carts/:cartId/items/:itemId

Apply Promotion​

Endpoint: POST /carts/:cartId/promotions

Body:

FieldTypeDescriptionRequired
codestringPromotion codeYes

Remove Promotion​

Endpoint: DELETE /carts/:cartId/promotions/:code

Checkout API​

For the full checkout flow, see Cart & Checkout.

MethodEndpointPurpose
POST/checkout/:cartId/addressesSet shipping and billing addresses
POST/checkout/:cartId/shipping-methodSelect shipping option
POST/checkout/:cartId/paymentCreate payment session
GET/checkout/:cartId/shipping-optionsList available shipping options
GET/checkout/:cartId/summaryGet checkout summary
POST/checkout/:cartId/place-orderCreate order from cart
POST/checkout/:cartId/completeOne-shot complete flow

Customers API​

Customer address management. All endpoints require authentication.

Base path: /customers/addresses

MethodEndpointPurpose
GET/customers/addressesList addresses
GET/customers/addresses/:idGet address
POST/customers/addressesCreate address
PATCH/customers/addresses/:idUpdate address
DELETE/customers/addresses/:idDelete address
POST/customers/addresses/:id/defaultSet default address

Payments API​

List Payment Providers​

Endpoint: GET /payments/providers

Query Parameters:

ParameterTypeDescriptionRequired
regionIdstringMedusa region IDYes

Example:

GET /payments/providers?regionId=reg_01ABC123
Authorization: Bearer {token}

Create Payment Session​

Endpoint: POST /payments/sessions

Body:

FieldTypeDescriptionRequired
cartIdstringCart IDYes
providerIdstringPayment provider ID from MedusaYes
returnUrlstringRedirect URL after paymentYes
cancelUrlstringRedirect URL if payment cancelledNo
metadataobjectOptional metadataNo

Example:

POST /payments/sessions
Content-Type: application/json
Authorization: Bearer {token}

{
"cartId": "cart_01ABC123",
"providerId": "pp_stripe",
"returnUrl": "https://example.com/checkout/success",
"cancelUrl": "https://example.com/checkout/cancel"
}

Note: The Medusa integration does not implement getSession, updateSession, or cancelSession due to SDK limitations. Use createSession and proceed to place order.

Authentication​

Store API operations (Products, Orders, Carts, Checkout, Customers, Payments) require SSO token authentication. Pass the JWT token in the Authorization header:

Authorization: Bearer {your_sso_token}

The integration forwards this token to Medusa. A custom SSO auth plugin must be deployed on your Medusa server to validate the token and map it to a Medusa customer. See How to set up.

Guest checkout: Cart creation and adding items can work without authentication. For checkout completion, provide an email (in addresses or place-order body).