Skip to main content
Skip to main content

B2B Recipe

This document guides you through the different documentation resources that will help you build a B2B store with Medusa.


In a B2B store, it’s essential to differentiate between customer types to provide them with relevant pricing, products, shopping experience, and more.

Medusa’s commerce features, including sales channels, customer groups, and price lists, facilitate implementing this setup. Medusa’s architecture and extendible nature allow you to customize your store based on your use case.

Build a B2B storeUtilize Medusa's features and customization capabilities to build a B2B store.
Create a B2B Sales Channel
Create a Publishable API Key
Add Wholesale Products
Create a B2B Customer Group
Add B2B Customers
Create B2B Price Lists
Create Custom Entities
Create an API Route to Check Customers
Customize Admin
Customize Storefront
Deploy the B2B store

Create B2B Sales Channel

In Medusa, a sales channel allows you to set product availability per channel. In this case, you can create a B2B sales channel that will include only B2B products.

You can create a sales channel through the Medusa Admin or Admin REST APIs.

Create a Publishable API Key

Publishable API keys can be associated with one or more sales channels. Then, in a client such as a storefront, you can pass the publishable API key in the header of your requests to ensure all products retrieved belong to the associated sales channel(s).

You can create a publishable API key through the Medusa Admin or the Admin REST APIs, then associate it with the B2B sales channel. You’ll later use this key when developing your B2B storefront.

Add Products

Using the Medusa Admin or the Admin REST APIs, you can add your B2B products to your store. You can also import your products from an existing CSV file using the Product Import feature.

After or while you add your products, set the products’ availability to the B2B sales channel you’ve created.

Create B2B Customer Groups

In B2B sales, you often negotiate special prices with each customer or company. So, you need to organize your B2B customers into groups that allow you to set different prices for each.

You can create a single B2B customer group that all your B2B customers will fall into or create different B2B customer groups for every B2B customer. The second approach is helpful if you apply different prices for each business.

While creating the customer groups, make sure to add to the metadata attribute of the customer group a key is_b2b that acts as a flag to indicate that this is a B2B customer group. This is useful for later steps.

For more advanced customer modeling, you may create custom entities. This is covered in the Create Custom Entity section.

Add B2B Customers

After adding your B2B customer group, you can add B2B customers and assign them to the B2B customer group. Alternatively, if you want to allow B2B customers to register themselves, then that will be covered in a later step.

You can create a customer through the Medusa Admin or Admin REST APIs.

Create B2B Price List

A price list allows you to set different prices on a set of products for various conditions. When building a B2B store, you can use this to assign different prices for B2B customer groups.

You can use price lists to set the same price for all B2B customers or different prices for different B2B customers if you’ve organized them into separate customer groups.

You can create a price list through the Medusa Admin or Admin REST APIs.

Create Custom Entity

If you wish for a more advanced B2B sales flow, you can use Custom Entities to model Companies, Employees, Admins, and Buyers. This gives you more granular control of your B2B sales and allows you to build features like privileges, limits, and more.

Each of the entities you create can be controlled using custom logic.

Create an API Route to Check Customers

On the frontend clients communicating with your store, such as the storefront, you’ll need to check whether the currently logged-in customer is a B2B customer.

The API Route's logic differs based on how you’ve implemented the B2B logic. For example, if you’ve used the is_b2b flag in the customer group, your API Route can check whether that flag is enabled for the logged-in customer.

Medusa allows you to create custom API Routes exposed as REST APIs.

Example Implementation

Customize Admin

Based on your use case, you may need to customize the Medusa Admin to add new widgets or pages.

The Medusa Admin plugin can be extended to add widgets, UI routes, and setting pages.

Customize Storefront

You may want different interfaces for B2B and regular customers on the storefront. You may also want to display products differently for each type of customer.

Medusa provides a Next.js starter that you can use and customize. You can also build your storefront with any frontend technology. Medusa provides you with different client libraries and REST APIs to use.

Use the publishable API key you associated with your B2B sales channel in the storefront to ensure only B2B products are retrieved.

Deploy B2B Store

Once you finish your development, you can deploy your B2B backend and storefront to your preferred hosting providers.

Additional Development

You can find other resources for your B2B development in the Medusa Development section of this documentation.

Was this section helpful?