Skip to main content

Introduction

User Profiles extend the basic User object with additional information like bio, social links, preferences, detailed statistics, and activity history. Profiles are used to display rich user information on the platform.
The backend uses the /users endpoint for profile operations. The /profiles endpoint mentioned in the frontend is mapped to /users automatically.

UserProfile Object

The UserProfile object contains comprehensive user information:
id
number
required
Unique identifier for the user
firstName
string
required
User’s first name
lastName
string
required
User’s last name
username
string
required
Unique username
email
string
required
User’s email address
role
string
required
User’s role (administrador, editor, autor, comentador)
avatar
string
required
URL to user’s avatar image
coverImage
string
URL to user’s profile cover image
bio
string
User’s biography or description
website
string
User’s personal website URL
location
string
User’s location (e.g., “Madrid, España”)
phone
string
User’s phone number
birthDate
string
User’s birth date in ISO 8601 format
status
string
required
Account status: active, inactive, or suspended
isVerified
boolean
required
Whether the user’s account is verified
onlineStatus
string
required
Current online status: online, offline, or away
lastLogin
string
required
ISO 8601 timestamp of last login
createdAt
string
required
ISO 8601 timestamp of account creation
updatedAt
string
required
ISO 8601 timestamp of last profile update
Social media links
twitter
string
Twitter/X username or URL
linkedin
string
LinkedIn profile URL
github
string
GitHub username or URL
instagram
string
Instagram username or URL
preferences
object
User preferences (see UserPreferences section)
stats
object
User statistics (see UserStats section)
activity
array
Array of recent user activities (see UserActivity section)

Get User Profile

Retrieve a complete user profile by user ID.
GET /api/v1/users/{id}

Path Parameters

id
number
required
The unique identifier of the user

Example Request

curl -X GET "https://api.example.com/api/v1/users/1" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

{
  "id": 1,
  "firstName": "Juan",
  "lastName": "Pérez",
  "username": "admin_master",
  "email": "[email protected]",
  "role": "administrador",
  "avatar": "https://images.pexels.com/photos/2379004/pexels-photo-2379004.jpeg",
  "coverImage": "https://images.pexels.com/photos/3184338/pexels-photo-3184338.jpeg",
  "bio": "Administrador principal del blog. Especialista en marketing digital con más de 10 años de experiencia.",
  "website": "https://juanperez.com",
  "location": "Madrid, España",
  "status": "active",
  "isVerified": true,
  "onlineStatus": "online",
  "lastLogin": "2024-01-15T10:30:00Z",
  "createdAt": "2023-06-01T00:00:00Z",
  "updatedAt": "2024-01-15T10:30:00Z",
  "socialLinks": {
    "twitter": "@juanperez_mkt",
    "linkedin": "https://linkedin.com/in/juanperez",
    "github": "juanperez-dev",
    "instagram": "@juanperez.marketing"
  },
  "stats": {
    "postsCreated": 45,
    "postsPublished": 42,
    "totalViews": 125430,
    "totalLikes": 2340,
    "totalComments": 567,
    "followers": 1250,
    "following": 89,
    "profileViews": 5670
  }
}

Update User Profile

Update a user’s profile information including bio, location, website, and social links.
PATCH /api/v1/users/{id}

Path Parameters

id
number
required
The unique identifier of the user

Body Parameters

firstName
string
User’s first name
lastName
string
User’s last name
email
string
User’s email address
bio
string
User biography or description
location
string
User’s location
website
string
User’s personal website URL
avatar
string
URL to user’s avatar image
Social media links object with keys: twitter, linkedin, github, instagram

Example Request

curl -X PATCH "https://api.example.com/api/v1/users/1" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "bio": "Marketing digital expert with 10+ years experience",
    "location": "Barcelona, España",
    "website": "https://juanperez.com",
    "socialLinks": {
      "twitter": "@juanperez_mkt",
      "linkedin": "https://linkedin.com/in/juanperez",
      "github": "juanperez-dev"
    }
  }'

Example Response

Returns the updated UserProfile object.

Upload Avatar

Upload a new avatar image for a user.
POST /api/v1/users/{id}/avatar

Path Parameters

id
number
required
The unique identifier of the user

Body Parameters

file
file
required
Image file to upload (JPEG, PNG, GIF). Maximum size: 5MB

Example Request

curl -X POST "https://api.example.com/api/v1/users/1/avatar" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -F "[email protected]"

Example Response

{
  "avatarUrl": "https://storage.example.com/avatars/user-1-avatar.jpg",
  "user": {
    "id": 1,
    "avatar": "https://storage.example.com/avatars/user-1-avatar.jpg"
  }
}
The response format may vary. The URL can be found in avatar, avatarUrl, secure_url, or secureUrl fields.

Upload Cover Image

Upload a new cover image for a user’s profile.
POST /api/v1/users/{id}/cover

Path Parameters

id
number
required
The unique identifier of the user

Body Parameters

file
file
required
Image file to upload (JPEG, PNG, GIF). Maximum size: 10MB. Recommended dimensions: 1200x400px

Example Request

curl -X POST "https://api.example.com/api/v1/users/1/cover" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -F "[email protected]"

Example Response

{
  "coverUrl": "https://storage.example.com/covers/user-1-cover.jpg",
  "user": {
    "id": 1,
    "coverImage": "https://storage.example.com/covers/user-1-cover.jpg"
  }
}

Search Users

Search for users by name, username, or email.
GET /api/v1/profiles/search
This is a frontend-only endpoint that uses local search. For production, implement server-side search.

Query Parameters

q
string
required
Search query (matches firstName, lastName, username, or email)
page
number
default:"1"
Page number for pagination
limit
number
default:"10"
Number of results per page

Example Request

const query = 'juan';
const params = { page: 1, limit: 10 };

const results = await searchUsers(query, params);
console.log('Found users:', results.users);
console.log('Total results:', results.total);

Example Response

{
  "users": [
    {
      "id": 1,
      "firstName": "Juan",
      "lastName": "Pérez",
      "username": "admin_master",
      "email": "[email protected]",
      "avatar": "https://images.pexels.com/photos/2379004/pexels-photo-2379004.jpeg",
      "role": "administrador",
      "isVerified": true
    }
  ],
  "total": 1,
  "page": 1,
  "totalPages": 1
}

Get Profile Activity

Retrieve a user’s recent activity history.
GET /api/v1/profiles/{id}/activity

Path Parameters

id
number
required
The unique identifier of the user

Query Parameters

page
number
default:"1"
Page number for pagination
limit
number
default:"20"
Number of activities per page
type
string
default:"all"
Filter by activity type: all, post_created, post_published, comment_added, profile_updated, follow, like_given

Example Request

const userId = 1;
const params = { page: 1, limit: 20, type: 'post_published' };

const activityData = await getProfileActivity(userId, params);
console.log('Activities:', activityData.activities);

Example Response

{
  "activities": [
    {
      "id": "1",
      "type": "post_published",
      "description": "Publicó un nuevo post",
      "target": "Guía Completa de SEO 2024",
      "createdAt": "2024-01-15T09:30:00Z"
    },
    {
      "id": "2",
      "type": "comment_added",
      "description": "Comentó en",
      "target": "Email Marketing: Automatizaciones",
      "content": "Excelente artículo, muy completo.",
      "createdAt": "2024-01-14T16:20:00Z"
    },
    {
      "id": "3",
      "type": "profile_updated",
      "description": "Actualizó su perfil",
      "createdAt": "2024-01-14T12:15:00Z"
    }
  ],
  "total": 3,
  "page": 1,
  "totalPages": 1
}

Get Profile Statistics

Retrieve detailed statistics for a user’s profile.
GET /api/v1/profiles/{id}/stats

Path Parameters

id
number
required
The unique identifier of the user

Query Parameters

timeRange
string
default:"30d"
Time range for statistics: 7d, 30d, or 90d

Example Request

const userId = 1;
const timeRange = '30d';

const stats = await getProfileStats(userId, timeRange);
console.log('Profile stats:', stats);

Example Response

{
  "postsCreated": 45,
  "postsPublished": 42,
  "totalViews": 125430,
  "totalLikes": 2340,
  "totalComments": 567,
  "followers": 1250,
  "following": 89,
  "likesReceived": 3420,
  "commentsReceived": 890,
  "profileViews": 5670,
  "dailyViews": [
    {
      "date": "2024-01-01",
      "views": 150,
      "likes": 12,
      "comments": 5
    }
  ],
  "postsByCategory": [
    {
      "name": "SEO",
      "value": 12,
      "color": "#3B82F6"
    },
    {
      "name": "SEM",
      "value": 8,
      "color": "#10B981"
    }
  ]
}

User Preferences Object

emailNotifications
boolean
Enable email notifications
pushNotifications
boolean
Enable push notifications
marketingEmails
boolean
Allow marketing emails
theme
string
UI theme: light, dark, or system
language
string
Preferred language code (e.g., “es”, “en”)
timezone
string
User’s timezone (e.g., “Europe/Madrid”)
defaultEditor
string
Preferred editor: markdown, wysiwyg, or hybrid
autoSave
boolean
Enable auto-save for drafts
Display social links on profile
showEmail
boolean
Display email address on profile
profileVisibility
string
Profile visibility: public, users, followers, or private
allowDirectMessages
string
Who can send direct messages: everyone, followers, or none
showOnlineStatus
boolean
Show online/offline status
allowAnalytics
boolean
Allow analytics tracking
indexPosts
boolean
Allow search engines to index posts
allowComments
boolean
Allow comments on posts
moderateComments
boolean
Require comment moderation

User Statistics Object

postsCreated
number
Total number of posts created
postsPublished
number
Total number of published posts
totalViews
number
Total views across all content
totalLikes
number
Total likes received
totalComments
number
Total comments received
followers
number
Number of followers
following
number
Number of users following
likesReceived
number
Total likes received on content
commentsReceived
number
Total comments received
profileViews
number
Number of profile page views
postsGrowth
number
Percentage growth in posts (optional)
viewsGrowth
number
Percentage growth in views (optional)
likesGrowth
number
Percentage growth in likes (optional)
followersGrowth
number
Percentage growth in followers (optional)

User Activity Object

id
string
required
Unique activity identifier
type
string
required
Activity type: post_created, post_published, comment_added, profile_updated, follow, or like_given
description
string
required
Human-readable activity description
target
string
Target of the activity (e.g., post title, user name)
content
string
Additional content (e.g., comment text)
createdAt
string
required
ISO 8601 timestamp of activity
metadata
object
Additional metadata about the activity

Additional Operations

Check Username Availability

const result = await checkUsernameAvailability('new_username', 'current_username');
console.log('Available:', result.available);

Check Email Availability

const result = await checkEmailAvailability('[email protected]', '[email protected]');
console.log('Available:', result.available);

Change Password

await changePassword(userId, 'currentPassword', 'newPassword');

Export User Data

const result = await exportUserData(userId);
console.log('Download URL:', result.downloadUrl);

Request Account Deletion

await requestAccountDeletion(userId, 'Reason for deletion');
These operations are currently frontend-only. Implement corresponding backend endpoints for production use.

Users Overview

Learn about the User object and authentication

User CRUD Operations

Manage users, roles, and permissions

Build docs developers (and LLMs) love