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 emailStringYes The user's email address. passwordStringYes The user's password. This will be hashed before storage. usernameStringYes The user's unique username. firstNameStringNo The user's first name. lastNameStringNo The user's last name. roleStringYes The role assigned to the user (e.g., 'admin', 'user'). isActiveBooleanNo Whether the user account is active. Defaults to true. isVerifiedBooleanNo Whether the user's email is verified. Defaults to false. isPhoneVerifiedBooleanNo Whether the user's phone is verified. Defaults to false. onboardingCompletedBooleanNo Whether the user has completed onboarding. Defaults to false. oauthProfilesArray<Object>No An array of OAuth profiles linked to the user. omnixContactIdStringNo 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 _idStringYes The unique identifier of the user to update. emailStringNo The user's email address. usernameStringNo The user's unique username. firstNameStringNo The user's first name. lastNameStringNo The user's last name. roleStringNo The role assigned to the user (e.g., 'admin', 'user'). isActiveBooleanNo Whether the user account is active. isVerifiedBooleanNo Whether the user's email is verified. isPhoneVerifiedBooleanNo Whether the user's phone is verified. onboardingCompletedBooleanNo Whether the user has completed onboarding. oauthProfilesArray<Object>No An array of OAuth profiles linked to the user. omnixContactIdStringNo 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 _idStringYes 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 idStringYes 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 filterObjectNo An object to filter the results (e.g., { role: "user" }).sortObjectNo An object to define the sort order (e.g., { username: 1 }for ascending).pageNumberNo The page number to retrieve, starting from 1. pageSizeNumberNo 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 userIdStringYes The ID of the user whose password needs to be reset. newPasswordStringYes 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": {} }'