Significant-Gravitas/AutoGPT · warning · HTTPException

This invitation was sent to a different email address

Error message

This invitation was sent to a different email address

What it means

Raised by POST /api/invitations/{token}/accept when the authenticated user's email (case-insensitively) does not match the email the invitation was sent to. Invitations are bound to a recipient address; only that account may accept. HTTP 403.

Source

Thrown at autogpt_platform/backend/backend/api/features/orgs/invitation_routes.py:164

    token: str,
    user_id: Annotated[str, Security(get_user_id)],
) -> dict:
    invitation = await prisma.orginvitation.find_unique(where={"token": token})
    if invitation is None:
        raise NotFoundError("Invitation not found")
    if invitation.acceptedAt is not None:
        raise HTTPException(400, detail="Invitation already accepted")
    if invitation.revokedAt is not None:
        raise HTTPException(400, detail="Invitation has been revoked")
    if invitation.expiresAt < datetime.now(timezone.utc):
        raise HTTPException(400, detail="Invitation has expired")

    # Verify the accepting user's email matches the invitation
    accepting_user = await prisma.user.find_unique(where={"id": user_id})
    if accepting_user is None:
        raise HTTPException(401, detail="User not found")
    if accepting_user.email.lower() != invitation.email.lower():
        raise HTTPException(
            403,
            detail="This invitation was sent to a different email address",
        )

    # Add user to org (idempotent — handles race condition from concurrent accepts)
    try:
        await org_db.add_org_member(
            org_id=invitation.orgId,
            user_id=user_id,
            is_admin=invitation.isAdmin,
            is_billing_manager=invitation.isBillingManager,
            invited_by=invitation.invitedByUserId,
        )
    except UniqueViolationError:
        # User is already a member — treat as success (idempotent)
        pass

    # Add to specified workspaces. Failures are non-fatal (a team may have

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Log out and back in with exactly the account whose email received the invitation.
  2. If the recipient's address changed, ask the admin to revoke and resend the invitation to the new address.
  3. Admins: before resending, confirm the address with the invitee to avoid another mismatch.
Defensive patterns

Strategy: validation

Validate before calling

const me = await api.get('/api/user/me').then(r => r.data);
const emailMatches = me.email.toLowerCase() === invitedEmail.toLowerCase();
if (!emailMatches) show(`Switch to the account for ${invitedEmail} to accept.`);

Try / catch

try {
  await api.post(`/api/invitations/${token}/accept`);
} catch (e) {
  if (e.status === 403) { show('Log in with the invited email address.'); return; }
  throw e;
}

Prevention

When it happens

Trigger: User logged in with a different account (e.g., personal Google account) than the email that received the invite; case variants are tolerated but different mailboxes are not; invitee changed their primary email after the invite was sent.

Common situations: Google/SSO login picks a different account than expected; invite sent to work address but user browses logged in with personal address; shared inboxes where someone else clicks the link.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/e71a93157e5b48c9. Report an issue: GitHub.