This endpoint requires authentication. Include a valid JWT token in the Authorization header.
Endpoint
Retrieve profile information for the currently authenticated user based on the provided JWT token.
Response
Unique identifier for the user account.
Example Request
curl -X GET "https://api.bookify.com/api/users/me" \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Accept: application/json"
Example Response
Status Code: 200 OK
{
"id": "7b9c3d1e-4f2a-5c6d-8e9f-0a1b2c3d4e5f",
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe"
}
Error Responses
401 Unauthorized
Returned when the request lacks valid authentication credentials or the token is expired.
{
"code": "Auth.Unauthorized",
"message": "Authentication credentials are missing or invalid"
}
Common scenarios:
- No
Authorization header provided
- Invalid token format (missing “Bearer” prefix)
- Token has expired
- Token signature is invalid
- Token was issued by an unauthorized issuer
500 Internal Server Error
Returned when an unexpected server error occurs.
{
"code": "Server.Error",
"message": "An unexpected error occurred while processing your request"
}
Usage Notes
- The user information is extracted directly from the JWT token claims
- This endpoint does not require a user ID parameter - it automatically uses the authenticated user
- User profile information cannot be modified through this endpoint (read-only)
- The
id field is useful when creating bookings or other user-specific operations
Common Use Cases
1. Get User ID for Booking
# Get your user ID to use in booking requests
USER_ID=$(curl -s -X GET "https://api.bookify.com/api/users/me" \
-H "Authorization: Bearer $TOKEN" | jq -r '.id')
# Create a booking with your user ID
curl -X POST "https://api.bookify.com/api/bookings" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"apartmentId": "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d",
"userId": "'$USER_ID'",
"startDate": "2024-06-15",
"endDate": "2024-06-20"
}'
2. Display User Profile
// Fetch and display current user profile
async function loadUserProfile() {
const response = await fetch('https://api.bookify.com/api/users/me', {
headers: {
'Authorization': `Bearer ${accessToken}`,
'Accept': 'application/json'
}
});
if (!response.ok) {
throw new Error('Failed to load user profile');
}
const user = await response.json();
console.log(`Welcome, ${user.firstName} ${user.lastName}!`);
return user;
}
3. Verify Token Validity
# Check if your token is still valid
if curl -s -f -X GET "https://api.bookify.com/api/users/me" \
-H "Authorization: Bearer $TOKEN" > /dev/null; then
echo "Token is valid"
else
echo "Token is invalid or expired - please login again"
fi
Authentication Flow
Response Fields Details
| Field | Type | Description | Example |
|---|
id | UUID | Unique user identifier | 7b9c3d1e-4f2a-5c6d-8e9f-0a1b2c3d4e5f |
email | String | User’s email address (unique) | [email protected] |
firstName | String | User’s given name | John |
lastName | String | User’s family name | Doe |