medusajs/medusa · error · MedusaError

Invite with id: ${id} was not found

Error message

Invite with id: ${id} was not found

What it means

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).

Source

Thrown at packages/medusa/src/api/admin/invites/[id]/route.ts:19

import {
  AuthenticatedMedusaRequest,
  MedusaResponse,
} from "@medusajs/framework/http"
import { MedusaError } from "@medusajs/framework/utils"

import { deleteInvitesWorkflow } from "@medusajs/core-flows"
import { HttpTypes } from "@medusajs/framework/types"
import { refetchInvite } from "../helpers"

export const GET = async (
  req: AuthenticatedMedusaRequest<HttpTypes.AdminGetInviteParams>,
  res: MedusaResponse<HttpTypes.AdminInviteResponse>
) => {
  const { id } = req.params
  const invite = await refetchInvite(id, req.scope, req.queryConfig.fields)

  if (!invite) {
    throw new MedusaError(
      MedusaError.Types.NOT_FOUND,
      `Invite with id: ${id} was not found`
    )
  }

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

export const DELETE = async (
  req: AuthenticatedMedusaRequest,
  res: MedusaResponse<HttpTypes.AdminInviteDeleteResponse>
) => {
  const { id } = req.params
  const workflow = deleteInvitesWorkflow(req.scope)

  await workflow.run({
    input: { ids: [id] },
  })

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. List invites with GET /admin/invites and confirm the id exists before retrieving it
  2. If the invite was already accepted or expired, ask an admin to create a new invite
  3. Verify you are pointed at the environment/database where the invite was created

Example fix

// before
const { invite } = await sdk.admin.invite.retrieve("inv_123")

// after
const { invites } = await sdk.admin.invite.list()
const invite = invites.find((i) => i.id === "inv_123")
if (!invite) throw new Error("Invite no longer exists; request a new one")
Defensive patterns

Strategy: validation

Validate before calling

const { invites } = await sdk.admin.invite.list({ limit: 100 })
const exists = invites.some((i) => i.id === inviteId)
if (!exists) throw new Error(`Invite ${inviteId} not found`)

Type guard

const isInvite = (v: unknown): v is HttpTypes.AdminInvite =>
  typeof v === "object" && v !== null && "email" in v && "id" in v

Try / catch

try {
  const { invite } = await sdk.admin.invite.retrieve(id)
} catch (e: any) {
  if (e.statusCode === 404) return handleMissingInvite(id)
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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