medusajs/medusa · error · MedusaError

Campaign with id: ${req.params.id} was not found

Error message

Campaign with id: ${req.params.id} was not found

What it means

The GET /admin/campaigns/:id route refetches the campaign (promotion module) and throws NOT_FOUND (HTTP 404) when no campaign with that id exists.

Source

Thrown at packages/medusa/src/api/admin/campaigns/[id]/route.ts:25

  updateCampaignsWorkflow,
} from "@medusajs/core-flows"

import { refetchCampaign } from "../helpers"
import { MedusaError } from "@medusajs/framework/utils"
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"

export const GET = async (
  req: AuthenticatedMedusaRequest<HttpTypes.AdminGetCampaignParams>,
  res: MedusaResponse<HttpTypes.AdminCampaignResponse>
) => {
  const campaign = await refetchCampaign(
    req.params.id,
    req.scope,
    req.queryConfig.fields
  )

  if (!campaign) {
    throw new MedusaError(
      MedusaError.Types.NOT_FOUND,
      `Campaign with id: ${req.params.id} was not found`
    )
  }

  res.status(200).json({ campaign })
}

export const POST = async (
  req: AuthenticatedMedusaRequest<
    HttpTypes.AdminUpdateCampaign & AdditionalData,
    HttpTypes.AdminGetCampaignParams
  >,
  res: MedusaResponse<HttpTypes.AdminCampaignResponse>
) => {
  const existingCampaign = await refetchCampaign(req.params.id, req.scope, [
    "id",
  ])

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. List campaigns with GET /admin/campaigns to confirm the id
  2. Handle 404 in the client by redirecting to the campaigns list
  3. Ensure your backend URL matches the environment that owns the campaign
Defensive patterns

Strategy: try-catch

Validate before calling

const { campaigns } = await sdk.promotion.listCampaigns({ id: campaignId })
if (!campaigns.length) throw new Error("campaign gone")

Type guard

null

Try / catch

try { await fetchCampaign(id) } catch (e) { if (e.statusCode === 404) redirect("/campaigns") else throw e }

Prevention

When it happens

Trigger: GET /admin/campaigns/:id with a nonexistent, deleted, or mistyped campaign id.

Common situations: Campaign deleted by another admin while its detail page was open; deep links to removed campaigns; id copied across environments.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/7c1fcad7a7a1185b. Report an issue: GitHub.