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.

Headers

NameTypeDescription

apikey*

string

apikey

Authorization*

string

Bearer access-token

HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {
        "UserRoles": [
            {
                "id": <role-id>,
                "name": "<role-name>"
            },
            ...
        ],
        "AllGroups": [
            {
                "<role-id>": "<role-name>"
            },
            ...
        ],
        "g_placed": <geneology_placed_or_not>
    }
}

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.

Headers

NameTypeDescription

apikey*

string

apikey

Authorization*

string

Bearer access token

Request Body

NameTypeDescription

unique_id*

string

User unique id.

upgrade_to*

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

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.

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>',
    'Authorization': 'Bearer <access-token>' 
  },
  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>',
    'Authorization: Bearer <access-token>'
  ),
));

$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.

Headers

NameTypeDescription

apikey*

string

apikey

Authorization*

string

Bearer access token

Request Body

NameTypeDescription

unique_id*

string

user unique id

downgrade_to*

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*

string

Block the user with role downgrade, Possible values are: True - Block user account. False - Do not block.

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>',
    'Authorization': 'Bearer <access-token>'
  },
  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>',
    'Authorization: Bearer <access-token>'
  ),
));

$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.

Last updated