AppMage

AdminUserRpc

The AdminUserRpc provides administrative capabilities for managing user accounts within a specific subscription. These endpoints allow for creating, updating, deleting, retrieving, and performing specific actions like password resets and role inquiries for users. All operations are automatically scoped to the subscriptionId provided in the request context.

Endpoints

POST /api/rpc (Method: AdminUserRpc.create)

  • Description: Create a new user

  • Request Body:

    {
      "method": "AdminUserRpc.create",
      "params": {
        "email": "string",
        "password": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string",
        "role": "string",
        "isActive": "boolean",
        "isVerified": "boolean",
        "isPhoneVerified": "boolean",
        "onboardingCompleted": "boolean",
        "oauthProfiles": "array",
        "omnixContactId": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    email String Yes The user's email address.
    password String Yes The user's password. This will be hashed before storage.
    username String Yes The user's unique username.
    firstName String No The user's first name.
    lastName String No The user's last name.
    role String Yes The role assigned to the user (e.g., 'admin', 'user').
    isActive Boolean No Whether the user account is active. Defaults to true.
    isVerified Boolean No Whether the user's email is verified. Defaults to false.
    isPhoneVerified Boolean No Whether the user's phone is verified. Defaults to false.
    onboardingCompleted Boolean No Whether the user has completed onboarding. Defaults to false.
    oauthProfiles Array<Object> No An array of OAuth profiles linked to the user.
    omnixContactId String No An optional Omnix contact ID associated with the user.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string",
        "role": "string",
        "isActive": "boolean",
        "isVerified": "boolean",
        "isPhoneVerified": "boolean",
        "onboardingCompleted": "boolean",
        "oauthProfiles": "array",
        "omnixContactId": "string",
        "subscriptionId": "string",
        "serviceCode": "string",
        "createdAt": "Date",
        "updatedAt": "Date"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminUserRpc.create",
        "params": {
          "email": "[email protected]",
          "password": "securepassword123",
          "username": "newuser",
          "firstName": "New",
          "lastName": "User",
          "role": "user"
        }
      }'

POST /api/rpc (Method: AdminUserRpc.update)

  • Description: Update a user

  • Request Body:

    {
      "method": "AdminUserRpc.update",
      "params": {
        "_id": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string",
        "role": "string",
        "isActive": "boolean",
        "isVerified": "boolean",
        "isPhoneVerified": "boolean",
        "onboardingCompleted": "boolean",
        "oauthProfiles": "array",
        "omnixContactId": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The unique identifier of the user to update.
    email String No The user's email address.
    username String No The user's unique username.
    firstName String No The user's first name.
    lastName String No The user's last name.
    role String No The role assigned to the user (e.g., 'admin', 'user').
    isActive Boolean No Whether the user account is active.
    isVerified Boolean No Whether the user's email is verified.
    isPhoneVerified Boolean No Whether the user's phone is verified.
    onboardingCompleted Boolean No Whether the user has completed onboarding.
    oauthProfiles Array<Object> No An array of OAuth profiles linked to the user.
    omnixContactId String No An optional Omnix contact ID associated with the user.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string",
        "role": "string",
        "isActive": "boolean",
        "isVerified": "boolean",
        "isPhoneVerified": "boolean",
        "onboardingCompleted": "boolean",
        "oauthProfiles": "array",
        "omnixContactId": "string",
        "subscriptionId": "string",
        "serviceCode": "string",
        "createdAt": "Date",
        "updatedAt": "Date"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminUserRpc.update",
        "params": {
          "_id": "654321098765432109876543",
          "role": "admin",
          "isActive": true
        }
      }'

POST /api/rpc (Method: AdminUserRpc.delete)

  • Description: Delete a user

  • Request Body:

    {
      "method": "AdminUserRpc.delete",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The unique identifier of the user to delete.
  • Response:

    {
      "success": true,
      "data": {
        "acknowledged": true,
        "deletedCount": 1
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminUserRpc.delete",
        "params": {
          "_id": "654321098765432109876543"
        }
      }'

POST /api/rpc (Method: AdminUserRpc.findById)

  • Description: Get a user by ID

  • Request Body:

    {
      "method": "AdminUserRpc.findById",
      "params": {
        "id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    id String Yes The unique identifier of the user to retrieve.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "string",
        "email": "string",
        "username": "string",
        "firstName": "string",
        "lastName": "string",
        "role": "string",
        "isActive": "boolean",
        "isVerified": "boolean",
        "isPhoneVerified": "boolean",
        "onboardingCompleted": "boolean",
        "oauthProfiles": "array",
        "omnixContactId": "string",
        "subscriptionId": "string",
        "serviceCode": "string",
        "createdAt": "Date",
        "updatedAt": "Date"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminUserRpc.findById",
        "params": {
          "id": "654321098765432109876543"
        }
      }'

POST /api/rpc (Method: AdminUserRpc.getData)

  • Description: Get a list of users

  • Request Body:

    {
      "method": "AdminUserRpc.getData",
      "params": {
        "filter": {},
        "sort": {},
        "page": 1,
        "pageSize": 10
      }
    }
  • Parameters:

    Name Type Required Description
    filter Object No An object to filter the results (e.g., { role: "user" }).
    sort Object No An object to define the sort order (e.g., { username: 1 } for ascending).
    page Number No The page number to retrieve, starting from 1.
    pageSize Number No The number of items per page.
  • Response:

    {
      "success": true,
      "data": {
        "docs": [
          {
            "_id": "string",
            "email": "string",
            "username": "string",
            "firstName": "string",
            "lastName": "string",
            "role": "string",
            "isActive": "boolean",
            "isVerified": "boolean",
            "isPhoneVerified": "boolean",
            "onboardingCompleted": "boolean",
            "oauthProfiles": "array",
            "omnixContactId": "string",
            "subscriptionId": "string",
            "serviceCode": "string",
            "createdAt": "Date",
            "updatedAt": "Date"
          }
        ],
        "totalDocs": "number",
        "limit": "number",
        "page": "number",
        "totalPages": "number",
        "hasNextPage": "boolean",
        "hasPrevPage": "boolean"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminUserRpc.getData",
        "params": {
          "filter": { "role": "user" },
          "page": 1,
          "pageSize": 5
        }
      }'

POST /api/rpc (Method: AdminUserRpc.resetPassword)

  • Description: Admin action to reset a user's password.

  • Request Body:

    {
      "method": "AdminUserRpc.resetPassword",
      "params": {
        "userId": "string",
        "newPassword": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    userId String Yes The ID of the user whose password needs to be reset.
    newPassword String Yes The new password for the user. Must be at least 8 characters long.
  • Response:

    {
      "success": true,
      "data": "boolean"
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminUserRpc.resetPassword",
        "params": {
          "userId": "654321098765432109876543",
          "newPassword": "VerySecureNewPassword123!"
        }
      }'

POST /api/rpc (Method: AdminUserRpc.getAvailableRoles)

  • Description: Gets the list of available roles for user assignment.

  • Request Body:

    {
      "method": "AdminUserRpc.getAvailableRoles",
      "params": {}
    }
  • Parameters:

    Name Type Required Description
    (None)
  • Response:

    {
      "success": true,
      "data": [
        "admin",
        "user",
        "custom_role_1"
      ]
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "AdminUserRpc.getAvailableRoles",
        "params": {}
      }'