Request Module
In this section of the documentation, you will find resources to learn more about the Request Module and how to use it in your application. Mercur has seller request and approval features available out-of-the-box through the Request Module. A module is a standalone package that provides features for a single domain. Each of Mercur’s marketplace features are placed in custom modules, such as this Request Module. Learn more about why modules are isolated in this documentation.Request Features
- Seller Proposals: Allow sellers to propose new marketplace resources (products, categories, collections, types, tags).
- Admin Approval Workflow: Require admin review and approval before seller-proposed resources go live.
- Request Types: Support multiple request types for different marketplace entities.
- Review Notes: Store admin explanations for approval or rejection decisions.
- Status Tracking: Track requests through draft, pending, accepted, and rejected statuses.
- Automatic Resource Creation: Automatically create the proposed resource when a request is accepted.
How to Use the Request Module
In your Medusa application, you build flows around Commerce Modules. A flow is built as a Workflow, which is a special function composed of a series of steps that guarantees data consistency and reliable roll-back mechanism. You can build custom workflows and steps. Mercur provides pre-built workflows for request operations in the@mercurjs/requests package.
For example, the acceptProductRequestWorkflow:
src/workflows/requests/accept-product-request.ts
API Route
src/api/admin/requests/route.ts
Subscriber
src/subscribers/product-request-to-create.ts
Concepts
In this document, you’ll learn about the main concepts related to requests in Mercur.Request
A request represents a seller’s proposal to create a new marketplace resource that requires admin approval. It is represented by the Request data model. A request holds information about:- Request type (what kind of resource is being proposed)
- Request data (the payload containing the proposed resource details)
- Submitter ID (the seller member who created the request)
- Reviewer ID (the admin who reviewed the request)
- Reviewer note (admin’s explanation of their decision)
- Status (current state in the approval workflow)
Request Types
The Request Module supports multiple request types for different marketplace entities:product
Seller proposes a new product to be added to the marketplace catalog. Data payload includes:- Product title, description, handle
- Product type, collection, category
- Variants, options, pricing
- Images and metadata
product_category
Seller proposes a new product category. Data payload includes:- Category name, description
- Parent category ID (for hierarchy)
- Handle for URL
product_collection
Seller proposes a new product collection. Data payload includes:- Collection title, handle
- Description and metadata
product_type
Seller proposes a new product type classification. Data payload includes:- Type value (e.g., “Electronics”, “Apparel”)
product_tag
Seller proposes a new product tag. Data payload includes:- Tag value (e.g., “Eco-Friendly”, “Sale”)
review_remove
Seller requests removal of an unfair or policy-violating review. Data payload includes:- Review ID to be removed
- Reason for removal request
product_update
Seller proposes updates to an existing product that requires approval. Data payload includes:- Product ID
- Fields to be updated
- New values
Request Status Workflow
Requests follow a four-state workflow:draft
Initial state for requests being prepared.- Not yet submitted for review
- Can be edited or deleted
- Not visible to admins
pending
Submitted for review.- Awaiting admin decision
- Visible in admin request queue
- Cannot be edited by seller
accepted
Approved by admin.- Resource is automatically created from request data
- Request marked as accepted
- Seller notified of approval
- Resource goes live in marketplace
rejected
Denied by admin.- Resource is not created
- Admin provides explanation in
reviewer_note - Seller notified of rejection
- Request archived
Automatic Resource Creation
When a request is accepted, the appropriate workflow automatically creates the resource: Product Request → ProductEvent-Driven Architecture
The Request Module uses an event-driven pattern for resource creation:- Request Created: Seller creates request with status “pending”
- Admin Reviews: Admin accepts the request
- Event Emitted:
ProductRequestUpdatedEvent.TO_CREATEemitted - Subscriber Triggered:
product-request-to-createsubscriber executes - Workflow Runs:
createProductRequestWorkflowcreates the resource - Request Updated: Request status updated to “accepted”
Configuration Integration
The Request Module integrates with the Configuration Module to control availability:Notification Integration
The Request Module triggers notifications for key events: For Admins:- New request created → Admin notification in feed
- Request accepted → Success notification with resource details
- Request rejected → Rejection notification with admin’s reason