Docs
Introduction

Documentation

Learn how to integrate ConnectX into your application.

Users API Overview

Learn how to interact with the ConnectX Users API

The Users API allows you to manage user accounts in ConnectX. You can create users, update profiles, manage passwords, and handle user authentication.

Most API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Note: Some endpoints like password reset request and user creation do not require authentication.

All API endpoints are relative to the base URL:

https://connectx-backend-4o0i.onrender.com/api

Users

  • GET /users/ - List users
  • POST /users/ - Create a new user
  • GET /users/me/ - Get current user
  • PATCH /users/me/ - Update user profile
  • POST /users/change-password/ - Change password
  • POST /users/reset-password-request/ - Request password reset
  • POST /users/reset-password/ - Reset password

Available Roles

  • Admin - Full system access, can manage all tenants and users
  • Owner - Can manage their tenant and its users
  • Member - Can access tenant resources but with limited permissions
  • Customer - Basic user access for making purchases

Role-Based Access

  • Admins can create and manage users across all tenants
  • Owners can create and manage users within their tenant
  • Members can view user information within their tenant
  • Customers can only manage their own profile

Get a list of users. Admin users can see all users, while owners and members can only see users in their tenant.

Command

curl -X GET 'https://connectx-backend-4o0i.onrender.com/api/users/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Response

{
  "count": 2,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "John Doe",
      "email": "john@example.com",
      "role": "member",
      "tenant": "123e4567-e89b-12d3-a456-426614174001",
      "is_verified": true,
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    },
    {
      "id": "123e4567-e89b-12d3-a456-426614174002",
      "name": "Jane Smith",
      "email": "jane@example.com",
      "role": "customer",
      "tenant": "123e4567-e89b-12d3-a456-426614174001",
      "is_verified": true,
      "created_at": "2024-01-02T00:00:00Z",
      "updated_at": "2024-01-02T00:00:00Z"
    }
  ]
}

Create a new user. The role and permissions depend on who is creating the user.

Command

curl -X POST 'https://connectx-backend-4o0i.onrender.com/api/users/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "New User",
    "email": "newuser@example.com",
    "password": "securepassword123",
    "role": "member"
  }'

Response

{
  "id": "123e4567-e89b-12d3-a456-426614174003",
  "name": "New User",
  "email": "newuser@example.com",
  "role": "member",
  "tenant": "123e4567-e89b-12d3-a456-426614174001",
  "is_verified": false,
  "created_at": "2024-01-03T00:00:00Z",
  "updated_at": "2024-01-03T00:00:00Z"
}

Get details of the currently authenticated user.

Command

curl -X GET 'https://connectx-backend-4o0i.onrender.com/api/users/me/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json'

Response

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "name": "John Doe",
  "email": "john@example.com",
  "role": "member",
  "tenant": "123e4567-e89b-12d3-a456-426614174001",
  "is_verified": true,
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z"
}

Update the current user's profile information.

Command

curl -X PATCH 'https://connectx-backend-4o0i.onrender.com/api/users/me/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: multipart/form-data' \
  -F 'name=Updated Name' \
  -F 'bio=New bio information' \
  -F 'phone_number=+1234567890' \
  -F 'avatar=@/path/to/avatar.png'

Response

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "name": "Updated Name",
  "email": "john@example.com",
  "role": "member",
  "tenant": "123e4567-e89b-12d3-a456-426614174001",
  "is_verified": true,
  "bio": "New bio information",
  "phone_number": "+1234567890",
  "avatar_url": "https://example.com/avatars/user-123.png",
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-04T00:00:00Z"
}

Change the current user's password.

Command

curl -X POST 'https://connectx-backend-4o0i.onrender.com/api/users/change-password/' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "old_password": "currentpassword123",
    "new_password": "newsecurepassword456"
  }'

Response

{
  "message": "Password changed successfully"
}

Request a password reset email for a user.

Command

curl -X POST 'https://connectx-backend-4o0i.onrender.com/api/users/reset-password-request/' \
  -H 'Content-Type: application/json' \
  -d '{
    "email": "user@example.com"
  }'

Response

{
  "message": "Password reset email sent"
}

Reset a user's password using a reset token.

Command

curl -X POST 'https://connectx-backend-4o0i.onrender.com/api/users/reset-password/' \
  -H 'Content-Type: application/json' \
  -d '{
    "token": "reset-token-from-email",
    "new_password": "newsecurepassword456"
  }'

Response

{
  "message": "Password has been reset successfully"
}