API documentation for developers. With the API you can integrate WorkPan with your own software or website
The WorkPan API offers a set of callable methods.
You can integrate WorkPan with any application by accessing the database through the API.
A rate limit applies to every request: no more than 8 requests per second.
Before using the API you have to enable it and generate a token key — that is done in the “Modules” section of the control panel. After that every API request must carry this token parameter.
Requests can be sent with GET|POST.
All responses are returned in JSON.
URL: is the address of your system, for example https://_YOUR_LOGIN_.workpan.com.
In this guide we use the DEMO system with the following details
URL:
- https://demo.workpan.com
token:
- wt3sctw89sl
Contents:
Section 1: Getting the status of an order
Request:
|
|
Method |
/api/order-status/ |
token (required) |
(string) token |
id (required) |
(integer) Order number |
Response:
| Key |
Type |
Description |
status |
(boolean) |
Request status: TRUE|FALSE |
data |
(object) |
The data object |
The data object in detail.
| Key |
Description |
id |
Order key |
contacts_id |
Contact key |
contacts_name |
Contact name |
global_sid |
Status key |
global_status_name |
Full status description |
global_status_name_sm |
Short status description |
global_status_class |
Status class: ('none','warning','success','important','info','inverse') |
global_status_type |
Status type: (1 = waiting, 2 = open, 3 = in progress, 4 = success, 5 = error, 6 = closed) |
gid |
Device type key |
g_name |
Device type |
bid |
Brand key |
b_name |
Brand |
models_id |
Model key |
m_name |
Model |
imei |
Device IMEI |
bt_data |
Fault description |
nt_data |
Order note |
discount_name |
Discount |
sumPrice |
Total for services |
sumDiscount |
Discount amount |
sumTotal |
Grand total |
repairs |
An array of repair type objects:
orders_repairs_id — the repair ticket
products_rosters_id — the repair type key
products_rosters_name — the name
price — the price
|
details |
An array of component objects:
orders_details_id — the purchasing ticket
details_rosters_id — the part key
details_rosters_name — the name
price — the price
|
<?php
$url = 'https://demo.workpan.com/api/order-status/';
$token = 'wt3sctw89sl'; // Sample token, you can get yours in your account
$id = 10; // Sample order key
$postData = array(
'token' => $token,
'id' => $id
);
$post = http_build_query($postData);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
// Output
$obj = json_decode($response);
var_dump($obj);
{
"data": {
"id": "10",
"contacts_id": "23",
"contacts_name": "Мария",
"global_sid": "27",
"global_status_name": "Выдан с ремонтом",
"global_status_name_sm": "Выдан с ремонтом",
"global_status_class": "info",
"global_status_type": "4",
"gid": "2",
"g_name": "Планшет",
"bid": "1",
"b_name": "3Q",
"models_id": "17",
"m_name": "3Q Q-pad MT0729D",
"imei": null,
"bt_data": "После попадания воды планшет не включается, так же разбит дисплей",
"nt_data": null,
"discount_name": null,
"sumPrice": "7500.00",
"sumDiscount": "0.00",
"sumTotal": "7500.00",
"repairs": [
{
"orders_repairs_id": "34",
"products_rosters_id": "1",
"products_rosters_name": "Диагностика",
"price": "0"
},
{
"orders_repairs_id": "35",
"products_rosters_id": "2",
"products_rosters_name": "Чистка после попадания воды",
"price": "1500"
},
{
"orders_repairs_id": "36",
"products_rosters_id": "85",
"products_rosters_name": "Замена модуля (стекло, тачскрин и дисплей)",
"price": "1500"
}
],
"details": [
{
"orders_details_id": "5",
"details_rosters_id": "48",
"details_rosters_name": "Модуль (стекло, тачскрин и дисплей)",
"price": "4500"
}
]
},
"status": true
}
Section 2: Getting the IDs of all orders
Request:
|
|
Method |
/api/get-orders-ids/ |
token (required) |
(string) token |
page |
(integer) Page number |
create_date_start |
(integer) Order creation date, from (UNIXTIMESTAMP) |
create_date_end |
(integer) Order creation date, to (UNIXTIMESTAMP) |
Response:
| Key |
Type |
Description |
paginator |
(object) |
Paging data for the request |
items |
(object) |
Order IDs, for fetching the full data afterwards |
{
"paginator": {
"pageCount": 2,
"itemCountPerPage": 10,
"first": 1,
"current": 1,
"last": 2,
"next": 2,
"pagesInRange": {
"1": 1,
"2": 2
},
"firstPageInRange": 1,
"lastPageInRange": 2,
"currentItemCount": 10,
"totalItemCount": 11,
"firstItemNumber": 1,
"lastItemNumber": 10
},
"items": [
"1",
"2",
"9",
"22",
"29",
"30",
"31",
"32",
"33",
"34"
]
}
Section 3: Getting order details by ID
Request:
|
|
Method |
/api/get-order-by-id/ |
token (required) |
(string) token |
id (required) |
(integer) Order number |
Response:
| Key |
Type |
Description |
id |
(integer) |
Order ID |
contacts_id |
(integer) |
Contact/client ID (see the corresponding section for the full data) |
models_id |
(integer) |
Model ID |
models_name |
(string) |
Model name |
models_gadgets_id |
(integer) |
Device type ID |
models_gadgets_name |
(string) |
Device type name |
models_brands_id |
(integer) |
Brand ID |
models_brands_name |
(string) |
Brand name |
services_id |
(integer) |
Service centre ID |
create_uid |
(integer) |
ID of the user who created the order (see the corresponding section for the data) |
create_date |
(datetime) |
Order creation date |
create_date_u |
(integer) |
Order creation date (UNIXTIMESTAMP) |
priority |
(integer) |
Order priority (1, 2, 3) |
isService |
(boolean) |
Whether the device is at the service centre (0 => with the client, 1 => at the service centre) |
isWarranty |
(boolean) |
Is it a warranty order? (0 => no, 1 => yes) |
isClose |
(boolean) |
Is the order closed? (0 => no, it can be edited, 1 => yes, closed) |
bug_tid |
(integer) |
Fault description key (see the corresponding section for the full data) |
note_tid |
(integer) |
Order note (see the corresponding section for the full data) |
color_rid |
(integer) |
Device colour (see the corresponding section for the full data) |
discount_rid |
(integer) |
Order discount (see the corresponding section for the full data) |
discount_type |
(integer) |
Discount type (1 => on labour, 2 => on everything) |
oriented |
(integer) |
Agreed amount |
imei |
(string) |
Device serial number |
cond |
(string) |
Condition |
appearance |
(string) |
Appearance |
complete |
(string) |
What came with it |
global_sid |
(integer) |
Global order status (see the corresponding section for the full data) |
client_sid |
(integer) |
Client status (see the corresponding section for the full data) |
acceptance_sid |
(integer) |
Intake status (see the corresponding section for the full data) |
detail_sid |
(integer) |
Parts status (see the corresponding section for the full data) |
repair_sid |
(integer) |
Repairs status (see the corresponding section for the full data) |
delivery_sid |
(integer) |
Handover status (see the corresponding section for the full data) |
acceptance_uid |
(integer) |
ID of the employee who took the device in (see the corresponding section for the full data) |
acceptance_date |
(datetime) |
Intake date |
acceptance_date_u |
(integer) |
Intake date (UNIXTIMESTAMP) |
delivery_uid |
(integer) |
ID of the user who handed the device over (see the corresponding section for the full data) |
delivery_date |
(datetime) |
Handover date |
delivery_date_u |
(integer) |
Handover date (UNIXTIMESTAMP) |
delivery_type |
(integer) |
Handover type (1 => repaired, 2 => not repaired) |
expect_date |
(date) |
Expected handover date |
expect_date_u |
(integer) |
Expected handover date (UNIXTIMESTAMP) |
sumPrice |
(float) |
Total for all services |
sumDiscount |
(float) |
Discount amount |
sumTotal |
(float) |
Grand total (services minus discount) |
sumExpense |
(float) |
Total expenses |
sumPaid |
(float) |
Paid |
sumIncome |
(string) |
Profit |
guarantee_rid |
(string) |
Warranty key ID (see the corresponding section for the full data) |
{
"id": "31",
"contacts_id": "23",
"models_id": "1928",
"models_name": "Apple iPhone 2G",
"models_gadgets_id": "1",
"models_gadgets_name": "Apple",
"models_brands_id": "5",
"models_brands_name": "Телефон",
"services_id": "2",
"create_uid": "1",
"create_date": "2018-07-05 16:30:55",
"create_date_u": "1530790255",
"priority": "2",
"isService": "1",
"isWarranty": "0",
"isClose": "0",
"bug_tid": "10",
"note_tid": null,
"color_rid": "107",
"discount_rid": null,
"discount_type": null,
"oriented": "0",
"imei": "",
"cond": "Б/У",
"appearance": "Потертости,Царапины",
"complete": "Без упаковки,Без флешки,Без СЗУ,Без аккумлятора",
"global_sid": "14",
"client_sid": "7",
"acceptance_sid": "10",
"detail_sid": "14",
"repair_sid": "21",
"delivery_sid": null,
"acceptance_uid": "1",
"acceptance_date": "2019-01-19 14:36:40",
"acceptance_date_u": "1547890600",
"delivery_uid": null,
"delivery_date": null,
"delivery_date_u": null,
"delivery_type": null,
"expect_date": "2019-03-11",
"expect_date_u": "1552244400",
"sumPrice": "1000.00",
"sumDiscount": "0.00",
"sumTotal": "1000.00",
"sumExpense": "0.00",
"sumPaid": "1000.00",
"sumIncome": "1000.00",
"guarantee_rid": null
}
Request:
|
|
Method |
/api/get-contact-by-id/ |
token (required) |
(string) token |
id (required) |
(integer) Contact number |
Response:
| Key |
Type |
Description |
id |
(integer) |
Contact ID |
name |
(string) |
Name |
create_users_id |
(integer) |
The user who created the contact |
date_create |
(datetime) |
Creation date |
date_create_u |
(integer) |
Creation date (UNIXTIMESTAMP) |
date_update |
(datetime) |
Update date |
date_update_u |
(integer) |
Update date (UNIXTIMESTAMP) |
types |
(string) |
Contact type (ENUM('client','organization','provider')) |
status |
(integer) |
Status |
update_users_id |
(integer) |
ID of the user who updated the contact |
communications |
(object) |
An array of the contact’s communication data (phone, website, address and so on) |
{
"id": "23",
"name": "Мария",
"create_users_id": "1",
"date_create": "2018-06-11 18:38:11",
"date_create_u": "1528724291",
"date_update": "2019-03-29 16:44:23",
"date_update_u": "1553859863",
"types": "client",
"status": "1",
"update_users_id": "1",
"communications": [
{
"rosters_id": "1",
"rosters_name": "Телефон",
"rosters_type_id": "17",
"rosters_type_name": "Мобильный",
"data": "78124987856"
},
{
"rosters_id": "1",
"rosters_name": "Телефон",
"rosters_type_id": "16",
"rosters_type_name": "Рабочий",
"data": "7495123456"
}
]
}
Section 5: Getting status details by ID
Request:
|
|
Method |
/api/get-status-by-id/ |
token (required) |
(string) token |
id (required) |
(integer) Status ID |
Response:
| Key |
Type |
Description |
id |
(integer) |
Status ID |
name |
(string) |
Name |
name_small |
(string) |
Short name |
status_groups_id |
(integer) |
Status group ID |
status_groups_name |
(string) |
Status group name |
class |
(string) |
class ENUM('none','warning','success','important','info','inverse') |
class_i |
(integer) |
class integer |
type |
(string) |
type ENUM(waiting, open, in progress, success, error, closed) |
type_i |
(integer) |
type integer |
{
"id": "14",
"name": "Требуется назначить закупщика",
"name_small": "Тр. назначить закупщика",
"status_groups_id": "4",
"status_groups_name": "Запчасти",
"class": "warning",
"class_i": "2",
"type": "ожидание",
"type_i": "1"
}
Section 6: Getting employee details by ID
Request:
|
|
Method |
/api/get-user-by-id/ |
token (required) |
(string) token |
id (required) |
(integer) Employee ID |
Response:
| Key |
Type |
Description |
id |
(integer) |
Employee ID |
name |
(string) |
First name |
lastname |
(string) |
Last name |
{
"id": "1",
"create_date": "2018-04-18 19:11:42",
"create_date_u": "1524060702",
"create_uid": "1",
"name": "Иван",
"lastname": "Иванов",
"patronymic": null,
"login": "ivanov123",
"auths_groups_id": "1",
"isAdmin": "1",
"services_id": "1",
"status_id": "50",
"rosters_posts_id": "1",
"date_birth": "1989-01-01",
"date_birth_u": "614372400",
"note": null,
"career_start": "2018-02-01",
"career_end": null,
"communications": [
{
"rosters_id": "1",
"rosters_name": "Телефон",
"rosters_type_id": null,
"rosters_type_name": null,
"data": "+749512346"
},
{
"rosters_id": "3",
"rosters_name": "E-mail",
"rosters_type_id": null,
"rosters_type_name": null,
"data": "[email protected]"
},
{
"rosters_id": "12",
"rosters_name": "Мессенджер",
"rosters_type_id": null,
"rosters_type_name": null,
"data": "skype_name"
}
]
}
Section 7: Getting text data by ID (fields ending in _tid)
Request:
|
|
Method |
/api/get-text-by-id/ |
token (required) |
(string) token |
id (required) |
(integer) ID of the record | the _tid fields in the requests above |
Response:
| Key |
Type |
Description |
id |
(integer) |
ID |
data |
(string) |
The data |
{
"id": "15",
"data": "Не заряжается"
}
Section 8: Getting reference book data by ID (fields ending in _rid)
Request:
|
|
Method |
/api/get-roster-by-id/ |
token (required) |
(string) token |
id (required) |
(integer) ID of the record | the _rid fields in the requests above |
Response:
| Key |
Type |
Description |
id |
(integer) |
ID |
name |
(string) |
Name |
{
"id": "15",
"name": "Банковские реквизиты"
}