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 POST (update) /admin/customers/:id route refetches the customer before updating and throws NOT_FOUND (HTTP 404) if the record is gone.

Source

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

      `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",
  ])
  if (!existingCustomer) {
    throw new MedusaError(
      MedusaError.Types.NOT_FOUND,
      `Customer with id "${req.params.id}" not found`
    )
  }

  const { additional_data, ...rest } = req.validatedBody

  await updateCustomersWorkflow(req.scope).run({
    input: {
      selector: { id: req.params.id },
      update: rest,
      additional_data,
    },
  })

  const customer = await refetchCustomer(
    req.params.id,
    req.scope,

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Refetch the customer before allowing edits to be submitted
  2. Handle 404 by refreshing the customer list view
  3. Use idempotent update flows that check existence first
Defensive patterns

Strategy: validation

Validate before calling

const exists = (await sdk.admin.customer.list({ id })).customers.length > 0
if (!exists) throw new Error("customer deleted before update")

Type guard

null

Try / catch

try { await updateCustomer(id, payload) } catch (e) { if (e.statusCode === 404) { discardEdits(); reload() } else throw e }

Prevention

When it happens

Trigger: POST /admin/customers/:id with an update body for a customer that no longer exists.

Common situations: Customer deleted between page load and save; duplicate submits racing a deletion.

Related errors


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