Skip to main content
POST
/
api
/
profile
Get User Profile
curl --request POST \
  --url https://api.example.com/api/profile/

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/edimez14/password_generator/llms.txt

Use this file to discover all available pages before exploring further.

Overview

This endpoint returns the profile information for the currently authenticated user. Authentication is required via JWT token.

Authentication

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

Request

Endpoint

POST /api/profile/

Headers

HeaderValueRequired
AuthorizationBearer Yes
Content-Typeapplication/jsonYes

Request Body

No request body required. The user is identified from the authentication token.

Response

Success Response (200 OK)

Returns the user profile data serialized using UsersSerializer:
{
  "id": 1,
  "username": "john_doe",
  "email": "[email protected]",
  "first_name": "John",
  "last_name": "Doe",
  "number_phone": "1234567890",
  "avatar": "/media/avatars/profile.jpg",
  "date_joined": "2024-01-15T10:30:00Z",
  "last_login": "2024-03-10T14:20:00Z",
  "is_active": true,
  "is_staff": false,
  "is_superuser": false
}

Response Fields

FieldTypeDescription
idintegerUnique user identifier
usernamestringUser’s username (inherited from AbstractUser)
emailstringUser’s email address (unique, max 200 chars)
first_namestringUser’s first name (max 200 chars, optional)
last_namestringUser’s last name (max 200 chars, optional)
number_phonestringUser’s phone number (max 10 chars, optional)
avatarstringURL path to user’s avatar image (optional)
date_joineddatetimeWhen the user account was created
last_logindatetimeLast login timestamp
is_activebooleanWhether the user account is active
is_staffbooleanWhether user has staff privileges
is_superuserbooleanWhether user has superuser privileges

Error Responses

401 Unauthorized

Returned when the authentication token is missing or invalid:
{
  "detail": "Authentication credentials were not provided."
}

404 Not Found

Returned when the authenticated user cannot be found in the database:
{
  "error": "The user cannot be found in the database."
}

500 Internal Server Error

Returned when an unexpected error occurs:
{
  "error": "Error message details"
}

Example Request

curl -X POST https://api.example.com/api/profile/ \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json"

Example Response

{
  "id": 42,
  "username": "alice_wonder",
  "email": "[email protected]",
  "first_name": "Alice",
  "last_name": "Wonder",
  "number_phone": "5551234567",
  "avatar": "/media/avatars/alice.png",
  "date_joined": "2024-02-01T08:15:30Z",
  "last_login": "2024-03-10T11:45:22Z",
  "is_active": true,
  "is_staff": false,
  "is_superuser": false
}

Implementation Details

This endpoint is implemented in /apps/users/views.py:84 as the profile function view:
  • Decorated with @permission_classes([IsAuthenticated]) to require authentication
  • Uses UsersSerializer to serialize the user data from request.user
  • Returns all fields from the Users model (which extends Django’s AbstractUser)

Build docs developers (and LLMs) love