User Roles

Manage User Roles

Get User Roles

get
​

β€Žhttps://<domain>/<api prefix>/<version>/user/get/roles/
This API endpoint will give you the user roles details.
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access-token
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"UserRoles": [
{
"id": <role-id>,
"name": "<role-name>"
},
...
]
}
}

Sample code

Node

var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/user/get/roles/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access-token>',
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/get/roles/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"apikey: <apikey>",
"Authorization: Bearer <access-token>",
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;

Upgrade User Role

post
​

β€Žhttps://<domain>/<api prefix>/<version>/upgrade/user-role/
This API endpooint will upgrade a user role from customer to preferred customer or to member.
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Body Parameters
unique_id
required
string
User unique id.
upgrade_to
required
string
Upgrade options, possible values are: Member - Upgrade user role from customer to member. Preferred Customer - Upgrade user role from customer to preferred customer.
api_place_genealogy
optional
string
api_place_genealogy is required when upgrading the role from customer to preferred customer. Possible values are: True - Place the user in genealogy when upgrading to preferred customer False - Do not place the user in genealogy.
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/upgrade/user-role/',
'headers': {
'apikey': '<apikey>'
},
formData: {
'unique_id': '<user_unique_id>',
'upgrade_to': '<upgrade_option>',
'api_place_genealogy': '<True_or_False>'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/upgrade/user-role/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('unique_id' => '<user_unique_id>','upgrade_to' => '<upgrade_option>','api_place_genealogy' => '<True_or_False>'),
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>'
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;

Status Code

Error Type

Field

Description

400

Validation Error

unique_id

This field is required and its may not be blank.

User not exist or invalid unique id.

Ensure this field has no more than 255 characters.

400

Validation Error

upgrade_to

This field is required and its may not be blank.

Invalid upgrade option, Choose a valid one.

400

Validation Erorr

api_place_genealogy

This field is required and its may not be blank.

Choose a valid option.

403

Request Failed

​

User role is already upgraded.

User already have a member role.

User already have a preferred customer role.

Free user place genealogy disabled, can't upgrade user role.

Free package for user role upgrade is not created.

User role upgrade option not found.

Created free package is not a customer privilaged package.

Created free package is not a member privilaged package.

Downgrade User Role

post
​

β€Žhttps://<domain>/<api prefix>/<version>/downgrade/user-role/
This API endpoint will downgrade a user role from member to preferred customer or to customer.
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Body Parameters
unique_id
required
string
user unique id
downgrade_to
required
string
Downgrade options, possible values are: Customer - Downgrade user role from member to customer. Preferred Customer - Downgrade user role from member to preferred customer
api_block_user
optional
string
Block the user with role downgrade, Possible values are: True - Block user account. False - Do not block.
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Sample Code

Node

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/downgrade/user-role/',
'headers': {
'apikey': '<apikey>'
},
formData: {
'unique_id': '<user_unique_id>',
'downgrade_to': '<downgrade_option>'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/downgrade/user-role/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('unique_id' => '<user_unique_id>','downgrade_to' => '<downgrade_option>'),
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>'
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;
​

Error Responses

Status Code

Error Type

Field

Description

400

Validation Error

unique_id

This field is required and its may not be blank.

User not exist or invalid unique id.

Ensure this field has no more than 255 characters.

400

Validation Error

downgrade_to

This field is required and its may not be blank.

Invalid downgrade option, Choose a valid one.

400

Validation Erorr

api_block_user

Choose a valid option.

403

Request Failed

​

User already have a downgraded role.

User already have a customer role.

User already have a preferred customer role.

Somthing went wrong.

​