Skip to main content

Get Current User

Retrieve information about the currently authenticated user.

Request

GET /api/v1/auth/me

Authentication

Bearer JWT - Requires a valid access token.

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Request Body

No request body required.

Response

Success Response (200 OK)

{
"id": "123e4567-e89b-12d3-a456-426614174000",
"email": "[email protected]",
"name": "John Doe",
"isOrgAdmin": true,
"platformRole": "USER",
"organizationId": "223e4567-e89b-12d3-a456-426614174001",
"organizationName": "Acme Corporation",
"organizationSlug": "acme-corporation",
"subscriptionTier": "BUSINESS",
"maxUsers": 50,
"maxResources": 100,
"mfaEnabled": true,
"organizationMfaRequired": false
}

Response Fields

FieldTypeDescription
idstringUnique user ID (UUID)
emailstringUser's email address
namestringUser's full name
isOrgAdminbooleanWhether the user has organization admin privileges
platformRolestringPlatform-level role (USER, SUPER_ADMIN)
organizationIdstringOrganization ID (UUID)
organizationNamestringOrganization name
organizationSlugstringURL-friendly organization identifier
subscriptionTierstringOrganization subscription tier (FREE, BUSINESS, ENTERPRISE, PLATFORM)
maxUsersnumberMaximum number of users allowed in the organization
maxResourcesnumberMaximum number of cloud resources allowed in the organization
mfaEnabledbooleanWhether MFA is enabled for this user
organizationMfaRequiredbooleanWhether MFA is required for all users in the organization

Subscription Tier Limits

TierMax UsersMax ResourcesFeatures
FREE35Basic IP whitelisting
BUSINESS50100API keys, priority support
ENTERPRISE5001000SSO, custom integrations
PLATFORMUnlimitedUnlimitedAll features, super admin access

Error Responses

Status CodeDescription
401 UnauthorizedMissing, invalid, or expired access token
403 ForbiddenUser or organization is suspended
429 Too Many RequestsRate limit exceeded
500 Internal Server ErrorServer error occurred

Example

curl -X GET https://api.entryguard.io/api/v1/auth/me \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjNlNDU2Ny1lODliLTEyZDMtYTQ1Ni00MjY2MTQxNzQwMDAiLCJvcmdJZCI6IjIyM2U0NTY3LWU4OWItMTJkMy1hNDU2LTQyNjYxNDE3NDAwMSIsInJvbGVzIjpbIk9SR19BRE1JTiJdLCJpYXQiOjE3MDkwNDk2MDAsImV4cCI6MTcwOTA1MzIwMH0.xyz123"

Example Response

{
"id": "123e4567-e89b-12d3-a456-426614174000",
"email": "[email protected]",
"name": "John Doe",
"isOrgAdmin": true,
"platformRole": "USER",
"organizationId": "223e4567-e89b-12d3-a456-426614174001",
"organizationName": "Acme Corporation",
"organizationSlug": "acme-corporation",
"subscriptionTier": "BUSINESS",
"maxUsers": 50,
"maxResources": 100,
"mfaEnabled": true,
"organizationMfaRequired": false
}

Usage Notes

User Context

This endpoint is useful for:

  • Displaying user information in the UI
  • Checking user permissions and roles
  • Determining available features based on subscription tier
  • Verifying organization limits before creating resources or users
  • Confirming MFA status

Token Validation

This endpoint also serves as a token validation mechanism. If the access token is valid, the endpoint returns user information. If invalid or expired, it returns a 401 Unauthorized error.

Example Usage in Application

// JavaScript example - fetch current user on app load
async function getCurrentUser() {
const accessToken = localStorage.getItem('accessToken');

try {
const response = await fetch('https://api.entryguard.io/api/v1/auth/me', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
});

if (!response.ok) {
if (response.status === 401) {
// Token expired, try to refresh
await refreshToken();
return getCurrentUser(); // Retry with new token
}
throw new Error('Failed to fetch user');
}

const user = await response.json();
return user;
} catch (error) {
console.error('Error fetching current user:', error);
// Redirect to login
window.location.href = '/login';
}
}