Bloxby Support Portal
  • Home
  • Knowledge Base
  • Forums
  • Register
  • Live Chat

Knowledge Base

  1. Home
  2. Knowledge Base
  3. Developer Manual
  4. Integration
  5. RESTful API
  6. RESTful API end-points
  7. RESTful API end-point: /api/users/

RESTful API end-point: /api/users/

  • Created November 16, 2018
  • Author Andrew Ozols
  • Category RESTful API end-points
  • Description
    This end-points gives access to the Users section.
  • Available methods
    GET, POST, PUT, DELETE

 

GET

Get all users available.

Required headers

  • X-API-KEY
  • Authorization

Payload

Not applicable

Return

Returns a JSON string containing a list of the users currently available.

Example (php)

The example below retrieves a JSON string ($result) containing all the users currently in the application:

$curl = curl_init();
 
// Make sure you insert the correct URL below; this should point to your copy of Bloxby
$url = "http://getpageless.com/api/users/";
 
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions)
curl_setopt($curl, CURLOPT_USERPWD, "user:password"); 
 
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
 
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 
$result = curl_exec($curl);
 
curl_close($curl);
 
echo $result;

 

 

POST

Creates a new user.

Required headers

  • X-API-KEY
  • Authorization

Payload

A POST request should have a form-data encoded payload, containing name-value pairs corresponding to attributes of the new user. The following are allowed:

  • first_name [required, string]: first name of the new user
  • last_name [required, string]: last name of the new user
  • email [required, string]: email address of the new user
  • password [required, string]: password for the new user
  • type [required, string]: user type for the new user (should be either “User” or “Admin”)
  • package_id [required, number]: package ID for the package the new user should be subscribed to

Return

On success, the end-point will contain a JSON string representing the created user.

Example (php)

The following example creates a new user:

$curl = curl_init();

// Make sure you insert the correct URL below; this should point to your copy of Bloxby 
$url = "http://getpageless.com/api/users/";
 
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions) 
curl_setopt($curl, CURLOPT_USERPWD, "user:password"); 
 
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
 
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 
$data = array();
$data['first_name'] = "John";
$data['last_name'] = "Doe";
$data['email'] = "[email protected]";
$data['password'] = "MySecretPassword";
$data['first_name'] = "John";
$data['package_id'] = 1;
$data['type'] = "User";
 		 
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
 
$result = curl_exec($curl);
 
curl_close($curl);
 
echo $result;

 

PUT

Updates an existing user.

Required headers

  • X-API-KEY
  • Authorization

Payload

A PUT request should append a valid user ID to the end-point url, as such: “/api/users/12”.

A PUT request should have a x-www-form-urlencoded encoded payload, containing name-value pairs corresponding to attributes of the new package. The following are allowed:

  • first_name [optional, string]: first name of the new user
  • last_name [optional, string]: last name of the new user
  • email [optional, string]: email address of the new user
  • password [optional, string]: password for the new user
  • type [optional, string]: user type for the new user (should be either “User” or “Admin”)
  • status [optional, string]: indicates if the user account is enabled or disabled (should be either “Active” or “Inactive”)

Return

On success, the end-point will contain a JSON string representing the updated user.

Example (php)

The following example edits the user with ID = 2:

$curl = curl_init();
 
// Make sure you insert the correct URL below; this should point to your copy of Bloxby and included the ID for the user you'd like to edit 
$url = "http://getpageless.com/api/users/2";
 
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions) c
url_setopt($curl, CURLOPT_USERPWD, "user:password");
 
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
 
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
 
$data = array();
$data['first_name'] = "Johnn";
 		 
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
 
$result = curl_exec($curl);
 
curl_close($curl);
 
echo $result;

 

DELETE

Deletes a single user from the application.

Required headers

  • X-API-KEY
  • Authorization

Payload

A DELETE request should append a valid user ID to the end-point url, as such: “/api/users/12”.

Return

On success, the API will return a message confirming deletion of the user.

Example (php)

The following example deletes user with ID = 2:

$curl = curl_init();
 
// Make sure you insert the correct URL below; this should point to your copy of Bloxby and included the ID for the user you'd like to delete 
$url = "http://getpageless.com/api/users/2";
 
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// Replace user and password with a proper account (should have ADMIN persmissions) 
curl_setopt($curl, CURLOPT_USERPWD, "user:password");
 
// Replace key with a proper access key
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-API-KEY: key'));
 
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
 
$result = curl_exec($curl);
 
curl_close($curl);
 
echo $result;

 

Was this article helpful?

Yes No

Related Articles

  • RESTful API end-point: /api/packages/
    • 0
    • 1941

Leave A Comment? Cancel Reply

You must be logged in to post a comment.

Knowledge Base Categories

  • User Manual
  • General
    • Frequently Asked Questions
  • Developer Manual
    • Updates
    • Integration
    • Extending Bloxby
  • Admin Manual
    • Managing Blocks & Components

Popular Articles

  • Server Requirements
  • Installation Guide
  • Terms and Definitions
  • How to modify or develop Bloxby
  • How to configure Bloxby page builder

Knowledge Base Authors

  • Andrew Ozols
    Andrew Ozols
    Articles Authored: 138
  • Herbert
    Herbert
    Articles Authored: 4

Knowledge Base Authors

  • Andrew Ozols
    Andrew Ozols
    Articles Authored: 138
  • Herbert
    Herbert
    Articles Authored: 4

Forum Statistics

Forums
11
Topics
1,086
Replies
6,211
Topic Tags
250
© Bloxby 2019, All rights reserved