{"record":{"id":"596783736e977231","repo":"medusajs/medusa","slug":"customer-with-id-req-params-id-not-found-596783","errorCode":null,"errorMessage":"Customer with id \"${req.params.id}\" not found","messagePattern":"Customer with id \"(.+?)\" not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/customers/[id]/route.ts","lineNumber":45,"sourceCode":"      `Customer with id: ${req.params.id} not found`\n    )\n  }\n\n  res.status(200).json({ customer })\n}\n\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<\n    AdminUpdateCustomerType & AdditionalData,\n    HttpTypes.SelectParams\n  >,\n  res: MedusaResponse<HttpTypes.AdminCustomerResponse>\n) => {\n  const existingCustomer = await refetchCustomer(req.params.id, req.scope, [\n    \"id\",\n  ])\n  if (!existingCustomer) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Customer with id \"${req.params.id}\" not found`\n    )\n  }\n\n  const { additional_data, ...rest } = req.validatedBody\n\n  await updateCustomersWorkflow(req.scope).run({\n    input: {\n      selector: { id: req.params.id },\n      update: rest,\n      additional_data,\n    },\n  })\n\n  const customer = await refetchCustomer(\n    req.params.id,\n    req.scope,","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/customers/[id]/route.ts#L27-L63","documentation":"The POST (update) /admin/customers/:id route refetches the customer before updating and throws NOT_FOUND (HTTP 404) if the record is gone.","triggerScenarios":"POST /admin/customers/:id with an update body for a customer that no longer exists.","commonSituations":"Customer deleted between page load and save; duplicate submits racing a deletion.","solutions":["Refetch the customer before allowing edits to be submitted","Handle 404 by refreshing the customer list view","Use idempotent update flows that check existence first"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const exists = (await sdk.admin.customer.list({ id })).customers.length > 0\nif (!exists) throw new Error(\"customer deleted before update\")","typeGuard":"null","tryCatchPattern":"try { await updateCustomer(id, payload) } catch (e) { if (e.statusCode === 404) { discardEdits(); reload() } else throw e }","preventionTips":["Refetch before edit submission","Disable forms when the loaded record is stale"],"tags":["admin-api","customers","update","not-found"],"backgroundTag":"http-404-update-missing-resource","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}