API / Users

Users endpoint enables you to get user information and manage users in Silverbucket's database. Endpoint's URL is:

https://<your_environment_url>/customer-api/1.0/users/

GET


When calling /users/ endpoint without parameters you will get all the users from database. Example response:
{
    "count": 1,
    "csvUrl": "/customer-api/1.0/users/?csv=true",
    "itemsPerPage": 500,
    "excelUrl": "/customer-api/1.0/users/?excel=true",
    "next": null,
    "current": 1,
    "lastPage": 1,
    "data": [
        {
            "id": 5298,
            "last_login": "2019-08-26T10:20:55.845277",
            "username": "captain",
            "first_name": "Manual User",
            "last_name": "Help &",
            "email": "support@silverbucket.com",
            "is_superuser": true,
            "is_staff": true,
            "is_contractuser": true,
            "is_mainuser": true,
            "is_active": true,
            "date_joined": "2019-04-08T15:29:30.661258",
            "startdate": "2016-11-01",
            "enddate": null,
            "dayload": "7.50",
            "language": "fi",
            "is_external": false,
            "is_stealth": false,
            "cost_price": "144.00",
            "hourly_rate": "99.00",
            "external_id": "XYZ123abc456",
            "capacity": "100.00",
            "is_future_talent": false,
            "hourlock_date": "2020-04-30",
            "node": 462,
            "country": 1,
            "site": 1,
            "cost_center": null,
            "invoicing_price_group": null,
            "default_role": 245,
            "supervisor": 3572,
            "calendar": null,
            "currency": 1
        }
    ],
    "previous": null
}

POST


You can add user's with POST method to the same URL than get. POST body contains new user's data in JSON format. Successful call will give response code 201 and return the newly created user's JSON. Minimum JSON for adding a user is:
{
    "username": "<string: unique>",
    "first_name": "<string>",
    "last_name": "<string>",
    "startdate": "YYYY-MM-DD",
    "language": "<ISO 639-1>",
    "default_role": <role_id>,
    "dayload": "<DECIMAL(10, 2)>",
    "currency": <currency_id>
}

Below is an example of which metadata fields you can add with /users/ endpoint:
{
    "username": "<string: unique>",
    "first_name": "<string>",
    "last_name": "<string>",
    "email": "<string>",
    "is_superuser": <boolean: true|false>,
    "is_staff": <boolean: true|false>,
    "is_contractuser": <boolean: true|false>,
    "is_mainuser": <boolean: true|false>,
    "is_active": <boolean: true|false>,
    "startdate": "<YYYY-MM-DD>",
    "enddate": "<YYYY-MM-DD>"|null,
    "dayload": "<DECIMAL(10, 2)>",
    "language": "<ISO 639-1>",
    "is_external": <boolean: true|false>,
    "is_stealth": <boolean: true|false>,
    "cost_price": "<DECIMAL(10, 2)>"|null,
    "hourly_rate": "<DECIMAL(10, 2)>"|null,
    "external_id": "<string>"|null,
    "capacity": "<DECIMAL(10, 2)>",
    "is_future_talent": <boolean: true|false>,
    "hourlock_date": "<YYYY-MM-DD>"|null,
    "node": <node_id>|null,
    "country": <country_id>|null,
    "site": <site_id>|null,
    "cost_center": <cost_center_id>|null,
    "invoicing_price_group": <invoicing_price_group_id>|null,
    "default_role": <role_id>,
    "supervisor": <user_id>|null,
    "calendar": <calendar_id>|null,
    "currency": <currency_id>
}

PATCH

If you want to modify some record, it can be done with the PATCH method. URL for the PATCH must include the record's ID which you wish to edit:
https://<your_environment_url>/customer-api/1.0/users/<id>/
In message body you should deliver the edited fields. You can edit all the fields which are available for POSTing.
How did we do with this article?