Snooplytics API DocsHome

User API

Account settings

1 min read

Manage the authenticated user's account settings. Retrieve profile information, update full name, and access subscription status and usage limits.

Available Endpoints

MethodEndpointDescription
GET/api/user/meGet current user profile
PUT/api/user/meUpdate current user profile
DELETE/api/user/meDelete user account
GET/api/user/me/exportExport user data
GET/api/user/me/login-historyGet login history

Endpoints

GET
/api/user/me

Get current user profile

Retrieve the authenticated user's profile information including subscription status and credits.

Bearer TokenScopes: user:read

Request

curl -X GET "http://localhost:3030/api/user/me" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"

Response 200

User profile retrieved successfully

{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "507f1f77bcf86cd799439011",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "email": "[email protected]",
  "isVerified": true,
  "verifiedAt": "2024-01-01T00:05:00.000Z",
  "isActive": true,
  "lastLoginAt": "2024-01-15T09:00:00.000Z",
  "fullName": "John Doe",
  "emailPreferences": {
    "marketingOptOut": false
  },
  "twoFactorEnabled": true,
  "organizationCount": 1,
  "role": "user"
}
}

Error Responses

401Unauthorized - Invalid or missing authentication

{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}

403Forbidden - Insufficient permissions

{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
PUT
/api/user/me

Update current user profile

Update the authenticated user's full name.

Bearer TokenScopes: user:write

Request

curl -X PUT "http://localhost:3030/api/user/me" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"fullName":"John Doe"}'

Body Parameters

NameTypeDescription
fullNamerequiredstringUser full name
John Doe

Response 200

User profile updated successfully

{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "id": "507f1f77bcf86cd799439011",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z",
  "email": "[email protected]",
  "isVerified": true,
  "verifiedAt": "2024-01-01T00:05:00.000Z",
  "isActive": true,
  "lastLoginAt": "2024-01-15T09:00:00.000Z",
  "fullName": "John Doe",
  "emailPreferences": {
    "marketingOptOut": false
  },
  "twoFactorEnabled": true,
  "organizationCount": 1,
  "role": "user"
}
}

Error Responses

401Unauthorized - Invalid or missing authentication

{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}

403Forbidden - Insufficient permissions

{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
DELETE
/api/user/me

Delete user account

Permanently delete the authenticated user's account and all associated data. Requires password confirmation.

Bearer TokenScopes: user:write

Request

curl -X DELETE "http://localhost:3030/api/user/me" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"

Body Parameters

NameTypeDescription
passwordrequiredstringCurrent password for account deletion confirmation

Response 200

Account deleted successfully

{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
  "message": "string"
}
}

Error Responses

401Unauthorized - Invalid or missing authentication

{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}

403Forbidden - Insufficient permissions

{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
GET
/api/user/me/export

Export user data

Export all user data for GDPR compliance. Returns a JSON file with all user data.

Bearer TokenScopes: user:read

Request

curl -X GET "http://localhost:3030/api/user/me/export" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"

Response 200

User data exported successfully

{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {}
}

Error Responses

401Unauthorized - Invalid or missing authentication

{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}

403Forbidden - Insufficient permissions

{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}
GET
/api/user/me/login-history

Get login history

Get the authenticated user's login history.

Bearer TokenScopes: user:read

Request

curl -X GET "http://localhost:3030/api/user/me/login-history" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"

Response 200

Login history retrieved successfully

{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": [
  {
    "id": "507f1f77bcf86cd799439011",
    "timestamp": "2024-01-15T10:30:00.000Z",
    "action": "login",
    "ipAddress": "192.168.1.1",
    "userAgent": "Mozilla/5.0...",
    "success": true,
    "metadata": {}
  }
]
}

Error Responses

401Unauthorized - Invalid or missing authentication

{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}

403Forbidden - Insufficient permissions

{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}