Skip to main content

Endpoint

GET /invite/get
Get basic information about an invitation, including details about the inviter. For private invites (with email), the requester’s email must match the invitation email.

Authentication

This endpoint supports optional authentication:
  • Public invites: No authentication required
  • Private invites: Authentication required, and the logged-in user’s email must match the invitation email

Query Parameters

token
string
required
The invitation token to look up.
GET /invite/get?token=abc123xyz789

Response

Success Response (200)

status
boolean
Always true on success.
inviter
object
Information about the user who created the invitation.
invitation
object
Information about the invitation itself.

Examples

Get Public Invite Details

Request:
GET /invite/get?token=abc123xyz789
Response:
{
  "status": true,
  "inviter": {
    "email": "[email protected]",
    "name": "John Admin",
    "image": "https://example.com/avatars/john.jpg"
  },
  "invitation": {
    "email": null,
    "createdAt": "2026-03-04T10:30:00.000Z",
    "role": "member",
    "newAccount": true
  }
}
This is a public invite (no specific email) that will assign the “member” role.

Get Private Invite Details

Request:
GET /invite/get?token=private-invite-token
Cookie: better-auth.session_token=...
Response:
{
  "status": true,
  "inviter": {
    "email": "[email protected]",
    "name": "Sarah Manager",
    "image": null
  },
  "invitation": {
    "email": "[email protected]",
    "createdAt": "2026-03-04T14:20:00.000Z",
    "role": "editor",
    "newAccount": true
  }
}
This is a private invite for [email protected] to become an “editor”. The requester must be logged in with that email to access this information.

Get Invite for Existing User Upgrade

Request:
GET /invite/get?token=upgrade-token
Cookie: better-auth.session_token=...
Response:
{
  "status": true,
  "inviter": {
    "email": "[email protected]",
    "name": "Admin User",
    "image": "https://example.com/avatars/admin.jpg"
  },
  "invitation": {
    "email": "[email protected]",
    "createdAt": "2026-03-04T09:15:00.000Z",
    "role": "admin",
    "newAccount": false
  }
}
This invitation is for an existing user (newAccount: false) to upgrade to the “admin” role.

Get Invite with Anonymous Inviter

Request:
GET /invite/get?token=anonymous-invite
Response:
{
  "status": true,
  "inviter": {
    "email": "[email protected]",
    "name": null,
    "image": null
  },
  "invitation": {
    "email": null,
    "createdAt": "2026-03-04T16:45:00.000Z",
    "role": "member",
    "newAccount": true
  }
}
When shareInviterName was set to false, the inviter’s name is not shared (returns null).

Error Responses

Invalid Token (400)

{
  "message": "Invalid or non-existent token",
  "errorCode": "INVALID_TOKEN"
}
Returned when:
  • Token doesn’t exist in the database
  • Token has expired
  • For private invites: Requester is not authenticated
  • For private invites: Requester’s email doesn’t match the invitation email
  • Invitation has been canceled or rejected

Inviter Not Found (400)

{
  "message": "Inviter not found",
  "errorCode": "INVITER_NOT_FOUND"
}
Returned when:
  • The user who created the invitation no longer exists in the database

Behavior

Public Invites (no email)

  1. Validates the invitation token exists
  2. Retrieves inviter information
  3. Returns invitation and inviter details
  4. Anyone can access public invite details

Private Invites (with email)

  1. Validates the invitation token exists
  2. Checks if the requester is authenticated
  3. Verifies the requester’s email matches the invitation email
  4. Retrieves inviter information
  5. Returns invitation and inviter details
  6. Only the invited user can access private invite details

Use Cases

Display Invitation Information

Before activating an invitation, you can use this endpoint to show the user:
  • Who invited them
  • What role they’ll receive
  • Whether they need to create a new account or upgrade existing one
const { inviter, invitation } = await authClient.invite.getInvite({ token });

console.log(`${inviter.name} invited you to join as ${invitation.role}`);

if (invitation.newAccount) {
  console.log('You will need to create a new account');
} else {
  console.log('Your role will be upgraded to', invitation.role);
}

Validate Invitation Before Accepting

Check if an invitation is valid before proceeding with the activation flow:
try {
  const inviteDetails = await authClient.invite.getInvite({ token });
  // Invitation is valid, proceed with activation
  showInvitationUI(inviteDetails);
} catch (error) {
  // Invalid or expired invitation
  showErrorMessage('This invitation is invalid or has expired');
}

Display Inviter Information

Show a personalized message with the inviter’s details:
const InvitationCard = ({ token }) => {
  const { inviter, invitation } = useInviteDetails(token);
  
  return (
    <div>
      {inviter.image && <img src={inviter.image} alt={inviter.name} />}
      <p>{inviter.name} has invited you to join as {invitation.role}</p>
      <p>Invitation sent on {new Date(invitation.createdAt).toLocaleDateString()}</p>
    </div>
  );
};

Privacy Considerations

  • The shareInviterName setting controls whether the inviter’s name is shared
  • Private invites can only be viewed by the intended recipient
  • Public invite details are accessible to anyone with the token

Source Code Reference

Implementation: src/routes/get-invite.ts:9-137

Build docs developers (and LLMs) love