Knowledgebase

Add User

Method: POST
Endpoint: /api/addUser

Parameters

Parameter Type Required

Description 

name string Yes Name of the user you're adding
email string Yes Email of the user you're adding
password string Yes Password of the user you're adding
package_id int Yes Package id for user 
timezone string (default: 00:00) No Timezone of user you're adding
login_ips coma seprated valid ips No Restrict access to user your account by adding a range of trusted IP addresses
response 0, 1 (default: 0) No Get full response of the operation


Response Parameters

Parameter Type Description
status JSON Success or Error
result JSON Result of the operation
response JSON Output of the operation
 

Example Request (CURL)

<?php
// Authentication
$api_token	=	'API_KEY'; // Mumara API Key (can be found in Settings -> API Key)
$domain		=	'http://www.anydomain.com'; // Your Mumara Domain Name

// API Endpoint
$endpoint	=	'/api/addUser';

$params = [
    'email'         => '[email protected]',
    'password'      => 'secret789',
    'package_id'    => 1,
    'timezone'      => '+05:00',
    'login_ips'     => '192.168.1.1,192.168.1.2',
    'name'          => 'David Seagal',
    'response'      => 1
];

// Defining cURL Request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$domain.$endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_HTTPHEADER,
    array('Content-Type: application/json', 'Authorization: Bearer ' . $api_token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Executing cURL
$output = curl_exec ($ch);

// Printing Output
echo "<pre>";
echo json_encode(json_decode($output),JSON_PRETTY_PRINT );

// Closing cURL
curl_close ($ch);
?>

 

Example Response (JSON)

{
    "status": "success",
    "result": "User has been successfully created.",
    "response": {
        "name": "David Seagal",
        "email": "[email protected]",
        "login_ips": "192.168.1.1,192.168.1.2",
        "role": "client",
        "is_client": 1,
        "user_id": 2,
        "time_zone": "+5:+00",
        "package_id": 1,
        "role_id": 3,
        "updated_at": "2020-12-29 12:56:19",
        "created_at": "2020-12-29 12:56:19",
        "id": 24
    }
}
Status value of the success response will be "success"

 

Example Error Response (JSON)

{
    "status": "error",
    "result": {
        "email": [
            "Error: Missing required parameter, email"
        ],
        "password": [
            "Error: Missing required parameter, password"
        ],
        "name": [
            "Error: Missing required parameter, name"
        ],
        "package_id": [
            "Error: Missing required parameter, package id"
        ]
    }
}

 

Possible Errors

  • Error: Missing required parameter, email
  • Error: User already exists.
  • Error: Package doesn`t exsit
POST
/api/addUser
Try it out