Overview
The following are the REST endpoints available for the Administration section of the ProcessMaker REST API 1.0:
All these endpoints and their methods are explained below.
- Overview
- Users
- Get Users List:
GET /users
- Get User Information:
GET /user/{usr_uid}
- Create User:
POST /user
- Upload User Image:
POST /user/{usr_uid}/image-upload
- Update User Information:
PUT /user/{usr_uid}
- Delete User:
DELETE /user/{usr_uid}
- Groups
- Get Groups List:
GET /groups
- Get Group Information:
GET /group/{grp_uid}
- Create Group:
POST /group
- Update Group:
PUT /group/{usr_uid}
- Delete Group:
DELETE /group/{grp_uid}
- Get Group Members:
GET /group/{grp_uid}/users
- Get Available Users:
GET /group/{grp_uid}/available-users
- Assign User to Group:
POST /group/{grp_uid}/user
- Unassign User from Group:
DELETE /group/{grp_uid}/user/{usr_uid}
- Departments
- Get Departments List:
GET /departments
- Get Department Information:
GET /department/{dep_uid}
- Create Department:
POST /department
- Update Department:
PUT /department/{dep_uid}
- Delete Department:
DELETE /department/{dep_uid}
- Get Users List for Department:
GET /department/{dep_uid}/assigned-user
- Available Users List for Department:
GET /department/{dep_uid}/available-user
- v.2.8: Assign User to Department:
PUT /department/{dep_uid}/assign-user/{usr_uid}
- v.3.0+: Assign User to Department:
POST /department/{dep_uid}/assign-user
- Unassign User from Department:
PUT /department/{dep_uid}/unassign-user/{usr_uid}
- Set Manager for Department:
PUT /department/{dep_uid}/set-manager/{usr_uid}
- Roles
- Get Roles List:
GET /roles
- Get Role Information:
GET /role/{rol_uid}
- Create Role:
POST /role
- Update Role:
PUT /role/{rol_uid}
- Delete Role:
DELETE /role/{rol_uid}
- Get Users with Role:
GET /role/{rol_uid}/users
- Available Users for Role:
GET /role/{rol_uid}/available-users
- Assign User to Role:
POST /role/{rol_uid}/user
- Unassign User from Role:
DELETE /role/{rol_uid}/user/{usr_uid}
- Permissions List for Role:
GET /role/{rol_uid}/permissions
- Available Permissions for Role:
GET /role/{rol_uid}/available-permissions
- Assign Permission to Role:
POST /role/{rol_uid}/permission
- Unassign Permission from Role:
DELETE /role/{rol_uid}/permission/{per_uid}
- PM Tables
- PM Tables List:
GET /pmtable
- Get PM Table Structure:
GET /pmtable/{pmt_uid}
- Get PM Table Data:
GET /pmtable/{pmt_uid}/data
- Create PM Table:
POST /pmtable
- Add PM Table Data:
POST /pmtable/{pmt_uid}/data
- Update PM Table Structure:
PUT /pmtable/{pmt_uid}
- Update PM Table Data:
PUT /pmtable/{pmt_uid}/data
- Delete PM Table:
DELETE /pmtable/{pmt_uid}
- Delete PM Table Data:
DELETE /pmtable/{pmt_uid}/data/...
- Categories
- Get Categories List:
GET /project/categories
- Get Category Information:
GET /project/category/{cat_uid}
- Create Category:
POST /project/category
- Update Category:
PUT /project/category/{cat_uid}
- Delete Category:
DELETE /project/category/{cat_uid}
- Calendars
Users
The following REST endpoints are used to manage users in ProcessMaker.
2.
Get information of a specific user
3.
Create user
5.
Update the information of a user
6.
Delete user
Available methods:
Get Users List: GET /users
Returns a list of all users in the workspace, including users with "INACTIVE" and "VACATION" status. The users are returned in the order which they appear in the wf_<WORKSPACE>.USERS table.
- GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
URL Parameters:
-
Name Type Description workspace String Workspace name
Optional GET Parameters:
-
Name Type Description filter string Case insensitive string to search for in the user's first name, last name or username.
For example,"api/1.0/workspace/users?filter=mit"
would return the users "smith", "Mitter" and "solmit".start integer The number of users where the list begins. The counting starts from number 0, which is always the "admin" user.
For example,"api/1.0/workspace/users?start=3"
would start the list of users with the fourth user.limit integer The maximum number of users which are returned in the list.
For example if wanting to return 10 users at a time and there are 25 users in total, then call this endpoint 3 times:"api/1.0/workspace/users?limit=10"
(returns users 0-9)"api/1.0/workspace/users?start=10&limit=10"
(returns users 10-19)"api/1.0/workspace/users?start=20&limit=10"
(returns users 20-24)
Result:
If a successful request, the HTTP status code is 200 and it returns a JSON array of user objects with the following structure:
Element | Description | Example |
---|---|---|
[ | Start array | |
{ | Start user object | |
"usr_uid" | User's unique ID. | "11826545154db794ca22b52025081429" |
"usr_username" | The username, which is unique and is used to login to ProcessMaker | "jdoe" |
"usr_password" | The MD5 hash for the user's password. | "21232f297a57a5a743894a0e4a801fc3" |
"usr_firstname" | The user's first name. | "John Jake" |
"usr_lastname" | The user's last name. | "Doe" |
"usr_email" | The user's email address. | "jdoe@example.com" |
"usr_due_date" | The date in "YYYY-MM-DD" when the user's account will expire. After this date, the user will not be able to login to ProcessMaker. | "2020-01-01" |
"usr_create_date" | The datatime in "YYYY-MM-DD HH:MM:SS" format when the user was created. | "2005-11-30 08:11:57" |
"usr_update_date" | The datetime in "YYYY-MM-DD HH:MM:SS" format when the user's record was last updated. | "2014-05-23 18:36:19" |
"usr_status" | The user's status, which can be "ACTIVE", "INACTIVE" or "VACATION" | "ACTIVE" |
"usr_country" | Two letter ISO country code. See the wf_<WORKSPACE>.ISO_COUNTRY table in the database. | "US" (United States) |
"usr_city" | One or two letter code to identify the region, state or province. Note: This field is misnamed. See the wf_<WORKSPACE>.ISO_SUBDIVISION table in the database. | "FL" (Florida in the US) |
"usr_location" | Code which is 1 to 3 letters to identify the city or locality. See the wf_<WORKSPACE>.ISO_LOCATION table in the database. | "MMK" (Miami Lakes in Florida) |
"usr_address" | The user's address. This field may contain line breaks (\n). | "540 Mytle Lane" |
"usr_phone" | The user's phone number. | "1-305-402-1234" |
"usr_fax" | The user's fax number. | "1-305-402-0282" |
"usr_cellular" | The user's cellular telephone number. | "1-305-675-1400" |
"usr_zip_code" | The user's zip or postal code | "46135" |
"dep_uid" | The unique ID of the user's department. If the user isn't a member of a department then an empty string "". | "54883398754db7993002ae1030708956" |
"usr_position" | The user's position. | "Accountant" |
"usr_resume" | Always set to "" since the resume is no longer used. | "" |
"usr_birthday" | The user's birthday in "YYYY-MM-DD" format. | "1973-02-25" |
"usr_role" | The user's role, which can be "PROCESSMAKER_ADMIN", "PROCESSMAKER_OPERATOR", "PROCESSMAKER_MANAGER" or a custom role. | "PROCESSMAKER_ADMIN" |
"usr_reports_to" | The unique ID of the manager to whom the user reports. This is used when using a Reports To assignment rule. If the user is not a member of a department, then an empty string "". | "14680180454ca4477335a27034362107" |
"usr_replaced_by" | Unique ID of another user who will replace this user if status changes to "INACTIVE" or "VACATION". Set to empty string "" if there is no replacement user. | "14680180454ca4477335a27034362107" |
"usr_ux" | The user experience, which is the type of interface seen by the user. It can be "NORMAL", "SWITCHABLE", "MOBILE" or "SINGLE". | "NORMAL" |
}, | End user object. | |
... | Additional user objects. | |
] | End array. |
If a bad request, than the HTTP status code is set to 400 or greater and it returns a JSON error object.
Example in JavaScript:
This JavaScript example creates a array of active users. It obtains the list of all the users for the workspace and stores it in an array named aUsers
. Then it loops through the array and checks whether the user's status is "ACTIVE"
. If so, it adds the user's UID and username to an new array named aActiveUsers
.
if (!accessToken) {
accessToken = getAccessToken(); //custom function to get a new access token
}
var reqUsers = new XMLHttpRequest();
//set address to your installation of ProcessMaker:
reqUsers.open("GET", "https://example.com/api/1.0/workflow/users", true);
reqUsers.setRequestHeader("Authorization", "Bearer " + accessToken);
reqUsers.onreadystatechange = function() {
if (reqUsers.readyState==4 && reqUsers.status==200) {
var aActiveUsers = [];
var aUsers = JSON.parse(reqUsers.responseText);
for (var i = 0; i < aUsers.length; i++) {
if (aUsers[i].usr_status == "ACTIVE") {
aActiveUsers.push({
uid: aUsers[i].usr_uid,
username: aUsers[i].usr_username
});
}
}
}
}
reqUsers.send(null);
Example in PHP:
This PHP example creates a array of active users. It obtains the list of all the users for the workspace and stores it in an array named $aUsers
. Then it loops through the array and checks whether the user's status is "ACTIVE"
. If so, it adds the user's UID and username to an new array named $aActiveUsers
.
$apiServer = "https://example.com"; //set to your ProcessMaker address
$ch = curl_init($apiServer . "/api/1.0/workflow/users");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aUsers = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$aActiveUsers = array();
if ($statusCode != 200) {
if (isset ($aUsers) and isset($aUsers->error))
print "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
else {
foreach ($aUsers as $oUser) {
if ($oUser->usr_status == "ACTIVE") {
$aActiveUsers[] = array("uid" => $oUser->usr_uid, "username" => $oUser->usr_username);
}
}
}
Get User Information: GET /user/{usr_uid}
Get information about a specified user.
- GET /api/1.0/{workspace}/user/{usr_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name usr_uid String User UID
Result:
Returns the HTTP status code 200 and the same user object as the GET /users endpoint. For example:
usr_uid: "66065213554dd1feb48fe79020620851",
usr_username: "johndoe",
usr_password: "5e8ff9bf55ba3508199d22e984129be6",
usr_firstname: "John",
usr_lastname: "Doe",
usr_email: "janedoe@example.com",
usr_due_date: "2020-12-31",
usr_create_date: "2015-02-12 16:49:31",
usr_update_date: "2015-02-12 16:49:31",
usr_status: "ACTIVE",
usr_country: "US",
usr_city: "IN",
usr_location: "GXQ",
usr_address: "740 Turtle Dove lane",
usr_phone: "1-765-653-4478",
usr_fax: "1-765-862-8712",
usr_cellular: "1-755-644-8723",
usr_zip_code: "46135",
dep_uid: "75740355754dd28ba73d7d6082172936",
usr_position: "Factory Foreman",
usr_resume: "",
usr_birthday: "1980-02-12",
usr_role: "PROCESSMAKER_OPERATOR",
usr_reports_to: "14680180454ca4477335a27034362107",
usr_replaced_by: "14680180454ca4477335a27034362107",
usr_ux: "NORMAL"
}
If a bad request, then it returns the HTTP status code 400 and an error object like the following:
error: {
code: 400,
message: "Bad Request: invalid value specified for `usr_uid`. Given string is too short"
}
}
Example in PHP:
$userId = '55324179754ca442baeb994077387342'; //set to the unique ID of a user
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . '/api/1.0/workflow/user/' . $userId);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oUser = json_decode(curl_exec($ch));
if (!isset($oUser)) {
print "Error accessing $apiServer: \n" . curl_error($ch);
}
elseif (isset($oUser->error)) {
print "Error in $apiServer: \nCode: {$oUser->error->code}\nMessage: {$oUser->error->message}\n";
}
else {
$fullName = $oUser->usr_firstname . ' ' . $oUser->usr_lastname;
}
curl_close($ch);
Create User: POST /user
Create a new user.
- POST /api/1.0/{workspace}/user
URL Parameters:
-
Name Type Description workspace String Workspace name
POST Parameters:
-
Name Type Description usr_username String Username which is used to login to ProcessMaker and is unique. usr_firstname String User's first name usr_lastname String User's last name usr_email String User's email address usr_due_date String The date in "YYYY-MM-DD" when the user's account will expire. After this date, the user will not be able to login to ProcessMaker. Ex: "2020-12-31" usr_status String The user's status, which can be "ACTIVE", "INACTIVE" or "VACATION". usr_role String The user's role, which can be "PROCESSMAKER_ADMIN", "PROCESSMAKER_OPERATOR", "PROCESSMAKER_MANAGER" or a custom role. usr_new_pass String The user's password. Remember that passwords should adhere to the password security policies. usr_cnf_pass String Enter the password a second time to confirm it. usr_address String Optional. The user's address. Use \n to include line breaks in the address. Ex: "345 Radcliff Drive\nC/O Brad Williams" usr_zip_code String Optional. User's zip or postal code. usr_country String Optional. Two letter ISO country code. See the wf_<WORKSPACE>.ISO_COUNTRY table in the database. usr_city String Optional. One or two letter code to identify the region, state or province. Note: This field is misnamed. See the wf_<WORKSPACE>.ISO_SUBDIVISION table in the database. usr_location String Optional. Code which is 1 to 3 letters long to identify the city or locality. See the wf_<WORKSPACE>.ISO_LOCATION table in the database. usr_phone String Optional. The user's telephone number. usr_position String Optional. The user's position in the organization. usr_replaced_by String Optional. Unique ID of another user who will replace this user if his/her status changes to "INACTIVE" or "VACATION". usr_calendar String Optional. The unique ID of the calendar which is used to calculate the due dates of tasks which the user is assigned to work on. To get the UID of a calendar, see the wf_<WORKSPACE>.CALENDAR_DEFINITION.CALENDAR_UID field in the database.
Result:
If a user was successfully created, the HTTP status code will be set to 200 and a JSON object with information about the new user is returned:
usr_uid: "75740355754dd28ba73d7d6082172936",
usr_username: "janedoe",
usr_password: "5e8ff9bf55ba3508199d22e984129be6",
usr_firstname: "Jane",
usr_lastname: "Doe",
usr_email: "janedoe@example.com",
usr_due_date: "2020-12-31",
usr_create_date: "2015-02-12 17:27:06",
usr_update_date: "2015-02-12 17:27:06",
usr_status: "ACTIVE",
usr_country: "US",
usr_city: "IN",
usr_location: "GXQ",
usr_address: "740 Turtle Dove lane",
usr_phone: "1-765-653-4478",
usr_fax: "",
usr_cellular: "",
usr_zip_code: "46135",
dep_uid: "",
usr_position: "Head Accountant",
usr_resume: "",
usr_birthday: "2015-02-12",
usr_role: "PROCESSMAKER_OPERATOR",
usr_reports_to: "",
usr_replaced_by: "14680180454ca4477335a27034362107",
usr_ux: "NORMAL"
}
If an error occurred, the HTTP status code will be set to 400 or greater and a JSON object will be returned like the following:
error: {
code: 400,
message: "Bad Request: usr_username. Username 'janedoe' already exists"
}
}
PHP Example:
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array(
'usr_username' => "janedoe",
'usr_firstname' => "Jane",
'usr_lastname' => "Doe",
'usr_email' => "janedoe@example.com",
'usr_due_date' => "2020-12-31",
'usr_status' => "ACTIVE",
'usr_role' => "PROCESSMAKER_OPERATOR",
'usr_new_pass' => "p4s5w0rD",
'usr_cnf_pass' => "p4s5w0rD",
'usr_address' => "740 Turtle Dove lane",
'usr_zip_code' => "46135",
'usr_country' => "US",
'usr_city' => "IN",
'usr_location' => "GXQ",
'usr_phone' => "1-765-653-4478",
'usr_position' => "Head Accountant",
'usr_replaced_by'=> "14680180454ca4477335a27034362107",
'usr_calendar' => "91552296454dd0c63c477c6014743059"
);
$ch = curl_init($apiServer . "/api/1.0/workflow/user");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oUser = json_decode(curl_exec($ch));
if (!isset($oUser)) {
print "Error accessing $apiServer: \n" . curl_error($ch);
}
elseif (isset($oUser->error)) {
print "Error in $apiServer: \nCode: {$oUser->error->code}\nMessage: {$oUser->error->message}\n";
}
else {
print "User '{$oUser->usr_username}' created with UID: {$oUser->usr_uid}\n";
}
curl_close($ch);
Upload User Image: POST /user/{usr_uid}/image-upload
Upload an image of the specified user, which will appear in the user's profile screen.
- POST /api/1.0/{workspace}/user/{usr_uid}/image-upload
URL Parameters:
-
Name Type Description workspace String Workspace name usr_uid String User UID
POST Parameters:
-
Name Type Description Examples USR_PHOTO string The full path on the ProcessMaker server where the image file is located. The image file must be JPEG, PNG or GIF format.
Note: If using PHP, make sure to place @ in front of the path to suppress error messages. Otherwise, this endpoint will not work."/home/bob/images/myphoto.jpg"
"C:\Users\bob\images\myphoto.gif"
Result:
Returns an HTTP status code of 200
if the image was uploaded correctly. Otherwise, returns 0
.
PHP Example:
$userId = '55324179754ca442baeb994077387342'; //set the unique ID of a user
$filePath = '/home/user/images/photo.jpg'; //set the file to upload
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/user/$userId/image-upload");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
//Notice the @ to suppress error messages:
curl_setopt($ch, CURLOPT_POSTFIELDS, array('USR_PHOTO' => "@" . $filePath));
curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
print "Error uploading user image:\nHTTP status code: $statusCode\n";
}
curl_close($ch);
If needing to upload image files which are not located on the ProcessMaker server, first use ssh2_scp_send() to copy the files to the ProcessMaker server, then use the code above to call the /api/1.0/{workspace}/user/{usr_uid}/image-upload endpoint.
$filename = basename($path);
$conn = ssh2_connect('www.example.com'); //set to the address of the ProcessMaker server
ssh2_auth_password($conn, 'username', 'password'); //set username & password to login to ProcessMaker server
ssh2_scp_send($conn, $path, "/remote/dir/$filename");
Update User Information: PUT /user/{usr_uid}
Update the information about a specified user.
- PUT /api/1.0/{workspace}/user/{usr_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name usr_uid String User UID
PUT Parameters:
Only set the fields which need to be updated. PUT parameters need to be URL-encoded. In PHP, place the parameters in an associative array and use http_build_query() to encode it. In JavaScript, place the parameters in an object and then use encodeURIComponent() to encode it.
-
Name Type Description usr_username String Optional. Username which is used to login to ProcessMaker and is unique. usr_firstname String Optional. User's first name usr_lastname String Optional. User's last name usr_email String Optional. User's email address usr_due_date String Optional. The date in "YYYY-MM-DD" when the user's account will expire. After this date, the user will not be able to login to ProcessMaker. Ex: "2020-12-31" usr_status String Optional. The user's status, which can be "ACTIVE", "INACTIVE" or "VACATION". usr_role String Optional. The user's role, which can be "PROCESSMAKER_ADMIN", "PROCESSMAKER_OPERATOR", "PROCESSMAKER_MANAGER" or a custom role. usr_address String Optional. The user's address. Use \n to include line breaks in the address. Ex: "345 Radcliff Drive\nC/O Brad Williams" usr_zip_code String Optional. User's zip or postal code. usr_country String Optional. Two letter ISO country code. See the wf_<WORKSPACE>.ISO_COUNTRY table in the database. usr_city String Optional. One or two letter code to identify the region, state or province. Note: This field is misnamed. See the wf_<WORKSPACE>.ISO_SUBDIVISION table in the database. usr_location String Optional. Code which is 1 to 3 letters long to identify the city or locality. See the wf_<WORKSPACE>.ISO_LOCATION table in the database. usr_phone String Optional. The user's telephone number. usr_cellular String Optional. The user's cellular phone number. usr_fax String Optional. The user's fax number. usr_position String Optional. The user's position in the organization. usr_birthday String Optional. The user's birthday in "YYYY-MM-DD" format. Ex: "1984-08-23" usr_replaced_by String Optional. Unique ID of another user who will replace this user if his/her status changes to "INACTIVE" or "VACATION". usr_new_pass String Optional. The user's password. Remember that passwords should adhere to the password security policies. usr_cnf_pass String Optional. Enter the password a second time to confirm it. If this password doesn't match the one in usr_new_pass, then an error will occur.
Result:
If the user account was updated, the HTTP status code is set to 200 and it returns the following object with the updated information about the user:
usr_uid: "55324179754ca442baeb994077387342"
usr_username: "molly"
usr_password: "2b06a2251d39e28f8220696766dcd136"
usr_firstname: "Molly"
usr_lastname: "Moe"
usr_email: "molly@example.com"
usr_due_date: "2023-12-31"
usr_create_date: "2015-01-20 09:31:07"
usr_update_date: "2015-02-13 14:37:25"
usr_status: "VACATION"
usr_country: "US"
usr_city: "IN"
usr_location: "GXQ"
usr_address: "Dept 66\n740 Turtle Dove lane"
usr_phone: "1-765-653-4444"
usr_fax: "1-765-658-3574"
usr_cellular: "1-765-658-3571"
usr_zip_code: "46135"
dep_uid: "11826545154db794ca22b52025081429"
usr_position: "Head Accountant"
usr_resume: ""
usr_birthday: "1982-01-29"
usr_role: "PROCESSMAKER_MANAGER"
usr_reports_to: "14680180454ca4477335a27034362107"
usr_replaced_by: "14680180454ca4477335a27034362107"
usr_ux: "SINGLE"
}
If an error occurred, the HTTP status code is set to 400 and an error object like the following is returned:
error: {
code: 400
message: "Bad Request: usr_username. Username 'janedoe' already exists"
}
}
PHP Example:
The following example, changes the status to "VACATION" and sets the user who will replace this user when she goes on vacation.
$userId = "75740355754dd28ba73d7d6082172937"; //set to the unique ID of a user
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array(
'usr_status' => "VACATION",
'usr_replaced_by' => "14680180454ca4477335a27034362107"
);
$ch = curl_init($apiServer . "/api/1.0/workflow/user/" . $userId);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postParams));
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (isset($oResult) and isset($oResult->error)) {
print "Error in $apiServer: \nCode: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
elseif (isset($oResult) and isset($oResult->usr_uid)) {
print "User '{$oResult->usr_uid}' updated:\n";
print_r($oResult);
}
else {
print "Error updating user: HTTP status code: $statusCode\n";
}
curl_close($ch);
Note that the following line sets the request to be a PUT request:
Also note that the POST parameters need to be passed to http_build_query() to generate a URL-encoded query string which can be used with PUT requests.
Delete User: DELETE /user/{usr_uid}
Delete a specified user.
- DELETE /api/1.0/{workspace}/user/{usr_uid}
- Note: This endpoint sets the wf_<WORKSPACE>.USERS.USR_USERNAME field to "" (empty string) in the database, so that the user can no longer be used, but it does NOT delete the user's record from the database.
URL Parameters:
-
Name Type Description workspace String Workspace name usr_uid String User UID
Result:
If the user was successfully deleted, then the HTTP response code will be 200. If an error occurs, then the HTTP response code is set to 400 and an object like the following is returned:
error: {
code: 400
message: "Bad Request: The row '75740355754dd28ba73d7d6082172937' in table USER doesn't exist!"
}
}
PHP Example:
$userId = "75740355754dd28ba73d7d6082172937"; //set to a user's ID
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/user/$userId");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if (isset($oResult) and isset($oResult->error)) {
print "Error in $apiServer: \nCode: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
else {
print "Error: HTTP status code: $statusCode\n";
}
}
curl_close($ch);
Groups
The following REST endpoints are used to manage groups, as well as their member users in ProcessMaker.
4.
Update group
Groups - Users
6.
List all assigned users to a group
7.
List available users to assign to a group
9.
Unassign a user from a group
Available methods:
Get Groups List: GET /groups
Get a list of all the groups in the workspace (including groups with "INACTIVE" status). The groups are returned in alphabetical order.
- GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
URL Parameters:
-
Name Type Description workspace String Workspace name
Optional GET Parameters:
-
Name Type Description filter string Case insensitive string to search for in the group name.
For example,"api/1.0/workspace/groups?filter=sal"
would return the groups "Sales" and "Condiments & salts".start integer The number of groups where the list begins. The counting starts from the number 0.
For example,"api/1.0/workspace/groups?start=3"
would start the list of groups with the fourth group.limit integer The maximum number of groups which are returned in the list.
For example if wanting to return 10 groups at a time and there are 25 groups in total, then call this endpoint 3 times:"api/1.0/workspace/groups?limit=10"
(returns groups 0-9)"api/1.0/workspace/groups?start=10&limit=10"
(returns groups 10-19)"api/1.0/workspace/groups?start=20&limit=10"
(returns groups 20-24)
Result:
Returns an HTTP status code of 200 and the following array of group objects:
Element | Description |
---|---|
[ | Start array |
{ | Start group object |
grp_uid | The group's unique ID. |
grp_title | The group's title. |
grp_status | The group's status, which can be "ACTIVE" or "INACTIVE". |
grp_users | The number of users who are members of the group, including users who have "INACTIVE" and "VACATION" status. |
grp_tasks | The number of tasks to which the group is assigned. Note that this number includes tasks which are in deactivated processes, but it does not include ad hoc assignment to tasks. |
}, | End group object. |
... | Additional group objects. |
] | End array. |
For example:
{
grp_uid: "47113834154e4a6c5cd1f11014216675",
grp_title: "European Sales",
grp_status: "ACTIVE",
grp_users: 3,
grp_tasks: 1
},
{
grp_uid: "23251789354e4a6d6812cb4062218479",
grp_title: "Factory Workers",
grp_status: "INACTIVE"
grp_users: 20,
grp_tasks: 7
},
{
grp_uid: "92331939154e4a6b3d46cc3062046323",
grp_title: "Managers"
grp_status: "ACTIVE"
grp_users: 4,
grp_tasks: 2
}
]
If there is are no groups, then an empty array is returned. If an error occurs, then
PHP Example: The following example creates an array of the active groups which are assigned to one or more tasks.
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/groups");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aGroups = json_decode(curl_exec($ch));
curl_close($ch);
$aActiveGroups = array();
foreach ($aGroups as $oGroup) {
if ($oGroup->grp_status == "ACTIVE" and $oGroup->grp_tasks >= 1) {
$aActiveGroups[] = array("uid" => $oGroup->grp_uid, "title" => $oGroup->grp_title);
}
}
Get Group Information: GET /group/{grp_uid}
Get information about a specified group.
- GET /api/1.0/{workspace}/group/{grp_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name grp_uid String Group UID
Result:
Returns the HTTP status code 200 and the same group object as the GET /groups endpoint. For example:
grp_uid: "47113834154e4a6c5cd1f11014216675",
grp_title: "European Sales",
grp_status: "ACTIVE",
grp_users": 5,
grp_tasks": 2
}
If a bad request, then it returns the HTTP status code 400 and an error object like this:
error: {
code: 400,
message: "Bad Request: The group with grp_uid: 66065213554dd1feb48fe79020620851 does not exist."
}
}
PHP Example:
This example prints out how many users are in a group with the ID "47113834154e4a6c5cd1f11014216675":
$userId = '47113834154e4a6c5cd1f11014216675'; //set to the unique ID of a group
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . '/api/1.0/workflow/group/' . $userId);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oGroup = json_decode(curl_exec($ch));
if (isset($oGroup->error)) {
print "Error in $apiServer: \nCode: {$oGroup->error->code}\nMessage: {$oGroup->error->message}\n";
}
else {
print "Group '{$oGroup->grp_title}' has {$oGroup->grp_users} members.\n";
}
curl_close($ch);
Create Group: POST /group
Create a new group.
- POST /api/1.0/{workspace}/group
URL Parameters:
-
Name Type Description workspace String Workspace name
POST Fields:
-
Name Type Description grp_title String The name of the group. grp_status String The group's status, which can be "ACTIVE" or "INACTIVE". If the group is assigned to a task and its status is "INACTIVE", then members of the group will NOT be assigned to the task when cases are run.
Result:
If a new group was created, then the HTTP status code is 201 and a JSON object with information about the new group is returned. For example:
grp_uid: "95436327554e4c87a5bd201063097966",
grp_title: "Accounting",
grp_status: "ACTIVE"
}
If a bad request, then the HTTP status code is 400 or greater and a JSON object like the following is returned:
error: {
code: 400,
message: "Bad Request: The group title with grp_title: \"Accounting\" already exists."
}
}
PHP Example:
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array(
'grp_title' => "Accounting",
'grp_status' => "ACTIVE"
);
$ch = curl_init($apiServer . "/api/1.0/workflow/group");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oGroup = json_decode(curl_exec($ch));
if (!isset($oGroup)) {
print "Error accessing $apiServer: \n" . curl_error($ch);
}
elseif (isset($oGroup->error)) {
print "Error in $apiServer: \nCode: {$oGroup->error->code}\nMessage: {$oGroup->error->message}\n";
}
else {
print "Group '{$oGroup->grp_title}' created with UID: {$oGroup->grp_uid}\n";
}
curl_close($ch);
Update Group: PUT /group/{usr_uid}
Update information about a specified group.
- PUT /api/1.0/{workspace}/group/{grp_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name grp_uid String Group unique ID.
Optional Fields:
-
Name Type Description grp_title String The group's title. grp_status String Group status, which can be "ACTIVE" or "INACTIVE". If the group is assigned to a task and its status is "INACTIVE", then members of the group will NOT be assigned to the task when cases are run.
Result:
If the group was successfully updated, the HTTP status code is 200 and there is nothing returned.
If it is a bad request, then the HTTP status code is set to 400 or greater, and a JSON object like the following is returned:
error: {
code: 400,
message: "Bad Request: The group with grp_uid: 47113834154e4a6c5cd1f11014216674 does not exist."
}
}
PHP Example:
The following example changes the group title to "Accounting" and sets its status to "INACTIVE":
$userId = "75740355754dd28ba73d7d6082172937"; //set to the unique ID of a group
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array(
'grp_title' => "Accounting",
'grp_status' => "INACTIVE",
);
$ch = curl_init($apiServer . "/api/1.0/workflow/group/" . $groupId);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postParams));
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if (isset($oResult) and isset($oResult->error))
print "Error Code: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
curl_close($ch);
Note that the following line sets the request to be a PUT request:
Also note that the POST parameters need to be passed to http_build_query() to generate a URL-encoded query string which can be used with PUT requests.
Delete Group: DELETE /group/{grp_uid}
Delete a specified group. Note that this endpoint deletes the group's record from the GROUPWF table and its title from the CONTENT table in the database, but it doesn't delete the group's membership list from the GROUP_USER table.
- DELETE /api/1.0/{workspace}/group/{grp_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name grp_uid String Group unique ID.
Result:
If the group was deleted, then the HTTP status code is 200. Otherwise, the HTTP status code is 400 or greater and a JSON object is returned like the following:
error: {
code: 400,
message: "Bad Request: The group with grp_uid: 23251789354e4a6d6812cb4062218479 does not exist."
}
}
PHP Example:
$groupId = "75740355754dd28ba73d7d6082172937"; //set to a group's ID to delete it
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/group/" . $groupId);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if (isset($oResult) and isset($oResult->error)) {
print "Error in $apiServer: \nCode: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
else {
print "Error: HTTP status code: $statusCode\n";
}
}
curl_close($ch);
GROUPS - USERS
Get Group Members: GET /group/{grp_uid}/users
List the assigned users to a specified group.
- GET /api/1.0/{workspace}/group/{grp_uid}/users?filter={filter}&start={start}&limit={limit}
URL Parameters:
-
Name Type Description workspace String Workspace name grp_uid String Group UID
Optional GET Parameters:
-
Name Type Description filter string Case insensitive string to search for in the user's first name, last name or username.
For example,"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?filter=mit"
would return the users "smith", "Mitter" and "solmit".start integer The number of users where the list begins. The counting starts from number 0.
For example,"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?start=3"
would start the list of users with the fourth user.limit integer The maximum number of users which are returned in the list.
For example if wanting to return 10 users at a time and there are 25 users in total, then call this endpoint 3 times:"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?limit=10"
(returns users 0-9)"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?start=10&limit=10"
(returns users 10-19)"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?start=20&limit=10"
(returns users 20-24)
Result:
If a successful request, the HTTP status code is set to 200 and a JSON array of user objects is returned, like the following one:
{
usr_uid: "55324179754ca442baeb994077387342",
usr_username: "jane",
usr_firstname: "Jane",
usr_lastname: "Doe",
usr_email: "janedoe@example.com",
usr_status: "ACTIVE"
},
{
usr_uid: "66065213554dd1feb48fe79020620851",
usr_username: "sam",
usr_firstname: "Sam",
usr_lastname: "Sloe",
usr_email: "samsloe@example.com",
usr_status: "INACTIVE"
},
]
If a bad request, then the HTTP status code is 400 or greater and a JSON error object is returned, like this one:
error: {
code: 400,
message: "Bad Request: The group with grp_uid: 47113834154e4a6c5cd1f11014216674 does not exist."
}
}
PHP Example:
This PHP example creates a list of active users who are members of a group with the unique ID of "47113834154e4a6c5cd1f11014216675" and places them in the array $aActiveUsers
.
$groupId = "47113834154e4a6c5cd1f11014216675", //set to the unique ID of a group
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "api/1.0/workspace/group/$groupId/users");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aUsers = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$aActiveUsers = array();
if ($statusCode != 200) {
if (isset ($aUsers) and isset($aUsers->error))
print "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
else {
foreach ($aUsers as $oUser) {
if ($oUser->usr_status == "ACTIVE") {
$aActiveUsers[] = array("uid" => $oUser->usr_uid, "username" => $oUser->usr_username);
}
}
}
Get Available Users: GET /group/{grp_uid}/available-users
Get a list of available users, which can be assigned to a specified group. All users which aren't yet assigned to the group will be listed, including users with "INACTIVE" and "VACATION" status.
- GET /api/1.0/{workspace}/group/{grp_uid}/available-users?filter={filter}&start={start}&limit={limit}
URL Parameters:
-
Name Type Description workspace String Workspace name grp_uid String Group unique ID.
Optional GET Parameters:
-
Name Type Description filter string Case insensitive string to search for in the user's first name, last name or username.
For example,"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?filter=mit"
would return the users "smith", "Mitter" and "solmit".start integer The number of users where the list begins. The counting starts from number 0.
For example,"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?start=3"
would start the list of users with the fourth user.limit integer The maximum number of users which are returned in the list.
For example if wanting to return 10 users at a time and there are 25 users in total, then call this endpoint 3 times:"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?limit=10"
(returns users 0-9)"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?start=10&limit=10"
(returns users 10-19)"api/1.0/workspace/group/47113834154e4a6c5cd1f11014216675/users?start=20&limit=10"
(returns users 20-24)
Result:
If a successful request, the HTTP status code is set to 200 and a JSON array of user objects is returned, like the following one:
{
usr_uid: "55324179754ca442baeb994077387342",
usr_username: "jane",
usr_firstname: "Jane",
usr_lastname: "Doe",
usr_email: "janedoe@example.com",
usr_status: "ACTIVE"
},
{
usr_uid: "66065213554dd1feb48fe79020620851",
usr_username: "sam",
usr_firstname: "Sam",
usr_lastname: "Sloe",
usr_email: "samsloe@example.com",
usr_status: "INACTIVE"
},
]
If a bad request, then the HTTP status code is 400 or greater and a JSON error object is returned, like this one:
error: {
code: 400,
message: "Bad Request: The group with grp_uid: 47113834154e4a6c5cd1f11014216674 does not exist."
}
}
PHP Example:
This example gets a list of the first 10 available users to be assigned to a group with the ID ""47113834154e4a6c5cd1f11014216675":
$groupId = "47113834154e4a6c5cd1f11014216675", //set to the unique ID of a group
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "api/1.0/workspace/group/$groupId/users");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aUsers = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$aAvailableUsers = array();
if ($statusCode != 200) {
if (isset ($aUsers) and isset($aUsers->error))
print "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
else {
for ($i = 0; $i < 10 and $i < count($aUsers; $i++) {
$aAvailableUsers[] = array(
"uid" => $aUsers[$i]->usr_uid,
"name"=> "{$aUsers[$i]->usr_firstname} {$aUsers[$i]->usr_lastname} ({$aUsers[$i]->usr_username})"
);
}
}
Assign User to Group: POST /group/{grp_uid}/user
Assign a user to a specified group.
- POST /api/1.0/{workspace}/group/{grp_uid}/user
URL Parameters:
-
Name Type Description workspace String Workspace name grp_uid String The group's unique ID
POST Fields:
-
Name Type Description usr_uid String The unique ID of the user who will be added to the group as a member. Note that it is possible to add a user with "INACTIVE" or "VACATION" status to a group, but that user will not be assigned to any cases until his/her status changes to "ACTIVE" status.
Optional Fields:
These fields may be included, but they will be ignored by the REST endpoint.
-
Name Type Description usr_username String Username usr_firstname String User first name usr_lastname String User last name usr_email String User email usr_status String User status
Result:
If the user was assigned to the group, then the HTTP status code is 201 (Created) and there is no return object. Otherwise, it is 400 or greater and returns a JSON error object like:
error: {
code: 400,
message: "Bad Request: The user with usr_uid: 55324179754ca442baeb994077387342 is already assigned to the group."
}
}
PHP Example:
$groupId = "75740355754dd28ba73d7d6082172937"; //set to the unique ID of a group
$userId = "14680180454ca4477335a27034362107"; //set to unique ID of user to add to group
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array('usr_uid' => $userId);
$ch = curl_init($apiServer . "/api/1.0/workflow/group/$groupId/user");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 201) {
if isset($oResult) and isset($oResult->error)) {
print "Error in $apiServer:\nCode: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
else {
print "Error: HTTP status code $statusCode\n";
}
}
curl_close($ch);
Unassign User from Group: DELETE /group/{grp_uid}/user/{usr_uid}
Unassign (remove) a user from a group so no longer a member of the group.
- DELETE /api/1.0/{workspace}/group/{grp_uid}/user/{usr_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name grp_uid String Group UID usr_uid String Group UID
Result:
If the user was removed from the group, then the HTTP status code is 200 and there is no return object. Otherwise, the HTTP status code is 400 or greater and a JSON error object is returned, such as:
error: {
code: 400,
message: "Bad Request: The user with usr_uid: 98883020754dd1f052ee1f1034403381 is not assigned to the group."
}
}
PHP Example:
$groupId = "75740355754dd28ba73d7d6082172937"; //set to a group's ID
$userId = "98883020754dd1f052ee1f1034403381"; //set to the ID of the user to be removed from the group
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/group/$groupId/user/$userId");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if (isset($oResult) and isset($oResult->error)) {
print "Error in $apiServer: \nCode: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
else {
print "Error: HTTP status code: $statusCode\n";
}
}
curl_close($ch);
Departments
These are the REST endpoints to manage departments in ProcessMaker:
- Get a list of departments
- Get data of a department
- Create a department
- Update a department
- Delete a department
- Get the list of assigned users
- Get a list of available users in a department.
- v.2.8: Assign a user to a department
- v.3.0+: Assign a user to a department
- Unassign a user from a department
- Set manager user to department
Get Departments List: GET /departments
Get a list of all the departments in the workspace, including departments with "INACTIVE" status.
- GET /api/1.0/{workspace}/departments
URL Parameters:
-
Name Type Description workspace String Workspace name
Result:
If successful, the HTTP status code is set to 200 and it returns a JSON array of department objects with the following structure:
Element | Description | Example |
---|---|---|
[ | Start array. | |
{ | Start department object | |
dep_uid, | The department's unique ID. | "11826545154db794ca22b52025081429" |
dep_parent, | The unique ID of the parent department. If this is a top-level deparment, then set to "" (empty string). | "" |
dep_title, | The department's title. | "Human Resources" |
dep_status, | The department's status, which can be "ACTIVE" or "INACTIVE". | "ACTIVE" |
dep_manager, | The department's supervisor, to whom the other members of the department and the supervisors of the subdepartments report. By default, the supervisor is the first user assigned to the department. | "14680180454ca4477335a27034362107" |
dep_ldap_dn, | The user's distinguished name if imported from LDAP. If a normal user whose account wasn't imported, then then set to "" (empty string). | "" |
dep_last, | If the last department object in the current array, then set to 1 . If not the last, then set to 0 . | 1 |
dep_manager_username, | The username of the department's supervisor. | "liliana" |
dep_manager_firstname, | The first name of the department's supervisor. | "Liliana" |
dep_manager_lastname, | The last name of the department's supervisor. | "Ortiz" |
has_children, | The number of subdepartments of this department. | "2" |
dep_children | A array of subdepartment objects for this department. If there are no subdepartments, then an empty array. | [] |
}, | End the department object | |
{...} | Any additional department objects. | |
] | End array. |
For example:
{
dep_uid: "11826545154db794ca22b52025081429",
dep_parent: "",
dep_title: "Human Resources",
dep_status: "ACTIVE",
dep_manager: "14680180454ca4477335a27034362107",
dep_ldap_dn: "",
dep_last: 0,
dep_manager_username: "liliana",
dep_manager_firstname: "Liliana",
dep_manager_lastname: "Ortiz",
has_children: "2",
dep_children:
[
{
dep_uid: "54883398754db7993002ae1030708956",
dep_parent: "11826545154db794ca22b52025081429",
dep_title: "Crisis Management",
dep_status: "ACTIVE",
dep_manager: "91937880754ca444fc1e7b8079810120",
dep_ldap_dn: "",
dep_last: 0,
dep_manager_username: "sylvia",
dep_manager_firstname:"Sylvia",
dep_manager_lastname: "Herrero",
has_children: "0",
dep_children:
[]
},
{
dep_uid: "98568611654e60da3ad38c3043219561",
dep_parent: "11826545154db794ca22b52025081429",
dep_title: "Employee Activities",
dep_status: "ACTIVE",
dep_manager: "66065213554dd1feb48fe79020620851",
dep_ldap_dn: "",
dep_last: 1,
dep_manager_username: "johndoe",
dep_manager_firstname: "John",
dep_manager_lastname: "Doe",
has_children: "0",
dep_children:
[]
}
]
},
{
dep_uid: "48474671254e60d7d9ac448055325161",
dep_parent: "",
dep_title: "Sales",
dep_status: "INACTIVE",
dep_manager: "00000000000000000000000000000001",
dep_ldap_dn: "",
dep_last: 1,
dep_manager_username: "admin",
dep_manager_firstname: "Administrator",
dep_manager_lastname: " ",
has_children: "0",
dep_children:
[]
}
]
PHP Example:
This example prints out the directory structure of an organization with the supervisor's name in parentheses.
function printDeptArray($aDepts, $level) {
foreach ($aDepts as $oDept) {
//print spaces for the level of department:
for ($ii = 0; $ii < $level; $ii++) {
print " ";
}
print "{$oDept->dep_title} ({$oDept->dep_manager_username})\n";
if ($oDept->has_children != 0) {
printDeptArray($oDept->dep_children, $level + 1);
}
}
}
$apiServer = "https://example.com"; //set to your ProcessMaker address
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/departments");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aDepts = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$aEmptyDepartments = array();
if ($statusCode != 200) {
if (isset ($aDepts) and isset($aDepts->error))
print "Error code: {$aDepts->error->code}\nMessage: {$aDepts->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
else {
print "<pre>"; //only necessary if used in a web page
printDeptArray($aDepts, 0);
print "</pre>"; //only necessary if used in a web page
}
For the departments shown in the example above, this script would print out:
Crisis Management (sylvia)
Employee Activities (johndoe)
Sales (admin)
Get Department Information: GET /department/{dep_uid}
Get information about a specified department.
- GET /api/1.0/{workspace}/department/{dep_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Department UID
Result:
If successful, the HTTP status code is 200 and a department object is returned like the GET departments endpoint, but it doesn't include the dep_children
array. For example:
dep_uid: "54883398754db7993002ae1030708956",
dep_parent: "11826545154db794ca22b52025081429",
dep_title: "Crisis Management",
dep_status: "ACTIVE",
dep_manager: "91937880754ca444fc1e7b8079810120",
dep_ldap_dn: "",
dep_last: 0,
dep_manager_username: "sylvia",
dep_manager_firstname: "Sylvia",
dep_manager_lastname: "Herrero",
has_children: "0"
}
If unsuccessful, the HTTP status code is 400 or greater and a JSON error object is returned, such as:
error: {
code: 400,
message: "Bad Request: The department with dep_uid: '54883398754db7993002ae1030708957' does not exist."
}
}
PHP Example:
This example prints out the department's title and its supervisor's full name:
$deptId = "54883398754db7993002ae1030708956"; //set to a department's unique ID
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/department/$deptId");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oDept = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($statusCode != 200) {
if (isset ($oDept) and isset($oDept->error))
print "Error code: {$oDept->error->code}\nMessage: {$oDept->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
else {
print "{$oDept->dep_title} Department supervisor: {$oDept->dep_manager_firstname} {$oDept->dep_manager_lastname}";
}
Create Department: POST /department
Create a new department.
- POST /api/1.0/{workspace}/department
URL Parameters:
-
Name Type Description workspace String Workspace name
POST Fields:
-
Name Type Description dep_title String Department's title (name). Note that the department's title must be unique, so an error will occur if trying to create a department title which already exists. dep_parent String Optional. Parent department's unique ID. If not included or set to "" (empty string), then this is a top-level department. dep_manager String Optional. Department supervisor's unique ID. Users may only be assigned to ONE department, so the supervisor may NOT be a member of another department. dep_status String Optional. Department status, which can be "ACTIVE" or "INACTIVE". If not included, then "ACTIVE" by default.
Result:
If the new department was created, the HTTP status code is 201 (Created) and a department object is returned, like the following:
dep_uid: "53126763454e62dc3284a75021962206",
dep_parent: "48474671254e60d7d9ac448055325161",
dep_title: "International Sales",
dep_status: "ACTIVE",
dep_manager: "61875549854e62c9c0bc823037974404",
dep_ldap_dn: "",
dep_last: 0,
dep_manager_username: "kendrick",
dep_manager_firstname: "Kendrick",
dep_manager_lastname: "Hillman",
has_children: "0"
}
- Note: The
dep_last
element in the returned object is always set to 0 and is not correct. To check whether the new department is the last department at the current level, call the GET /departments or GET /department/{dep_uid} endpoint and check the value of thedep_last
element.
If an error occurred, the HTTP status code is 400 or greater and an error object is returned, like the following:
error: {
code: 400,
message: "Bad Request: The department with dep_parent: '48474671254e60d7d9ac448055325160' does not exist."
}
}
PHP Example:
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array(
'dep_title' => 'International Sales',
'dep_manager' => '61875549854e62c9c0bc823037974404',
'dep_parent' => '48474671254e60d7d9ac448055325161',
'dep_status' => 'ACTIVE'
);
$ch = curl_init($apiServer . "/api/1.0/workflow/department");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oDept = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode == 201) {
print "Department '{$oDept->dep_title}' created with UID: {$oDept->dep_uid}\n";
}
else {
if (isset($oDept) and isset($oDept->error)) {
print "Error in $apiServer: \nCode: {$oDept->error->code}\nMessage: {$oDept->error->message}\n";
}
else {
print "Error: HTTP status code: $statusCode\n";
}
}
curl_close($ch);
Update Department: PUT /department/{dep_uid}
Update the information about a department.
- PUT /api/1.0/{workspace}/department/{dep_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Department UID.
Optional Fields:
-
Name Type Description dep_title String The department title (name), which must be unique. dep_parent String Unique ID of the parent department. Set to "" (empty string) to make a top-level department. dep_manager String Unique ID of the department supervisor, to whom the members of the department [[1]], as well as the supervisors of subdepartments. dep_status String Department status, which can be "ACTIVE" or "INACTIVE".
Result:
If the department was successfully updated, then the HTTP status code is set to 200 and there is no return object. Otherwise, it is set to 400 and greater and returns an error object, such as:
error: {
code: 400,
message: "Bad Request: The user with dep_manager: '91937880754ca444fc1e7b8079810121' does not exist."
}
}
PHP Example:
$deptId = "75740355754dd28ba73d7d6082172937"; //set to the unique ID of a department
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array(
'dep_title' => 'International Sales',
'dep_manager' => '91937880754ca444fc1e7b8079810121',
'dep_parent' => '48474671254e60d7d9ac448055325161',
'dep_status' => 'INACTIVE'
);
$ch = curl_init($apiServer . "/api/1.0/workflow/department/" . $deptId);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postParams));
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if (isset($oResult) and isset($oResult->error))
print "Error Code: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
curl_close($ch);
Delete Department: DELETE /department/{dep_uid}
Delete a specified department. Note that it is not possible to delete a department while it has assigned users, so all the users must be unassigned from the department before deleting it.
- DELETE /api/1.0/{workspace}/department/{dep_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Unique ID of the department to be deleted.
Result:
If the department was deleted, the HTTP status code is set to 200 and nothing is returned. Otherwise, it is set to 400 or greater and an error object is returned like the following:
error: {
code: 400,
message: "Bad Request: Department cannot be deleted while has assigned users."
}
}
PHP Example:
$deptId = "75740355754dd28ba73d7d6082172937"; //set to a department ID to delete it
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/department/" . $deptId);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if (isset($oResult) and isset($oResult->error))
print "Error Code: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
curl_close($ch);
Departments - Users:
Get Users List for Department: GET /department/{dep_uid}/assigned-user
Get a list of the users assigned to a specified department.
- GET /api/1.0/{workspace}/department/{dep_uid}/assigned-user
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Unique ID of department.
Result:
If successful, the HTTP status code is 200 and an array of user objects is returned, like the following:
{
usr_uid: "91937880754ca444fc1e7b8079810120",
usr_username: "sylvia",
usr_firstname: "Sylvia",
usr_lastname: "Herrero",
usr_status: "VACATION",
usr_supervisor: true
},
{
usr_uid: "98883020754dd1f052ee1f1034403381",
usr_username: "janedoe",
usr_firstname: "Jane",
usr_lastname: "Doe",
usr_status: "ACTIVE",
usr_supervisor: false
}
]
PHP Example:
This example cycles through all the departments, looking for the username "janedoe" and prints out her department. First it calls the GET /departments endpoint to get a list of departments, then it calls the GET /department/{dep_uid}/assigned-user endpoint for each department and searches for the user.
function searchInDepts($username, $aDepts) {
global $apiServer, $accessToken;
foreach ($aDepts as $oDept) {
$ch = curl_init($apiServer . "/api/1.0/workflow/department/{$oDept->dep_uid}/assigned-user");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aUsers = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($statusCode != 200) {
if (isset($aUsers) and isset($aUsers->error))
exit("Error Code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n");
else
exit("Error: HTTP status code: $statusCode\n");
}
foreach ($aUsers as $oUser) {
if ($oUser->usr_username == $username) {
return $oDept;
}
}
if ($oDept->has_children != 0) {
$oRet = searchInDepts($username, $oDept->dep_children);
if ($oRet) //if username found, return the department object
return $oRet;
}
}
return null; //username not found
}
$apiServer = "shttp://example.com"; //set to your ProcessMaker address
$usernameToFind = "janedoe"; //set to a username to find
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/departments");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aDepts = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($statusCode != 200) {
if (isset ($aDepts) and isset($aDepts->error))
exit("Error code: {$aDepts->error->code}\nMessage: {$aDepts->error->message}\n");
else
exit("Error: HTTP status code: $statusCode\n");
}
else {
$oDeptFound = searchInDepts($usernameToFind, $aDepts);
if ($oDeptFound)
print "User '$usernameToFind' is a member of the {$oDeptFound->dep_title} Department.\n";
else
print "User '$usernameToFind' is not a member of any department.\n";
}
Available Users List for Department: GET /department/{dep_uid}/available-user
Get a list of the available users, which can be assigned to a specified department. The list contains all users which aren't yet assigned to any department (including users which have "INACTIVE" and "VACATION" status).
- GET /api/1.0/{workspace}/department/{dep_uid}/available-user
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Unique ID of department.
Result:
If successful, the HTTP status code is set to 200 and it returns an array of user objects, like the following:
{
usr_uid: "43239845654e76a70ccb5a1012787498",
usr_username: "sally",
usr_firstname: "Sally",
usr_lastname: "Slim",
usr_status: "INACTIVE"
},
{
usr_uid: "66065213554dd1feb48fe79020620851",
usr_username: "johndoe",
usr_firstname: "John",
usr_lastname: "Doe",
usr_status: "ACTIVE"
}
]
Note that the user objects are not arranged in any particular order.
If an error occurred, the HTTP status code is set to 400 or greater, and an error object is returned, such as:
error: {
code: 400,
message: "Bad Request: The department with dep_uid: '54883398754db7993002ae1030708955' does not exist."
}
}
PHP Example:
Get a list of available users and sort them in alphabetical order according to their full names and print them. All the user objects are placed in the $aUsersWithKeys array which has the full names as the keys and then they are sorted using the ksort() function.
$deptId = "54883398754db7993002ae1030708956"; //set to a department's unique ID
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$ch = curl_init($apiServer . "/api/1.0/workflow/department/$deptId/available-user");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aUsers = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($statusCode != 200) {
if (isset ($oDept) and isset($oDept->error))
print "Error code: {$oDept->error->code}\nMessage: {$oDept->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
else {
$aUsersWithKeys = array();
foreach ($aUsers as $oUser) {
$fullname = $oUser->usr_firstname . ' ' . $oUser->usr_lastname . ' (' . $oUser->username . ')';
$aUsersWithKeys[$fullname] = $oUser;
}
ksort($aUsersWithKeys, SORT_NATURAL | SORT_FLAG_CASE));
foreach ($aUsersWithKeys as $oUser) {
print $oUser->usr_firstname . ' ' . $oUser->usr_lastname . ' (' . $oUser->username . ")\n";
}
}
v.2.8: Assign User to Department: PUT /department/{dep_uid}/assign-user/{usr_uid}
Assign a user to a specified department in version 2.8. If using version 3.0 or later, see POST /department/{dep_uid}/assign-user. If the user is already a member of another department, the user will be transfered to the specified department. If reassigning a user who is a supervisor of another department, see this bug.
- PUT /api/1.0/{workspace}/department/{dep_uid}/assign-user/{usr_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Unique ID of department. usr_uid String Unique ID of user to assign to the department.
Result:
If the user was assigned to the department, the HTTP status code is 200 and there is no return object. Otherwise, the HTTP status code is 400 or greater and there is a return object such as:
error: {
code: 400,
message: "Bad Request: The user with usr_uid: '43239845654e76a70ccb5a1012787499' does not exist."
}
}
PHP Example:
$deptId = "75740355754dd28ba73d7d6082172937"; //set to the unique ID of a department
$userId = "14680180454ca4477335a27034362107"; //set to unique ID of user to add to department
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array('usr_uid' => $userId);
$ch = curl_init($apiServer . "/api/1.0/workflow/department/$deptId/assign-user/$userId");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if isset($oResult) and isset($oResult->error)) {
print "Error Code: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
else {
print "Error: HTTP status code $statusCode\n";
}
}
curl_close($ch);
v.3.0+: Assign User to Department: POST /department/{dep_uid}/assign-user
Assign a user to a specified department in version 3.0 and later. If the user is already a member of another department, the user will be transfered to the specified department. If reassigning a user who is a supervisor of another department, see this bug.
- POST /api/1.0/{workspace}/department/{dep_uid}/assign-user
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Unique ID of department.
POST Fields:
-
Name Type Description usr_uid String Unique ID of a user to assign to the department.
Result:
If the user was assigned to the department, the HTTP status code is 201
and there is no return object. Otherwise, the HTTP status code is 300
or greater and there is a return object such as:
error: {
code: 400,
message: "Bad Request: The user with usr_uid: '43239845654e76a70ccb5a1012787499' does not exist."
}
}
PHP Example:
$userId = '55625662755e0e42fe83f41018778834';
$deptId = '49874200755e894791651c7054311031';
$aVars = array(
'usr_uid' => $userId
);
$url = "/api/1.0/workflow/department/$deptId/assign-user";
$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
if ($oRet->status == 200) {
print "User $userId added to the Accounting Department.\n";
}
Unassign User from Department: PUT /department/{dep_uid}/unassign-user/{usr_uid}
Unassign a user from a department, so no longer a member of the department. If unassigning a supervisor from a department, see this bug.
- PUT /api/1.0/{workspace}/department/{dep_uid}/unassign-user/{usr_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Unique ID of department. usr_uid String Unique ID of the user to unassign from the department.
Result:
If the user was unassigned from the department, the HTTP status code is 200 and there is no return object. Otherwise, the HTTP status code is 400 or greater and there is a return object such as:
error: {
code: 400,
message: "Bad Request: The user with usr_uid: '43239845654e76a70ccb5a1012787499' does not exist."
}
}
PHP Example:
$deptId = "75740355754dd28ba73d7d6082172937"; //set to the unique ID of a department
$userId = "14680180454ca4477335a27034362107"; //set to unique ID of user to remove from department
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array('usr_uid' => $userId);
$ch = curl_init($apiServer . "/api/1.0/workflow/department/$deptId/unassign-user/$userId");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if isset($oResult) and isset($oResult->error)) {
print "Error Code: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
else {
print "Error: HTTP status code $statusCode\n";
}
}
curl_close($ch);
Set Manager for Department: PUT /department/{dep_uid}/set-manager/{usr_uid}
Set a user to be the manager (supervisor) for a department. The other members of the department will report to the manager, as well as the managers of subdepartments. Note that this endpoint has a number of outstanding bugs.
- PUT /api/1.0/{workspace}/department/{dep_uid}/set-manager/{usr_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name dep_uid String Unique ID of the department. usr_uid String Unique ID of the user to become the the manager of the department.
Result:
If the manager was successfully set, then the HTTP status code is 200 and there is no return object. Otherwise, the HTTP status code is 400 or greater and an error object is returned, like the following:
error: {
code: 400,
message: "Bad Request: The user with usr_uid: '43239845654e76a70ccb5a1012787499' does not exist."
}
}
PHP Example:
$deptId = "75740355754dd28ba73d7d6082172937"; //set to the unique ID of a department
$userId = "14680180454ca4477335a27034362107"; //set to unique ID of user to become supervisor
$accessToken = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : getAccessToken();
$postParams = array('usr_uid' => $userId);
$ch = curl_init($apiServer . "/api/1.0/workflow/department/$deptId/set-manager/$userId");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer $accessToken"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$oResult = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($statusCode != 200) {
if isset($oResult) and isset($oResult->error)) {
print "Error Code: {$oResult->error->code}\nMessage: {$oResult->error->message}\n";
}
else {
print "Error: HTTP status code $statusCode\n";
}
}
curl_close($ch);
Roles
The following REST endpoints are used to manage roles in ProcessMaker.
Roles
Roles - Users
6.
List assigned users to a role
7.
List available users to assign to a role
Roles - Permissions
10.
List assigned permissions to a role
11.
List available permissions to assign to a role
12.
Assign permissions to a role
13.
Unassign permissions from a role
Get Roles List: GET /roles
Get a list of the roles in the workspace.
- GET /api/1.0/{workspace}/roles
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/roles Optional filters filter={text} Case insensitive text to search for in the role codes (but not the role names). Remember to URL encode in UTF-8, if it contains spaces, symbols or non-ASCII characters, using a function such as urlencode() in PHP or encodeURIComponent() in JavaScript. /api/1.0/workflow/roles?filter=reviewer start={number} Integer which indicates the initial position of the role. /api/1.0/workflow/roles?start=20&limit=10 limit={number} Integer which limits the number of roles returned /api/1.0/workflow/roles?start=30&limit=10
Result:
If successful, the HTTP status is200
(OK) and an array of role objects is returned, such as:
{
"rol_uid": "00000000000000000000000000000002",
"rol_code": "PROCESSMAKER_ADMIN",
"rol_name": "System Administrator",
"rol_status": "ACTIVE",
"rol_system": "00000000000000000000000000000002",
"rol_create_date": "2015-03-19 07:55:48",
"rol_update_date": "",
"rol_total_users": 2
},
{
"rol_uid": "00000000000000000000000000000003",
"rol_code": "PROCESSMAKER_OPERATOR",
"rol_name": "Operator",
"rol_status": "ACTIVE",
"rol_system": "00000000000000000000000000000002",
"rol_create_date": "2015-03-20 08:45:09",
"rol_update_date": "",
"rol_total_users": 0
}
]
PHP example
Print out a list of the roles with "ACTIVE" status and the number of users assigned to each role.
$url = "/api/1.0/workflow/roles";
$oRet = pmRestRequest("GET", $url, $aVars, $oToken->access_token);
if ($oRet->status == 200) {
foreach ($oRet->response as $oRole) {
print "Active Roles:\n";
if ($oRole->rol_status == 'ACTIVE') {
print " {$oRole->rol_name}\t{$oRole->rol_total_users}\n";
}
}
}
Get Role Information: GET /role/{rol_uid}
Get information about a specified role.
- GET /api/1.0/{workspace}/role/{rol_uid}
URL Parameters:
-
Name Type Description workspace String Workspace name rol_uid String Role UID
Result:
If successful, the HTTP status is set to 200
and an object with information about the role is returned, such as
"rol_uid": "00000000000000000000000000000002",
"rol_code": "PROCESSMAKER_ADMIN",
"rol_name": "System Administrator",
"rol_status": "ACTIVE",
"rol_system": "00000000000000000000000000000002",
"rol_create_date": "2015-01-30 23:59:59",
"rol_update_date": "",
"rol_total_users": 2
}
Create Role: POST /role
Create a new role.
- POST /api/1.0/{workspace}/role
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role
POST fields:
-
Name Description rol_code The role code, which is an identifier consisting of letters, numbers and underscores ("_"). It may not contain any spaces or special characters. rol_name The role name, which is any identifier which can contain any type of characters and is displayed in the ProcessMaker. rol_status Optional. Role status, which may be "ACTIVE" or "INACTIVE". If not specified, then set to "ACTIVE" by default. If set to "INACTIVE", any users assigned to the role will not be able to login to ProcessMaker, nor may any cases be assigned to those users.
Result:
If the role was created, then the HTTP status code is set to 201
(Created) and an object containing information about the new role is returned, such as:
"rol_uid": "55625662755e0e42fe83f41018778834",
"rol_code": "Case_Reviewer",
"rol_name": "Case Reviewer",
"rol_status": "ACTIVE",
"rol_system": "00000000000000000000000000000002",
"rol_create_date": "2015-11-18 22:45:52",
"rol_update_date": "",
"rol_total_users": 0
}
Update Role: PUT /role/{rol_uid}
Update information about a specified role.
- PUT /api/1.0/{workspace}/role/{rol_uid}
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/14539701455e9bf5e9dfc40009566988 rol_uid Unique ID of role /api/1.0/workflow/role/14539701455e9bf5e9dfc40009566988
POST fields:
-
Name Description rol_code Optional. The role code, which is an identifier consisting of letters, numbers and underscores ("_"). It may not contain any spaces or special characters. rol_name Optional. The role name, which is any identifier which can contain any type of characters and is displayed in the ProcessMaker. rol_status Optional. Role status, which may be "ACTIVE" or "INACTIVE". If set to "INACTIVE", any users assigned to the role will not be able to login to ProcessMaker, nor may any cases be assigned to those users.
Result:
If the information about a case has been updated, then the HTTP status is set to 200
(OK) and there is no return object.
PHP example:
$roleId = '92775102755E9beea04c394090645988';
$aVars = array(
'rol_code' => 'Consultant',
'rol_name' => 'Consultant',
'rol_status' => 'INACTIVE'
);
$url = "/api/1.0/workflow/role/$roleId";
$oRet = pmRestRequest("PUT", $url, $aVars, $oToken->access_token);
if ($oRet->status == 200) {
print "Role changed to 'Consultant'.\n";
}
Delete Role: DELETE /role/{rol_uid}
Delete a specified role. Note that it is not possible to delete a role which still has assigned users, so all users must be assigned to different roles before deleting the role.
- DELETE /api/1.0/{workspace}/role/{rol_uid}
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/14539701455e9bf5e9dfc40009566988 rol_uid Unique ID of role /api/1.0/workflow/role/14539701455e9bf5e9dfc40009566988
Result:
If the role is deleted, the HTTP status code is set to 200 and there is no return object. If the HTTP status code is 300 or greater than an error occurred and a error object will usually be returned, such as:"error": {
"code": 400,
"message": "Bad Request: This role cannot be deleted while it still has some assigned users."
}
}
PHP example:
$roleId = '92775102755E9beea04c394090645988';
$url = "/api/1.0/workflow/role/$roleId";
$oRet = pmRestRequest("DELETE", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
print "Role deleted.\n";
}
ROLES - USERS
Get Users with Role: GET /role/{rol_uid}/users
Get a list of the users assigned to a role.
- GET /api/1.0/{workspace}/role/{rol_uid}/users
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000003/users rol_uid Unique ID of role /api/1.0/workflow/role/00000000000000000000000000000003/users Optional filters: filter={text} Case insensitive text to search for users in their first name, last name or username. Remember to URL encode in UTF-8, if it contains spaces, symbols or non-ASCII characters, using a function such as urlencode() in PHP or encodeURIComponent() in JavaScript. /api/1.0/workflow/role/00000000000000000000000000000003/users?filter=mary start={number} Integer which indicates the initial position of the user in the list. /api/1.0/workflow/role/00000000000000000000000000000003/users?start=20&limit=10 limit={number} Integer which limits the number of users returned. /api/1.0/workflow/role/00000000000000000000000000000003/users?start=30&limit=10
Result:
If successful, the HTTP status code is set to 200
(OK) and an array of user objects is returned, such as:
{
"usr_uid": "93284375552975187b60962076613156",
"usr_username": "jdoe",
"usr_firstname": "Jane",
"usr_lastname": "Doe",
"usr_status": "ACTIVE"
},
{
"usr_uid": "548562415529751a1e28ed0037315520",
"usr_username": "bsmith",
"usr_firstname": "Bob",
"usr_lastname": "Smith",
"usr_status": "ACTIVE"
}
]
If no users are assigned to the role, then an empty array will be returned.
Available Users for Role: GET /role/{rol_uid}/available-users
Get a list of users who currently are assigned to other roles and are available to be reassigned to the specified role.
- GET /api/1.0/{workspace}/role/{rol_uid}/available-users
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000003/available-users rol_uid Unique ID of role /api/1.0/workflow/role/00000000000000000000000000000003/available-users Optional filters: filter={text} Case insensitive text to search for in the first name, last name or username of users. Remember to URL encode in UTF-8, if it contains spaces, symbols or non-ASCII characters, using a function such as urlencode() in PHP or encodeURIComponent() in JavaScript. /api/1.0/workflow/role/00000000000000000000000000000003/available-users?filter=mary start={number} Integer which indicates the initial position of the user in the list. /api/1.0/workflow/role/00000000000000000000000000000003/available-users?start=20&limit=10 limit={number} Integer which limits the number of users returned. /api/1.0/workflow/role/00000000000000000000000000000003/available-users?start=30&limit=10
Result:
If successful, the HTTP status code is set to 200
(OK) and an array of user objects is returned, such as:
{
"usr_uid": "93284375552975187b60962076613156",
"usr_username": "jdoe",
"usr_firstname": "Jane",
"usr_lastname": "Doe",
"usr_status": "ACTIVE"
},
{
"usr_uid": "548562415529751a1e28ed0037315520",
"usr_username": "bsmith",
"usr_firstname": "Bob",
"usr_lastname": "Smith",
"usr_status": "ACTIVE"
}
]
If no users are assigned to other roles, then an empty array will be returned.
Assign User to Role: POST /role/{rol_uid}/user
Assign a user to a role.
- POST /api/1.0/{workspace}/role/{rol_uid}/user
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000003/user rol_uid Unique ID of role. The 3 predefined roles in ProcessMaker are Administrator '00000000000000000000000000000002'
, Operator'00000000000000000000000000000003'
, and Manager'00000000000000000000000000000004'
./api/1.0/workflow/role/00000000000000000000000000000003/user
POST Fields:
-
Name Type Description usr_uid String Unique ID of user to be assigned to a role.
Result:
If the user has been successfully assigned to a role, then the HTTP status is set to 201
(Created) and there is no return object.
Note that the "admin" user may not be reassigned to a different role, which generates the following error:
"error": {
"code": 400,
"message": "Bad Request: The role of the administrator can not be changed!"
}
}
PHP example
$userId = '55625662755e0e42fe83f41018778834';
$roleId = '00000000000000000000000000000003'; //Operator role
$aVars = array(
'usr_uid' => $userId
);
$url = "/api/1.0/workflow/role/$roleId/user";
$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
if ($oRet->status == 201) {
print "User $userId reassigned to Operator role.\n";
}
Unassign User from Role: DELETE /role/{rol_uid}/user/{usr_uid}
Unassign (remove) a user from a role. It is not recommended to call this endpoint, unless wishing for the user to have no role and be unable to login or be used in any capacity in ProcessMaker. The user will need to be reassigned to another role in order to have any function inside ProcessMaker.
- DELETE /api/1.0/{workspace}/role/{rol_uid}/user/{usr_uid}
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000003/user/55625662755e0e42fe83f41018778834 rol_uid Unique ID of role. The 3 predefined roles in ProcessMaker are Administrator '00000000000000000000000000000002'
, Operator'00000000000000000000000000000003'
, and Manager'00000000000000000000000000000004'
./api/1.0/workflow/role/00000000000000000000000000000003/user/55625662755e0e42fe83f41018778834 usr_uid Unique ID of user /api/1.0/workflow/role/00000000000000000000000000000003/user/55625662755e0e42fe83f41018778834
Result:
If unassigned from the role, the HTTP status code is set to 200 (OK) and there is no return object. Otherwise, the HTTP status code is set to 300 or greater and an error object is often returned, such as:"error": {
"code": 400,
"message": "Bad Request: The user with usr_uid: 55625662755e0e42fe83f41018778834 is not assigned to the role."
}
}
PHP Example
$userId = '55625662755e0e42fe83f41018778834';
$roleId = '00611547a59021abb767b6e63f772ee2';
$url = "/api/1.0/workflow/role/$roleId/user/$userId";
$oRet = pmRestRequest("DELETE", $url, $aVars, $oToken->access_token);
if ($oRet->status == 200) {
print "User's role removed.\n";
}
ROLES - PERMISSIONS
Permissions List for Role: GET /role/{rol_uid}/permissions
Get a list of the permissions assigned to a specified role.
- GET /api/1.0/{workspace}/role/{rol_uid}/permissions
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000002/permissions rol_uid Unique ID of the Role. The 3 predefined roles in ProcessMaker are Administrator '00000000000000000000000000000002'
, Operator'00000000000000000000000000000003'
, and Manager'00000000000000000000000000000004'
./api/1.0/workflow/role/00000000000000000000000000000002/permissions Optional filters: filter={text} Case-insensitive text to search for in the permission codes. /api/1.0/workflow/role/00000000000000000000000000000002/permissions?filter=setup start={number} Position of the initial permission be returned /api/1.0/workflow/role/00000000000000000000000000000002/permissions?start=5&limit=5 limit={number} Number of permissions to be returned. /api/1.0/workflow/role/00000000000000000000000000000002/permissions?start=5&limit=5
Result:
If successful the HTTP status code is 200 and the response is an array of permission objects for the role, such as:{
"per_uid": "00000000000000000000000000000001",
"per_code": "PM_LOGIN",
"per_name": "Login"
},
{
"per_uid": "00000000000000000000000000000005",
"per_code": "PM_CASES",
"per_name": "Create cases"
}
]
PHP example:
Print out the list of permissions in the PROCESSMAKER_ADMIN role:
$roleId = '00000000000000000000000000000002';
$url = "/api/1.0/workflow/role/$roleId/permissions";
$oRet = pmRestRequest("GET", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
print "Permissions in role $roleId:\n";
foreach ($oRet->response as $oPermission) {
print "\t$oPermission->per_code\n";
}
}
Available Permissions for Role: GET /role/{rol_uid}/available-permissions
Get a list of the available permissions, which can be assigned to a specified role.
- GET /api/1.0/{workspace}/role/{rol_uid}/available-permissions
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000003/available-permissions rol_uid Unique ID of the Role. The 3 predefined roles in ProcessMaker are Administrator '00000000000000000000000000000002'
, Operator'00000000000000000000000000000003'
, and Manager'00000000000000000000000000000004'
./api/1.0/workflow/role/00000000000000000000000000000003/available-permissions Optional filters: filter={text} Case-insensitive text to search for in the permission codes. /api/1.0/workflow/role/00000000000000000000000000000003/available-permissions?filter=setup start={number} Position of the initial permission be returned /api/1.0/workflow/role/00000000000000000000000000000003/available-permissions?start=5&limit=5 limit={number} Number of permissions to be returned. /api/1.0/workflow/role/00000000000000000000000000000003/available-permissions?start=5&limit=5
Result:
If successful the HTTP status code is 200 and the response is an array of available permission objects for the role, such as:{
"per_uid": "00000000000000000000000000000006",
"per_code": "PM_ALLCASES",
"per_name": "All Cases"
},
{
"per_uid": "00000000000000000000000000000018",
"per_code": "PM_CANCELCASE",
"per_name": "Cancel cases"
}
]
PHP example:
Search through the list of available permissions for the Operator role to see whether it includes the PM_DASHBOARD permission. If available, then assign it to the Operator role:
$roleId = '00000000000000000000000000000003'; //Operator role
$url = "/api/1.0/workflow/role/$roleId/available-permissions";
$oRet = pmRestRequest("GET", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
$dashboardAvailable = false;
foreach ($oRet->response as $oPermission) {
if ($oPermission->per_code == 'PM_DASHBOARD') {
$dashboardAvailable = true;
$permissionId = $oPermission->per_uid;
}
//If PM_DASHBOARD available, then assign it to role
if ($dashboardAvailable) {
$aVars = array(
'per_uid' => $permissionId
);
$url = "/api/1.0/workflow/role/$roleId/permission";
$oRet2 = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
if ($oRet2->status == 201) {
print "PM_DASHBOARD assigned to Operator role.\n";
}
}
else {
print "PM_DASHBOARD is already assigned to the Operator role.\n";
}
}
Assign Permission to Role: POST /role/{rol_uid}/permission
Assign a permission to a role.
- POST /api/1.0/{workspace}/role/{rol_uid}/permission
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000003/permission rol_uid Unique ID of the Role. The 3 predefined roles in ProcessMaker are Administrator '00000000000000000000000000000002'
, Operator'00000000000000000000000000000003'
, and Manager'00000000000000000000000000000004'
./api/1.0/workflow/role/00000000000000000000000000000003/permission
POST Fields:
-
Name Type Description per_uid String Unique ID of the permission to assign to a role.
Result:
If the permission is successfully assigned to the role, then the HTTP status code is set to 201
(Created) and there is no response.
PHP example:
This example assigns the PM_REASSIGNCASE permission to the Operator role.
$roleId = '00000000000000000000000000000003'; //Operator role
$permissionId = '00000000000000000000000000000007'; //PM_REASSIGNCASE permission
$aVars = array(
'per_uid' => $permissionId
);
$url = "/api/1.0/workflow/role/$roleId/permission";
$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
if ($oRet->status == 201) {
print "PM_REASSIGNCASE permission assigned to the Operator role.\n";
}
Unassign Permission from Role: DELETE /role/{rol_uid}/permission/{per_uid}
Unassign (remove) a permission from a role.
- DELETE /api/1.0/{workspace}/role/{rol_uid}/permission/{per_uid}
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/role/00000000000000000000000000000003/permission/00000000000000000000000000000007 rol_uid Unique ID of the Role. The 3 predefined roles in ProcessMaker are Administrator '00000000000000000000000000000002'
, Operator'00000000000000000000000000000003'
, and Manager'00000000000000000000000000000004'
./api/1.0/workflow/role/00000000000000000000000000000003/permission/00000000000000000000000000000007 per_uid Unique ID of the permission to unassign from the role. /api/1.0/workflow/role/00000000000000000000000000000003/permission/00000000000000000000000000000007
Result:
If the permission is successfully unassigned from the role, then the HTTP status code is set to 200
(OK) and there is no response.
"error": {
"code": 400,
"message": "Bad Request: The permissions of the "PROCESSMAKER_ADMIN" role can not be changed."
}
}
PHP example:
This example unassigns the PM_REASSIGNCASE permission from the Operator role.
$roleId = '00000000000000000000000000000003'; //Operator role
$permissionId = '00000000000000000000000000000007'; //PM_REASSIGNCASE permission
$url = "/api/1.0/workflow/role/$roleId/permission/$permissionId";
$oRet = pmRestRequest("DELETE", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
print "PM_REASSIGNCASE permission unassigned from the Operator role.\n";
}
PM Tables
The following REST endpoints are used to manage PM tables in ProcessMaker:
PM Tables:
Name | Description | Type | Value |
---|---|---|---|
pmt_tab_name | PM Table name | String | "name" o "pmt_NAME"(String) |
pmt_tab_dsc | PM Table description | String | "PM table description"(String) |
fields | PM Table fields | Array | |
fld_dyn | Field name known in a DynaForm | String | "Acceptance"(String) |
fld_name | Field name for the MySQL table creation | String | "ACCEPTED" (String) |
fld_label | Field label in the PM graphic | String | "PM Table description"(String) |
fld_type | MySQL field type, which may be: "BOOLEAN", "TINYINT", "SMALLINT", "INTEGER", "BIGINT", "DOUBLE", "FLOAT", "REAL", "DECIMAL", "CHAR", "VARCHAR", "LONGVARCHAR", "DATE", "TIME" or "DATETIME" | String | "VARCHAR"(String MySQL type field) |
fld_size | MySQL field size | Integer | 23 (Numeric) |
Available methods:
PM Tables List: GET /pmtable
Get a list of the PM tables in the workspace. It does not include any Report Tables.
- GET /api/1.0/{workspace}/pmtable
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/pmtable
Result:
If successful, the HTTP status is set to 200
(OK) and an array of PM Table objects is returned:
[ | Start array. |
{ | Start PM Table object. |
"pmt_uid", | Unique ID of the PM Table. |
"pmt_tab_name", | Table in the wf_{workspace} database. |
"pmt_tab_description", | Description of the PM Table. |
"pmt_tab_class_name", | PHP class name for the PM Table. |
"pmt_num_rows", | Number of records in the PM Table. |
"fields": [ | An array of fields in the PM Table. |
{ | Start Field object. |
"fld_uid", | Unique ID of the field. |
"fld_index": | Index number of the field, counting from the number 0. |
"fld_name": | Name of the field in the database. |
"fld_description": | Label of the field. |
"fld_type": | Type of the field. |
"fld_size": | Field size. |
"fld_null": | Set to "1" if a NULL (empty) value is allowed. Otherwise, set to "0". |
"fld_auto_increment": | Set to "1" if the field will be auto-incremented. Otherwise, set to "0". |
"fld_key": | Set to "1" if a key field, meaning that its values are unique. Otherwise, set to "0". |
"fld_table_index": | Set to "1" if the field will be indexed. Otherwise, set to "0". |
}, | End Field object. |
... | Any additional Field objects. |
] | End array of Field objects. |
}, | End PM Table object. |
... | Any additional PM Table objects. |
] | End array of PM Table objects. |
For example:
{
"pmt_uid": "33532851355ef56860e8297082884997",
"pmt_tab_name": "PMT_CLIENTS",
"pmt_tab_description": "Table with information about clients",
"pmt_tab_class_name": "PmtClients",
"pmt_num_rows": 28,
"fields":
[
{
"fld_uid": "22501963155ef568633c460054115944",
"fld_index": "0",
"fld_name": "ID",
"fld_description": "ID",
"fld_type": "BIGINT",
"fld_size": "8",
"fld_null": "0",
"fld_auto_increment": "1",
"fld_key": "1",
"fld_table_index": "0"
},
{
"fld_uid": "58722687755ef568650b502051774480",
"fld_index": "1",
"fld_name": "COMPANY_NAME",
"fld_description": "CompanyName",
"fld_type": "VARCHAR",
"fld_size": "50",
"fld_null": "0",
"fld_auto_increment": "0",
"fld_key": "0",
"fld_table_index": "0"
}
]
}
]
PHP Example:
Print out the PM Tables and the fields in each table.
$url = "/api/1.0/workflow/pmtable";
$oRet = pmRestRequest("GET", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
foreach ($oRet->response as $oPmTable) {
print "Table {$oPmTable->pmt_tab_name}:\n";
foreach ($oPmTable->fields as $oField) {
print "\t{$oField->fld_name} ({$oField->fld_type})\n";
}
}
}
Get PM Table Structure: GET /pmtable/{pmt_uid}
Get the structure from a specified PM Table, including a list of its fields and their properties.
- GET /api/1.0/{workspace}/pmtable/{pmt_uid}
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/pmtable/33532851355ef56860e8297082884997 pmt_uid Unique ID of the PM Table /api/1.0/workflow/pmtable/33532851355ef56860e8297082884997
Result:
If successful, the HTTP status is set to 200
(OK) and a PM Table object is returned, such as:
"pmt_uid": "33532851355ef56860e8297082884997",
"pmt_tab_name": "PMT_CLIENTS",
"pmt_tab_description": "Table with information about clients",
"pmt_tab_class_name": "PmtClients",
"pmt_num_rows": 28,
"fields":
[
{
"fld_uid": "22501963155ef568633c460054115944",
"fld_index": "0",
"fld_name": "ID",
"fld_description": "ID",
"fld_type": "BIGINT",
"fld_size": "8",
"fld_null": "0",
"fld_auto_increment": "1",
"fld_key": "1",
"fld_table_index": "0"
},
{
"fld_uid": "58722687755ef568650b502051774480",
"fld_index": "1",
"fld_name": "COMPANY_NAME",
"fld_description": "CompanyName",
"fld_type": "VARCHAR",
"fld_size": "50",
"fld_null": "0",
"fld_auto_increment": "0",
"fld_key": "0",
"fld_table_index": "0"
}
]
}
PHP Example:
Print out the number of records in a PM Table and list the fields in the PM Table.
$tableId = '33532851355ef56860e8297082884997';
$url = "/api/1.0/workflow/pmtable/$tableId";
$oRet = pmRestRequest("GET", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
print "Table {$oRet->response->pmt_tab_name} has {$oRet->response->pmt_num_rows} records\n";
}
Get PM Table Data: GET /pmtable/{pmt_uid}/data
Get the data (records) from a PM table.
- GET /api/1.0/{workspace}/pmtable/{pmt_uid}/data
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/pmtable/33532851355ef56860e8297082884997/data pmt_uid Unique ID of the PM Table /api/1.0/workflow/pmtable/33532851355ef56860e8297082884997/data
Optional GET Parameters:
-
Name Type Description q={where:spec} string This is a generic way to search via the filterType "where" (only this one is supported) and where
spec is the specification of the filter, for example for a where filter, this is a logical condition that the results must match
For example,GET /api/1.0/workflow/pmtable/33532851355ef56860e8297082884997/data?q={"where": {"name": "Felix", "lastname": "Mondaca"}}
would return the row of the PM Table that has the values: "Felix", "Mondaca" in the fields "name" and "lastname" respectively .
Result:
If successful, the HTTP status is set to 200
(OK) and an object is returned with the rows of data in the PM Table and the number of rows.
For example:
"rows": [
{
"id": "1",
"company_name": "Western Fuels Corp.",
"address": "235 W. Elm St, Greenwood, NC 34928",
"has_contract": "1",
"__index__": "lg"
},
{
"id": "2",
"company_name": "Wrightspeed Transport",
"address": "2845 MLK Drive, Los Angeles, CA 28764",
"has_contract": "0",
"__index__": "lw"
},
{
"id": "3",
"company_name": "Albemarle Chemical",
"address": "2810 E. 26th St., Brooklyn, NY 98245",
"has_contract": "1",
"__index__": "mA"
}
],
"count": 3
}
Note: The field names are automatically converted to lowercase.
Note: Integers, floating-point numbers (real numbers) and boolean values are converted to strings. In the above example, the id is an integer and the has_contract is a boolean in MySQL. Also, the __index__ field is automatically created by MySQL to index the PM Table.
PHP Example:
Print out the records in a PM Table in an HTML table. First get the structure of the PM Table with GET /api/1.0/workflow/pmtable/{pmt_uid} in order to print out the label (description) of each field in the headers of the HTML table. Then, get the records with GET /api/1.0/workflow/pmtable/{pmt_uid}/data and print out each record as a record in the HTML table.
$tableId = '33532851355ef56860e8297082884997';
$url = "/api/1.0/workflow/pmtable/$tableId";
$oRet = pmRestRequest("GET", $url, null, $oToken->access_token);
if ($oRet->status == 200) {
$aFields = array(); //array of fields in the PM Table
print "\n" . '<table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;">' .
"<tbody>\n<tr>";
foreach ($oRet->response->fields as $oField) {
$aFields[] = strtolower($oField->fld_name); //convert field names to lowercase
print "<th>{$oField->fld_description}</th>";
}
print "</tr>\n";
$url2 = "/api/1.0/workflow/pmtable/$tableId/data";
$oRet2 = pmRestRequest("GET", $url2, null, $oToken->access_token);
if ($oRet2->status == 200) {
foreach ($oRet2->response->rows as $oRow) {
$aRow = get_object_vars($oRow); //convert object to associative array
print "<tr>\n";
foreach ($aFields as $fieldName) {
print ' <td>' . $aRow[$fieldName] . "</td>\n";
}
print "</tr>\n";
}
}
print "</tbody></table>\n";
}
Create PM Table: POST /pmtable
Create a new PM Table.
- POST /api/1.0/{workspace}/pmtable
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/pmtable
POST Fields:
-
Name Description { Start object. "pmt_tab_name", The name of the PM Table, which only consists of ASCII letters, numbers and underscores ("_"). It will automatically be converted to UPPERCASE. It is strongly recommended that it begin with "PMT_"
."pmt_tab_dsc", Optional. Description of the PM Table. "fields" An array of field objects. [ Start the array. { Start object defining field. "fld_name", The field name, which should only contain ASCII letters, numbers and underscores ("_"). It will automatically be converted to UPPERCASE. It is recommended that it be in UPPERCASE. "fld_label, The field's label. "fld_type", The field type, which can be: - BIGINT: An integer of 8 bytes between
-9223372036854775808
and9223372036854775807
. - BOOLEAN: A binary value of either
1
(true) or0
(false), but this stored as an INTEGER in the database. - CHAR: A string of a characters between
0
and255
in length. The number of characters stored in the database is fixed. If the field size is 100, then 100 characters are stored in the database, even if the value in the field has fewer characters. - DATE: A date in the
'YYYY-MM-DD'
format. The supported range is'1000-01-01'
to'9999-12-31'
. - DATETIME: A datetime in the
'YYYY-MM-DD HH:MM:SS'
format. The supported range is'1000-01-01 00:00:00'
to'9999-12-31 23:59:59'
. - DECIMAL: A decimal number, which has exactly 2 decimal digits. This is the recommended type when using currency.
- DOUBLE: A decimal number of 8 bytes. The supported range is
-1.7976931348623157E+308
to-2.2250738585072014E-308
,0
, and2.2250738585072014E-308
to1.7976931348623157E+308
. - FLOAT: A decimal number of 4 bytes. The supported range is
-3.402823466E+38
to-1.175494351E-38
,0
, and1.175494351E-38
to3.402823466E+38
. - INTEGER: An integer of 4 bytes between
-2147483648
and2147483647
. - LONGVARCHAR: A string of a variable number of characters, between 0 and 16,777,215 characters long. This is a synonym for a MEDIUMTEXT field.
- REAL: A synonym for DOUBLE (unless the REAL_AS_FLOAT SQL mode is enabled).
- SMALLINT: An integer of 2 bytes between
-32768
and32767
. - TIME: The time in 'HH:MM:SS' format.
- TIMESTAMP: A synonym for DATETIME.
- TINYINT: An integer of 1 byte between
-128
and127
. - VARCHAR: A string of a variable number of characters, between 0 and 255 characters in length before MySQL 5.0.3 and between 0 and 65,535 characters in MySQL 5.0.3 and later.
"fld_size", The field size is required for CHAR and VARCHAR fields, where it sets the maximum number of allowed characters. The field size is optional for BOOLEAN, TINYINT, SMALLINT, INTEGER and BIGINT fields, where it sets the maximum number of allowed digits. It is also optional for FLOAT, REAL and DECIMAL fields, where it sets the maximum number of digits before the decimal point. The number of decimal digits cannot be specified, although it is automatically set to 2 in DECIMAL fields. For example, setting fld_size
to4
allows numbers between-9999.X
and9999.X
with the number of decimals determined by the maximum for the data type.
Thefld_size
should NOT be included in DOUBLE, DATE, TIME, DATETIME, TIMESTAMP and LONGVARCHAR fields or it will cause a 400 error with no response object. Likewise, a 400 error will be caused if thefld_size
is set to a value larger than the allowed size, such as50
for an INTEGER."fld_null", Optional. Set to 1
if this field may have a value ofNULL
, meaning "no data". Otherwise, set to0
, meaning that the field must have a value. If not included, then set to1
by default."fld_autoincrement", Optional. Set to 1
if this field will be auto-incremented, meaning that the value will be automatically inserted as the maximum existing value in the field plus 1. This option is recommended for ID fields. Otherwise set to0
, which is the default."fld_key" Optional. Set to 1
if this field should be a primary key field, meaning that its value will be unique and it will used to index the table. Otherwise set to0
, which is the default if not included.} End of object defining the field. ... Any additional field objects. ] End array of field objects. } End object. - BIGINT: An integer of 8 bytes between
Result:
If the table is created, then the HTTP status code is set to 201
(Created) and a object is returned with information about the new PM Table. See the JSON example below.
JSON example:
Request:
"pmt_tab_name": "PMT_CONTRACTS",
"pmt_tab_dsc": "Clients for accounting services",
"fields": [
{
"fld_name": "ID",
"fld_label": "ID number",
"fld_type": "INTEGER",
"fld_size": 8,
"fld_key": 1,
"fld_null": 0,
"fld_autoincrement": 1
},
{
"fld_name": "NAME",
"fld_label": "Contractor Name",
"fld_type": "VARCHAR",
"fld_size": 120
},
{
"fld_name": "AMOUNT",
"fld_label": "Contract Amount",
"fld_type": "DECIMAL"
},
{
"fld_name": "DUE_DATE",
"fld_label": "Contract Due Date",
"fld_type": "DATE"
}
]
}
Response:
"pmt_uid": "83869640955f217bb427890052454465",
"pmt_tab_name": "PMT_CONTRACTS",
"pmt_tab_description": "Contracts for accounting services",
"pmt_tab_class_name": "PmtContracts",
"pmt_num_rows": 0,
"fields":
[
{
"fld_uid": "52437664155f217bb6f79b6006806943",
"fld_index": 0,
"fld_name": "ID",
"fld_description": "ID number"
"fld_type": "INTEGER"
"fld_size": 8,
"fld_null": 0,
"fld_auto_increment": 1,
"fld_key": 1,
"fld_table_index": 0
},
{
"fld_uid": "78554318355f217bb8ea6b4079739653",
"fld_index": 1,
"fld_name": "NAME",
"fld_description": "Contractor Name",
"fld_type": "VARCHAR",
"fld_size": 120,
"fld_null": 1,
"fld_auto_increment": 0,
"fld_key": 0,
"fld_table_index": 0
},
{
"fld_uid": "11719892455f217bb999165017574602",
"fld_index": 2,
"fld_name": "AMOUNT",
"fld_description": "Contract Amount",
"fld_type": "DECIMAL",
"fld_size": NULL,
"fld_null": 1,
"fld_auto_increment": 0,
"fld_key": 0,
"fld_table_index": 0
},
{
"fld_uid": "60151324555f217bba48057032011257",
"fld_index": 3,
"fld_name": "DUE_DATE",
"fld_description": "Contract Due Date",
"fld_type": "DATE",
"fld_size": NULL,
"fld_null": 1,
"fld_auto_increment": 0,
"fld_key": 0,
"fld_table_index": 0
}
]
}
PHP example:
$aVars = array(
"pmt_tab_name" => "PMT_CONTRACTS",
"pmt_tab_dsc" => "Contracts for accounting services",
"fields" => array(
array(
"fld_name" => "integer_",
"fld_label" => "ID number",
"fld_type" => "INTEGER",
"fld_key" => 1,
"fld_size" => 8,
"fld_null" => 0,
"fld_autoincrement" => 1
),
array(
"fld_name" => "NAME",
"fld_label" => "Contractor Name",
"fld_type" => "VARCHAR",
"fld_size" => 120
),
array(
"fld_name" => "AMOUNT",
"fld_label" => "Contract Amount",
"fld_type" => "DECIMAL"
),
array(
"fld_name" => "DUE_DATE",
"fld_label" => "Contract Due Date",
"fld_type" => "DATE"
)
)
);
$url = "/api/1.0/workflow/pmtable";
$oRet = pmRestRequest("POST", $url, $aVars, $oToken->access_token);
if ($oRet->status == 201) {
print "PM Table with UID '{$oRet->response->pmt_uid}' created.\n";
}
Note: If using PHP, the POST variables will need to be passed through the http_build_query() which will cause problems with fields which include the fld_size
. The ProcessMaker source code needs to be changed to avoid an error.
Add PM Table Data: POST /pmtable/{pmt_uid}/data
Add a new record to a PM Table.
- POST /api/1.0/{workspace}/pmtable/{pmt_uid}/data
URL Parameters:
-
Name Description Example workspace Workspace name /api/1.0/workflow/pmtable/22815673755f209dd749c90081062413/data pmt_uid Unique ID of PM Table /api/1.0/workflow/pmtable/22815673755f209dd749c90081062413/data
POST Fields:
The following object where the member variables have the same names as the fields in the PM Table and their values will be inserted in a new record in the PM Table.
For example:"ID": 1262, //INTEGER
"CLIENT_NAME": "Sprockets Inc.", //CHAR
"ADDRESS": "214 Elm St.\nDurham, FL 47621", //VARCHAR with new line
"AMOUNT": 13435.99, //DECIMAL
"WORK_START": "2015-10-31 14:04:45", //DATETIME
"PAUSE_TIME": "13:34:20", //TIME
"DUE_DATE": "2015-12-31", //DATE
"HAS_CONTRACT": 1 //BOOLEAN
}
Result:
If successful, the HTTP status is set to 201
(Created) and the new record which has been inserted in the PM Table is returned, with the field names in lowercase.
"field_name1" : "VALUE1",
"field_name2" : "VALUE2",
...
}
PHP example:
$oToken = pmRestLogin("IAIERTORPBHIJZXEPNSUANXLKYPKODJU", "71308091055cb7094026089092397336", "amos", "sample");
$tableId = '22815673755f209dd749c90081062413';
$aVars = array(
"ID" => 1262, //INTEGER
"CLIENT_NAME" => "Sprockets Inc.", //CHAR
"ADDRESS" => "214 Elm St.\nDurham, FL 47621", //VARCHAR with new line
"AMOUNT" => 13435.99, //DECIMAL
"WORK_START" => "2015-10-31 14:04:45", //DATETIME
"PAUSE_TIME" => "13:34:20", //TIME
"DUE_DATE" => "2015-12-31", //DATE
"HAS_CONTRACT"=> 1 //BOOLEAN
);
$url = "/api/1.0/workflow/pmtable/";//$tableId/data";
$oRet = pmRestRequest("GET", $url, $aVars, $oToken->access_token);
if ($oRet->status == 201) {
print '<html><head><meta charset="UTF-8"></head><body><pre>';
print "Record inserted!";
print '