Back Developer API
- Overview
- Users
- Users / KPIs
- Users / Group Items
- Groups
- Groups / Group Items
- KPI Categories
- KPI Categories / KPIs
- KPIs
- KPI Frequencies
- KPI Units
- KPI Icons
- KPI Entries
- Reports
- C# Example
Users / KPIs
These are the KPIs that are assigned to a user. This determines what KPIs the user can enter data against and what KPIs the user can analyze. It also sets the target for the User KPI if the user has a target that is different to the default KPI target.
User KPI Object
The object has the following properties:
| Name | Type | Read Only | Mandatory | Max Len. | Notes |
|---|---|---|---|---|---|
| id | integer | no | yes | The id of the KPI to assign to the user | |
| user_id | integer | yes | no | Id of the user assigned to the KPI | |
| user_target | decimal | no | no | The user target is only set if the KPI has a target | |
| sort_order | integer (16 bit) | no | yes | The display order of the KPIs for the user on the KPI Entry screen | |
| created_at | datetime | yes | no | The UTC date and time the item was created | |
| updated_at | datetime | yes | no | The UTC date and time of the last update of the item |
JSON Example
{
"id": 1234,
"user_id": 5678,
"user_target": 123,
"sort_order": 1,
"created_at": "2012-11-15T17:03:00",
"updated_at": "2012-11-15T17:03:00"
} XML Example
<UserKPI xmlns="http://schemas.datacontract.org/2004/07/SimpleKPI.Application.Areas.Api.Models"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<id>1234</id>
<user_id>5678</user_id>
<user_target>123</user_target>
<sort_order>1</sort_order>
<created_at>2012-11-15T17:03:00</created_at>
<updated_at>2012-11-15T17:03:00</updated_at>
</UserKPI>
Get all User's KPIs
GET /api/users/{user_id}/kpis
Using curl
curl https://{subdomain}.simplekpi.com/api/users/{user_id}/kpis
-v -u {email_address}:{token}
Example Response
Status: 200 OK
[
{
"id": 1234,
"user_id": 5678,
"user_target": 123,
"sort_order": 1,
"created_at": "2012-11-15T17:03:00",
"updated_at": "2012-11-15T17:03:00"
},
{
"id": 1234,
"user_id": 5678,
"user_target": 456,
"sort_order": 2,
"created_at": "2012-12-15T17:03:00",
"updated_at": "2012-12-15T17:03:00"
},
]
Get a User's KPI
GET /api/users/{user_id}/kpis/{id}
Using curl
curl https://{subdomain}.simplekpi.com/api/users/{user_id}/kpis/{id}
-v -u {email_address}:{token} Example Response
Status: 200 OK
{
"id": 1234,
"user_id": 5678,
"user_target": 123,
"sort_order": 1,
"created_at": "2012-11-15T17:03:00",
"updated_at": "2012-11-15T17:03:00"
}
Add a User's KPI
POST /api/users/{user_id}/kpis
Using curl
curl https://{subdomain}.simplekpi.com/api/users/{user_id}/kpis
-H "Content-Type: application/json"
-d '{"id": "1234", "user_target": 123, "sort_order": 1}'
-v -u {email_address}:{token} -X POST
Example Response
Status: 201 Created
Location: https://{subdomain}.simplekpi.com/api/users/{user_id}/kpis/{id}
{
"id": 1234,
"user_id": 5678,
"user_target": 123,
"sort_order": 1,
"created_at": "2012-11-15T17:03:00",
"updated_at": "2012-11-15T17:03:00"
}
Update a User's KPI
PUT /api/users/{user_id}/kpis/{id}
Using curl
curl https://{subdomain}.simplekpi.com/api/users/{user_id}/kpis/{id}
-H "Content-Type: application/json"
-d '{"user_target": 123, "sort_order": 2}'
-v -u {email_address}:{token} -X PUT
Example Response
Status: 200 OK
{
"id": 1234,
"user_id": 5678,
"user_target": 123,
"sort_order": 1,
"created_at": "2012-11-15T17:03:00",
"updated_at": "2012-11-15T17:03:00"
}
Delete a User's KPI
DELETE /api/users/{user_id}/kpis/{id}
Using curl
curl https://{subdomain}.simplekpi.com/api/users/{user_id}/kpis/{id}
-v -u {email_address}:{token}
Example Response
Status: 200 OK