How to Create Delete & Update a User via API

 

You can implement an API to create, delete, and update a user to the Knowledge Base.

 

In this article, you’ll learn:

  1. Create user API
  2. Delete user API
  3. Update user API

1. How to Create a User via API

 

Endpoint URL:

 

The endpoint URL given below is used to call the rest API. POST will be used as the request method. JSON will be your request format.

 

POST https://www.helpdocsonline.com/proprofsapi/user/v1

 

Request Parameters

 

Name Required Type Description
api_key Yes String Your private API key for the FAQ. The API key is available at: Settings > In-App Help > API key
action Yes String The action of the API “create.”
users Yes String/Array You can create one user at a time. Sample like email, name, role, access_sites, group

1. role: It can be any value from ‘Admin’, ‘Editor’, ‘Contributor’, ‘Viewer’.

2. access_sites: Allowed values are: 0 or 1. Pass 1 if you want to give access to all the sites and pass 0 if you don’t want to provide access to any of the sites (it can be used when you don’t want to give access to all the sites but want to give access according to any group)

3. group: Pass the group names here separated by a comma (if more than one)

 

 

Sample Code | JSON

 

Accept: application/json
Content-Type: application/json
{
        "api_key":  "<your API key>",
        "action":   "create",
        "user":
        {
                 "email":   "sample@mycompany.com",
                 "name":   "Sample",
                 "role":    "Contributor",
                 "access_sites":    0,
                 "group":    "groupName1,groupName2"                
         }
}

 

 

Sample Code | PHP Script

 

$data = array();
$data['api_key'] = '<your API key>';
$data['action'] = 'create';
$users= array('email'=>'sample@mycompany.com','name'=>'Sample','role'=>'Contributor','access_sites'=>0,'group'=>'groupName');
$data['users'] = array($user1);
echo json_encode($data);

 

Response Format

JSON

 

Example Response [Success]

 

Content-Type: application/json
[
 {
        "status":   "SUCCESS",
        "msg":   "User added successfully"
 }
]

 

Name Required
status Success
msg User added successfully

 

2. How to Delete a User via API

 

Endpoint URL:

 

The endpoint URL given below is used to call the rest API. POST will be used as the request method. JSON will be your request format.

 

POST https://www.helpdocsonline.com/proprofsapi/user/v1

 

Request Parameters

 

Name Required Type Description
api_key Yes String Your private API key for the FAQ. The API key is available in the manage account section of the super admin.
action Yes String The action of the API “delete.”
users Yes String Enter the email id of the user which you want to delete. 

 

 

Note: We can’t delete the master user from this API.

 

Sample Code | JSON

 

Accept: application/json
Content-Type: application/json
{
        "api_key":  "<your API key>",
        "action":   "delete",
        "user":
        {
                 "email":   "sample@mycompany.com"            
         }
}

 

 

Sample Code | PHP Script

 

$data = array();
$data['api_key'] = '<your API key>';
$data['action'] = 'delete';
$user= array('email'=>'sample@mycompany.com');
$data['users'] = array($user);
echo json_encode($data);

 

Response Format

JSON

 

Example Response [Success]

 

Content-Type: application/json
[
 {
        "status":   "SUCCESS",
        "msg":   "User deleted successfully"
 }
]

 

Name Required
status Success
msg User deleted successfully

 

 3. How to Update a User via API

 

Endpoint URL:

 

The endpoint URL given below is used to call the rest API. POST will be used as the request method. JSON will be your request format.

 

 

Name Required Type Description Default
api_key Yes String

Your private API key for the FAQ.

 

The API key is available at:

Login as Master user > Edit account (Right top hamburger menu)

 

 
action Yes String The action of the API. “update.”  

name

Yes String

User’s name 

 
password No String User’s Password Minimum length = 8 characters with alphanumeric
email Yes String Email ID of the User  
status Yes Numeric

0 = Inactive

1= Active

 
access_sites Yes String Comma separate site ids  
access_groups No String Comma separate group names  

 

Example Request

 

POST https://www.helpdocsonline.com/proprofsapi/article/v1

 

Accept: application/json
{  

"Action":"update",
"Api_key":"ddsdsdsf",
"name":"Proprofs Help",
"Password":"12345678",
"email":"webmaster@dev.com",
"Status":1,
"Access_sites":"14033,40625",
"access_groups":"Test,Yog

}

 

Response Format

JSON

 

Example Response

 

Content-Type: application/json
[
 {
        "status":   "SUCCESS",
        "msg":   "User updated successfully"
 }
]

 

That is all about creating, deleting, and updating users via API.

 

 

Was this information helpful?
© 2005 - 2024 ProProfs
-
add chat to your website