{"record":{"id":"dbbf7e275aef3206","repo":"medusajs/medusa","slug":"not-found-dbbf7e","errorCode":"NOT_FOUND","errorMessage":"Customer with id: ${id} was not found","messagePattern":"Customer with id: (.+?) was not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/store/customers/me/route.ts","lineNumber":18,"sourceCode":"import {\n  AuthenticatedMedusaRequest,\n  MedusaResponse,\n} from \"@medusajs/framework/http\"\nimport { refetchCustomer } from \"../helpers\"\nimport { MedusaError } from \"@medusajs/framework/utils\"\nimport { updateCustomersWorkflow } from \"@medusajs/core-flows\"\nimport { HttpTypes } from \"@medusajs/framework/types\"\n\nexport const GET = async (\n  req: AuthenticatedMedusaRequest<HttpTypes.StoreGetCustomerParams>,\n  res: MedusaResponse<HttpTypes.StoreCustomerResponse>\n) => {\n  const id = req.auth_context.actor_id\n  const customer = await refetchCustomer(id, req.scope, req.queryConfig.fields)\n\n  if (!customer) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Customer with id: ${id} was not found`\n    )\n  }\n\n  res.json({ customer })\n}\n\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<\n    HttpTypes.StoreUpdateCustomer,\n    HttpTypes.SelectParams\n  >,\n  res: MedusaResponse<HttpTypes.StoreCustomerResponse>\n) => {\n  const customerId = req.auth_context.actor_id\n  await updateCustomersWorkflow(req.scope).run({\n    input: {","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/store/customers/me/route.ts#L1-L36","documentation":"Thrown by GET /store/customers/me when the customer id resolved from the authenticated session (auth_context.actor_id) does not correspond to an existing customer in the database. The route refetches the customer with the requested fields and throws NOT_FOUND when the lookup returns nothing. This almost always means the auth token/session references a customer that was deleted (e.g. soft-deleted) after the token was issued.","triggerScenarios":"Calling GET /store/customers/me with a valid customer JWT/session whose actor_id was deleted, or after the customer record was removed via Admin API while the store client kept its access token. Also occurs if the auth identity is misconfigured so actor_id points at a wrong/nonexistent record.","commonSituations":"Deleted test customers while the storefront kept cached tokens; importing customers and having stale sessions; auth provider misconfiguration producing actor_ids that don't match the customer table.","solutions":["Log the customer out and re-authenticate to get a fresh token whose actor_id points to an existing customer","Verify the customer still exists (admin: GET /admin/customers/:id) and restore/reactivate it if soft-deleted","Check your auth provider setup so the actor_id is correctly linked to the customer entity","If tokens are long-lived, shorten their lifetime or revoke them on customer deletion"],"exampleFix":"// before\nconst { customer } = await sdk.store.customer.retrieve() // 404 after account deletion\n\n// after\ntry {\n  const { customer } = await sdk.store.customer.retrieve()\n} catch (e) {\n  if (e.type === 'not_found') {\n    await sdk.auth.logout()\n    redirect('/login?reason=session-expired')\n  }\n}","handlingStrategy":"try-catch","validationCode":"// Refresh session before use\nconst { customer } = await sdk.auth.me() // or re-authenticate\nif (!customer) await sdk.auth.logout()","typeGuard":null,"tryCatchPattern":"try {\n  const { customer } = await sdk.store.customer.retrieve()\n} catch (e: any) {\n  if (e.type === 'not_found' && e.message.includes('Customer')) {\n    await sdk.auth.logout()\n    window.location.href = '/login'\n  } else throw e\n}","preventionTips":["Revoke customer tokens on account deletion (webhook or custom logic)","Shorten customer JWT lifetime","Catch 404 on /store/customers/me globally and force re-login"],"tags":["store-api","customer","authentication","not-found"],"backgroundTag":"stale-auth-token","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}