Documentation Index Fetch the complete documentation index at: https://docs.mercurjs.com/llms.txt
Use this file to discover all available pages before exploring further.
Workflows
createVendorCampaignWorkflow
This documentation provides a reference to the createVendorCampaignWorkflow. It belongs to the @mercurjs/b2c-core package.
This workflow creates a new campaign and links it to the seller creating it. This allows for seller-specific campaigns within the marketplace.
Source code
Examples
packages/modules/b2c-core/src/api/vendor/campaigns/route.ts
import { AuthenticatedMedusaRequest , MedusaResponse } from "@medusajs/framework" ;
import { createVendorCampaignWorkflow } from "../../../workflows/campaigns/workflows" ;
import { VendorCreateCampaignType } from "./validators" ;
import { fetchSellerByAuthActorId } from "../../../shared/infra/http/utils" ;
export const POST = async (
req : AuthenticatedMedusaRequest < VendorCreateCampaignType >,
res : MedusaResponse
) => {
const seller = await fetchSellerByAuthActorId (
req . auth_context ?. actor_id ,
req . scope
);
const { result } = await createVendorCampaignWorkflow ( req . scope ). run ({
input: {
campaign: req . validatedBody ,
seller_id: seller . id
},
});
res . status ( 201 ). json ({ campaign: result [ 0 ] });
};
Steps
createCampaignsWorkflow : Creates the campaign using Medusa’s core workflow.
createRemoteLinkStep : Links the created campaign to the seller (using SELLER_MODULE) and the promotion module.
campaign
CreateCampaignDTO
required
The details of the campaign to create. The name of the campaign.
The identifier of the campaign.
The description of the campaign.
The start date of the campaign.
The end date of the campaign.
The budget configuration for the campaign. The type of budget (e.g. ‘spend’, ‘usage’).
The limit for the budget.
The currency code for the budget (required if type is ‘spend’).
The ID of the seller creating the campaign.
Output
The created campaigns. The name of the campaign.