medusajs/medusa · error · MedusaError

Customer with id: ${req.params.id} not found

Error message

Customer with id: ${req.params.id} not found

What it means

The GET /admin/customers/:id route refetches the customer via remote query; when no customer matches the id it throws NOT_FOUND (HTTP 404).

Source

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

import {
  AuthenticatedMedusaRequest,
  MedusaResponse,
} from "@medusajs/framework/http"
import { refetchCustomer } from "../helpers"
import { AdminUpdateCustomerType } from "../validators"

export const GET = async (
  req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminCustomerParams>,
  res: MedusaResponse<HttpTypes.AdminCustomerResponse>
) => {
  const customer = await refetchCustomer(
    req.params.id,
    req.scope,
    req.queryConfig.fields
  )

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

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

export const POST = async (
  req: AuthenticatedMedusaRequest<
    AdminUpdateCustomerType & AdditionalData,
    HttpTypes.SelectParams
  >,
  res: MedusaResponse<HttpTypes.AdminCustomerResponse>
) => {
  const existingCustomer = await refetchCustomer(req.params.id, req.scope, [
    "id",
  ])

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Confirm the id via GET /admin/customers with a filter
  2. Treat 404 as 'customer deleted' and clean up references
  3. Check you are querying the right environment
Defensive patterns

Strategy: try-catch

Validate before calling

const { customers } = await sdk.admin.customer.list({ id })
if (!customers.length) throw new Error("customer not found")

Type guard

null

Try / catch

try { await getCustomer(id) } catch (e) { if (e.statusCode === 404) showDeletedCustomerNotice() else throw e }

Prevention

When it happens

Trigger: GET /admin/customers/:id with an unknown, deleted, or mistyped customer id.

Common situations: Customer records removed for GDPR/privacy compliance while links remain; guest customer ids reused incorrectly; environment mismatch.

Related errors


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