Skip to main content
GET
/
api
/
auth
/
profile
Get User Profile
curl --request GET \
  --url https://api.example.com/api/auth/profile
{
  "user": {
    "_id": "<string>",
    "supabaseId": "<string>",
    "email": "<string>",
    "name": "<string>",
    "role": "<string>",
    "emailVerified": true,
    "createdAt": "<string>",
    "updatedAt": "<string>"
  },
  "error": "<string>"
}

Overview

Retrieves the profile information for the currently authenticated user. This endpoint requires a valid JWT token and returns the user’s MongoDB profile data.

Authentication

This endpoint requires authentication. Include a valid access token in the Authorization header.
Authorization: Bearer <access_token>

Request

No request body or parameters required. The user is identified from the JWT token.
cURL
curl -X GET "https://api.vaniykempire.com/api/auth/profile" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
JavaScript
const response = await fetch('https://api.vaniykempire.com/api/auth/profile', {
  headers: {
    'Authorization': `Bearer ${accessToken}`
  }
});

const data = await response.json();
console.log(data.user);
Python
import requests

response = requests.get(
    'https://api.vaniykempire.com/api/auth/profile',
    headers={
        'Authorization': f'Bearer {access_token}'
    }
)

data = response.json()
print(data['user'])

Response

user
object
The user’s profile information

Success Response

{
  "user": {
    "_id": "65f7b3c8e1234567890abcde",
    "supabaseId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "email": "[email protected]",
    "name": "John Doe",
    "role": "user",
    "emailVerified": true,
    "createdAt": "2024-03-15T10:30:00.000Z",
    "updatedAt": "2024-03-15T10:30:00.000Z"
  }
}

Error Responses

error
string
Error message describing what went wrong

401 Unauthorized

Returned when the access token is missing, invalid, or expired.
{
  "error": "Invalid token"
}

404 Not Found

Returned when the user record doesn’t exist in MongoDB (rare case).
{
  "error": "User not found"
}

500 Internal Server Error

Returned when a server error occurs.
{
  "error": "Internal server error message"
}

Notes

The profile endpoint uses the JWT token to identify the user, so you don’t need to pass a user ID. Each user can only access their own profile.
This endpoint returns data from MongoDB, not Supabase. It includes the supabaseId field which links the MongoDB record to the Supabase authentication record.
  • Signup - Create a new user account
  • Login - Authenticate and get an access token

Build docs developers (and LLMs) love