Skip to content

Latest commit

 

History

History
119 lines (88 loc) · 2.42 KB

me.mdx

File metadata and controls

119 lines (88 loc) · 2.42 KB
title Get Profile
description Retrieve the currently authenticated user's profile, or fetch a public profile by username.

GET /api/userAuth/me

Returns the full profile of the currently signed-in user. The response never includes the password field.

Required Headers

Header Value
x-api-key Your pk_live_… key
Authorization Bearer <accessToken>

Response Fields

MongoDB ObjectId of the user. The user's email address. The user's display name. All other fields from your `users` collection schema, except `password`.

Code Examples

const res = await fetch('https://api.urbackend.in/api/userAuth/me', {
  headers: {
    'x-api-key': 'pk_live_YOUR_KEY',
    'Authorization': `Bearer ${accessToken}`
  }
});

const user = await res.json();
curl "https://api.urbackend.in/api/userAuth/me" \
  -H "x-api-key: pk_live_YOUR_KEY" \
  -H "Authorization: Bearer ACCESS_TOKEN"

Success Response

{
  "_id": "64fd1234abcd5678ef901234",
  "email": "alice@example.com",
  "name": "Alice",
  "username": "alice_dev"
}

Errors

Status Cause
401 Unauthorized Missing or expired Authorization token

GET /api/userAuth/public/:username

Returns a public-safe view of a user's profile. No authentication is required.

This endpoint never returns sensitive fields such as `password` or `email`. Only fields considered safe for public display are included.

Path Parameters

The username of the user whose public profile you want to retrieve.

Required Header

x-api-key: your pk_live_… key.

Code Example

const res = await fetch('https://api.urbackend.in/api/userAuth/public/alice_dev', {
  headers: {
    'x-api-key': 'pk_live_YOUR_KEY'
  }
});

const user = await res.json();

Success Response

{
  "_id": "64fd1234abcd5678ef901234",
  "name": "Alice",
  "username": "alice_dev"
}

Errors

Status Cause
404 Not Found No user found with that username