{"record":{"id":"be6729d856277eff","repo":"medusajs/medusa","slug":"invite-with-id-id-was-not-found","errorCode":null,"errorMessage":"Invite with id: ${id} was not found","messagePattern":"Invite with id: (.+?) was not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/invites/[id]/route.ts","lineNumber":19,"sourceCode":"import {\n  AuthenticatedMedusaRequest,\n  MedusaResponse,\n} from \"@medusajs/framework/http\"\nimport { MedusaError } from \"@medusajs/framework/utils\"\n\nimport { deleteInvitesWorkflow } from \"@medusajs/core-flows\"\nimport { HttpTypes } from \"@medusajs/framework/types\"\nimport { refetchInvite } from \"../helpers\"\n\nexport const GET = async (\n  req: AuthenticatedMedusaRequest<HttpTypes.AdminGetInviteParams>,\n  res: MedusaResponse<HttpTypes.AdminInviteResponse>\n) => {\n  const { id } = req.params\n  const invite = await refetchInvite(id, req.scope, req.queryConfig.fields)\n\n  if (!invite) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Invite with id: ${id} was not found`\n    )\n  }\n\n  res.status(200).json({ invite })\n}\n\nexport const DELETE = async (\n  req: AuthenticatedMedusaRequest,\n  res: MedusaResponse<HttpTypes.AdminInviteDeleteResponse>\n) => {\n  const { id } = req.params\n  const workflow = deleteInvitesWorkflow(req.scope)\n\n  await workflow.run({\n    input: { ids: [id] },\n  })","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/invites/[id]/route.ts#L1-L37","documentation":"Thrown by GET /admin/invites/:id when refetchInvite returns no record. The route resolves the invite by id via the query graph with the requested fields; an empty result means no invite with that id exists in the user module (or it was consumed/deleted).","triggerScenarios":"Calling GET /admin/invites/inv_123 with an id that does not exist, an invite that was already accepted (accepted invites are removed), or a deleted invite.","commonSituations":"Accepting an invite from a stale link after it was already used, passing a user id instead of an invite id, or querying a different environment/database than where the invite was created.","solutions":["List invites with GET /admin/invites and confirm the id exists before retrieving it","If the invite was already accepted or expired, ask an admin to create a new invite","Verify you are pointed at the environment/database where the invite was created"],"exampleFix":"// before\nconst { invite } = await sdk.admin.invite.retrieve(\"inv_123\")\n\n// after\nconst { invites } = await sdk.admin.invite.list()\nconst invite = invites.find((i) => i.id === \"inv_123\")\nif (!invite) throw new Error(\"Invite no longer exists; request a new one\")","handlingStrategy":"validation","validationCode":"const { invites } = await sdk.admin.invite.list({ limit: 100 })\nconst exists = invites.some((i) => i.id === inviteId)\nif (!exists) throw new Error(`Invite ${inviteId} not found`)","typeGuard":"const isInvite = (v: unknown): v is HttpTypes.AdminInvite =>\n  typeof v === \"object\" && v !== null && \"email\" in v && \"id\" in v","tryCatchPattern":"try {\n  const { invite } = await sdk.admin.invite.retrieve(id)\n} catch (e: any) {\n  if (e.statusCode === 404) return handleMissingInvite(id)\n  throw e\n}","preventionTips":["Fetch invite lists fresh instead of caching ids","Treat accepted invites as consumed; never retry the same invite link","Scope ids per environment in config"],"tags":["admin","invites","not-found","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}