Skip to content

Users API ​

Manage user profiles, update information, and handle account operations.

📖 Real API Documentation

All endpoints are documented based on the actual Flowless backend code - guaranteed to match production behavior!


Base URL ​

https://your-instance-name.pubflow.com

Get User Profile ​

Get the authenticated user's complete profile.

Endpoint ​

http
GET /auth/me

Alternative endpoint:

http
GET /auth/user/me

Headers ​

http
X-Session-ID: ses_xyz123456

Response ​

json
{
  "success": true,
  "data": {
    "user": {
      "id": "usr_1234567890",
      "email": "user@example.com",
      "name": "John",
      "last_name": "Doe",
      "user_name": "johndoe",
      "user_type": "customer",
      "picture": "https://storage.pubflow.com/users/usr_123/picture.jpg",
      "phone": "+1234567890",
      "is_verified": true,
      "two_factor": false,
      "dob": "1990-01-01",
      "gender": "male",
      "reference_id": "ref_123",
      "recovery_email": "recovery@example.com",
      "tmz": "America/New_York",
      "created_at": "2025-12-07T10:00:00Z",
      "updated_at": "2025-12-07T10:00:00Z"
    }
  }
}

Update User Profile ​

Update user profile information.

Endpoint ​

http
PUT /auth/profile

Alternative endpoint (with enhanced validation):

http
PUT /auth/user/me

Headers ​

http
X-Session-ID: ses_xyz123456
Content-Type: application/json

Request Body ​

json
{
  "name": "John",
  "lastName": "Doe",
  "userName": "johndoe",
  "phone": "+1234567890",
  "dob": "1990-01-01",
  "gender": "male",
  "referenceId": "ref_123",
  "recoveryEmail": "recovery@example.com",
  "tmz": "America/New_York"
}

Parameters ​

FieldTypeRequiredDescription
namestringNoUser's first name
lastNamestringNoUser's last name
userNamestringNoUnique username
phonestringNoPhone number
dobstringNoDate of birth (YYYY-MM-DD)
genderstringNoGender
referenceIdstringNoExternal reference ID
recoveryEmailstringNoRecovery email address
tmzstringNoTimezone (e.g., "America/New_York")

Enhanced Profile Fields

The /auth/user/me endpoint supports additional fields:

  • email - Change email (requires permission)
  • two_factor - Enable/disable 2FA
  • mobile - Mobile number
  • bio - User biography
  • display_name - Display name
  • first_time - First time user flag
  • metadata - Custom JSON metadata

Response ​

json
{
  "success": true,
  "data": {
    "user": {
      "id": "usr_1234567890",
      "email": "user@example.com",
      "name": "John",
      "lastName": "Doe",
      "userName": "johndoe",
      "userType": "customer",
      "picture": null,
      "phone": "+1234567890",
      "isVerified": true,
      "twoFactor": false,
      "dob": "1990-01-01",
      "gender": "male",
      "reference_id": "ref_123",
      "recovery_email": "recovery@example.com",
      "tmz": "America/New_York",
      "updatedAt": "2025-12-07T11:00:00Z"
    }
  }
}

Upload Profile Picture ​

Upload or update user's profile picture.

Endpoint ​

http
POST /auth/upload/picture

Headers ​

http
X-Session-ID: ses_xyz123456
Content-Type: multipart/form-data

Request Body (Form Data) ​

picture: [File]

Supported Formats ​

  • JPEG (.jpg, .jpeg)
  • PNG (.png)
  • WebP (.webp)
  • GIF (.gif)
  • Max size: 10MB
  • Automatic compression and optimization

Response ​

json
{
  "success": true,
  "data": {
    "picture_url": "https://storage.pubflow.com/users/usr_1234567890/picture.jpg",
    "file_size": 245678,
    "original_size": 512000,
    "compression_ratio": 0.48,
    "method": "cloud_config"
  },
  "message": "Picture uploaded successfully",
  "timestamp": "2025-12-07T11:00:00Z"
}

Example (JavaScript) ​

javascript
async function uploadProfilePicture(file: File) {
  const formData = new FormData();
  formData.append('picture', file);

  const response = await fetch(
    `${FLOWLESS_URL}/auth/upload/picture`,
    {
      method: 'POST',
      headers: {
        'X-Session-ID': sessionId,
      },
      body: formData,
    }
  );

  const data = await response.json();
  return data.data.picture_url;
}

Delete Profile Picture ​

Delete user's profile picture.

Endpoint ​

http
DELETE /auth/upload/picture

Headers ​

http
X-Session-ID: ses_xyz123456

Response ​

json
{
  "success": true,
  "message": "Picture deleted successfully"
}

Change Password ​

Change the user's password (authenticated users).

Endpoint ​

http
POST /auth/password-change/self

Headers ​

http
X-Session-ID: ses_xyz123456
Content-Type: application/json

Request Body ​

json
{
  "currentPassword": "OldPassword123!",
  "newPassword": "NewPassword456!"
}

Response ​

json
{
  "success": true,
  "message": "Password updated successfully"
}

Error Responses ​

json
// Incorrect current password
{
  "success": false,
  "error": "Current password is incorrect"
}

// Weak new password
{
  "success": false,
  "error": "New password must be at least 8 characters long"
}

Request Password Reset ​

Request a password reset email.

Endpoint ​

http
POST /auth/password-reset/request

Request Body ​

json
{
  "email": "user@example.com"
}

Response ​

json
{
  "success": true,
  "message": "If your email is registered, you will receive password reset instructions."
}

Security Feature

This endpoint always returns success, even if the email doesn't exist, to prevent email enumeration attacks.


Validate Password Reset Token ​

Validate a password reset token before using it.

Endpoint ​

http
POST /auth/password-reset/validate

Request Body ​

json
{
  "token": "reset_token_abc123"
}

Response ​

json
{
  "valid": true,
  "message": "Token is valid"
}

Reset Password ​

Reset password using the token from the email.

Endpoint ​

http
POST /auth/password-reset/complete

Request Body ​

json
{
  "token": "reset_token_abc123",
  "password": "NewPassword456!"
}

Response ​

json
{
  "success": true,
  "message": "Password reset successfully"
}

Error Responses ​

json
// Invalid or expired token
{
  "success": false,
  "error": "Invalid or expired reset token"
}

// Weak password
{
  "success": false,
  "error": "Password must be at least 8 characters long"
}

Resend Verification Email ​

Resend the email verification email.

Endpoint ​

http
POST /auth/resend-verification

Headers ​

http
X-Bridge-Secret: your_bridge_secret
Content-Type: application/json

Request Body ​

json
{
  "email": "user@example.com"
}

Response ​

json
{
  "success": true,
  "message": "If your email is registered, you will receive a verification email.",
  "verification_sent": true
}

Requires Bridge Secret

This endpoint requires the X-Bridge-Secret header for security. Get your bridge secret from the Pubflow dashboard.


Admin - Search Users ​

Search and filter users (admin/superadmin only).

Endpoint ​

http
GET /auth/users

Headers ​

http
X-Session-ID: ses_admin_xyz

Query Parameters ​

ParameterTypeRequiredDescription
qstringNoSearch query (email, name, username)
userTypestringNoFilter by user type
pagenumberNoPage number (default: 1)
limitnumberNoResults per page (default: 10)

Example Request ​

http
GET /auth/users?q=john&userType=customer&page=1&limit=10

Response ​

json
{
  "success": true,
  "data": {
    "users": [
      {
        "id": "usr_abc123",
        "email": "user@example.com",
        "name": "John",
        "lastName": "Doe",
        "userName": "johndoe",
        "userType": "customer",
        "isVerified": true,
        "createdAt": "2025-12-07T10:00:00Z"
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 10,
      "total": 1,
      "pages": 1
    }
  }
}

Admin - Get User Details ​

Get detailed information about a specific user (admin/superadmin only).

Endpoint ​

http
GET /auth/admin/users/:id

Headers ​

http
X-Session-ID: ses_admin_xyz

Response ​

json
{
  "success": true,
  "data": {
    "id": "usr_abc123",
    "email": "user@example.com",
    "name": "John",
    "last_name": "Doe",
    "user_type": "customer",
    "picture": null,
    "user_name": "johndoe",
    "phone": "+1234567890",
    "is_verified": true,
    "two_factor": false,
    "created_at": "2025-12-07T10:00:00Z",
    "updated_at": "2025-12-07T11:00:00Z",
    "sessions": [
      {
        "id": "ses_xyz789",
        "sessionPrefix": "ses_xyz",
        "ipAddress": "192.168.1.1",
        "userAgent": "Mozilla/5.0...",
        "userDevice": "desktop",
        "lastUsedAt": "2025-12-07T11:00:00Z",
        "createdAt": "2025-12-07T10:00:00Z",
        "expiresAt": "2025-12-14T10:00:00Z",
        "status": "active"
      }
    ],
    "sessionCount": 1
  }
}

Admin - Update User ​

Update any user's information (admin/superadmin only).

Endpoint ​

http
PUT /auth/admin/users/:id

Headers ​

http
X-Session-ID: ses_admin_xyz
Content-Type: application/json

Request Body ​

json
{
  "name": "John",
  "last_name": "Doe",
  "user_name": "johndoe",
  "email": "newemail@example.com",
  "phone": "+1234567890",
  "is_verified": true,
  "two_factor": false,
  "user_type": "customer",
  "dob": "1990-01-01",
  "gender": "male",
  "reference_id": "ref_123",
  "recovery_email": "recovery@example.com",
  "tmz": "America/New_York"
}

Response ​

json
{
  "success": true,
  "data": {
    "id": "usr_abc123",
    "email": "newemail@example.com",
    "name": "John",
    "last_name": "Doe",
    "user_type": "customer",
    "user_name": "johndoe",
    "picture": null,
    "phone": "+1234567890",
    "is_verified": true,
    "two_factor": false,
    "dob": "1990-01-01",
    "gender": "male",
    "reference_id": "ref_123",
    "recovery_email": "recovery@example.com",
    "tmz": "America/New_York",
    "created_at": "2025-12-07T10:00:00Z",
    "updated_at": "2025-12-07T12:00:00Z"
  }
}

Permission Restrictions

  • Only superadmin can modify superadmin users
  • Only superadmin can change user_type to/from superadmin
  • Admins cannot modify users with higher privileges

Admin - Change User Password ​

Change any user's password (admin/superadmin only).

Endpoint ​

http
POST /auth/password-change/admin

Headers ​

http
X-Session-ID: ses_admin_xyz
Content-Type: application/json

Request Body ​

json
{
  "userId": "usr_abc123",
  "newPassword": "NewPassword456!"
}

Response ​

json
{
  "success": true,
  "message": "Password updated successfully. User will need to log in again."
}

Session Invalidation

All active sessions for the user will be invalidated, forcing them to log in again with the new password.


Rate Limiting ​

User endpoints are rate-limited for security:

EndpointLimitWindow
GET /auth/me100 requests1 minute
PUT /auth/profile10 requests1 minute
POST /auth/upload/picture5 requests1 hour
POST /auth/password-change/self5 requests1 hour
POST /auth/password-reset/request3 requests1 hour
POST /auth/resend-verification3 requests1 hour

Next Steps ​