Trak Software Documentation logo

Users


GET /users

Query Parameters

Parameter Type Description
account Integer Retrieve users attached to an account.
active Boolean Filter users by active flag.
join String Values to join to account resource.
group Integer Filter users by their group id
search String Filter users by searching first, last and email fields.

Joining Resources

Here is a list of available resources to join on users.

[ 'accounts', 'accounts.logo', 'avatar']

Example Requests

All active managers

https://example.trak.io/api/v1/users?active=true&group_id=3

User with ID 1

https://example.trak.io/api/v1/users/1

Example Response

{
    "success": true,
    "message": null,
    "data": {
        "current_page": 1,
        "data": [
            {
                "user_id": 1,
                "site_id": 1,
                "group_id": 1,
                "first": "Trak",
                "last": "Admin",
                "email": "admin@trak.io",
                "avatar": {
                    "file_id": 3,
                    "site_id": 1,
                    "user_id": 1,
                    "name": "trak-cover.jpg",
                    "path": "users/1/aEF2C3LI3h1JjPrXjZractxfeEHDBsNjhjhmRIf0.jpeg",
                    "url": "<AWS_URL_GOES_HERE>/users/1/aEF2C3LI3h1JjPrXjZractxfeEHDBsNjhjhmRIf0.jpeg",
                    "created_at": "2018-12-03 20:33:01",
                    "updated_at": "2018-12-03 20:33:01"
                },
                "terms": 1,
                "active": 1,
                "editor": 1,
                "created_at": "2018-12-03 20:33:01",
                "updated_at": "2019-02-14 22:34:56",
                "login_at": "2019-02-14 22:34:56"
            }
        ],
        "first_page_url": "https://example.trak.io/api/v1/users?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "https://example.trak.io/api/v1/users?page=1",
        "next_page_url": null,
        "path": "https://example.trak.io/api/v1/users",
        "per_page": 50,
        "prev_page_url": null,
        "to": 7,
        "total": 7
    }
}

POST /users

Query Parameters

Parameter Type Required Description
email String true Email Address of the user.
first String true First name of the user.
group_id Integer true The group the user is assigned.
last String true Last name of the user.

{primary} You can only create users with a group_id greater than or equal to your group id.

Example Requests

{
    'first': 'Trak',
    'last': 'Collaborator',
    'email': 'collaborator#company.com',
    'group_id': 5
}

Example Response

{
    "success": true,
    "message": "API_USER_CREATED",
    "data": {
        "site_id": 1,
        "active": 0,
        "first": "Trak",
        "last": "Collaborator",
        "email": "collaborator@example.com",
        "group_id": "5",
        "updated_at": "2019-02-15 18:40:54",
        "created_at": "2019-02-15 18:40:54",
        "user_id": 1
    }
}

PUT /users/{user_id}

Query Parameters

Parameter Type Required Description
email String true Email Address of the user.
first String true First name of the user.
group_id Integer true The group the user is assigned.
last String true Last name of the user.

{primary} You can only update your user account or users that have not been activated.

Example Requests

{
    'first': 'Updated',
    'last': 'Collaborator',
    'email': 'collaborator#company.com',
    'group_id': 5
}

Example Response

{
    "success": true,
    "message": "API_USER_UPDATED",
    "data": {
        "site_id": 1,
        "active": 0,
        "first": "Updated",
        "last": "Collaborator",
        "email": "collaborator@example.com",
        "group_id": "5",
        "updated_at": "2019-02-15 19:40:54",
        "created_at": "2019-02-15 18:40:54",
        "user_id": 1
    }
}

DELETE /users/{user_id}

Example Response

{
    "success": true,
    "message": "API_USER_DELETED",
    "data": []
}