Users


GET /users

Query Parameters

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

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": {
        "data": [
            {
                "user_id": 1,
                "group_id": 1,
                "group": {
                    "raw": "admin",
                    "formatted": "Trak Admin"
                },
                "first": "Trak",
                "last": "Admin",
                "fullname": "Trak Admin",
                "email": "[email protected]",
                "avatar": {
                    "file_id": 3,
                    "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"
                },
                "active": true,
                "editor": true,
                "created_at": "2018-12-03 20:33:01",
                "updated_at": "2019-02-14 22:34:56",
                "login_at": "2019-02-14 22:34:56"
            }
        ],
        ...
    }
}

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": {
        "active": false,
        "first": "Trak",
        "last": "Collaborator",
        "email": "[email protected]",
        "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": {
        "active": false,
        "first": "Updated",
        "last": "Collaborator",
        "email": "[email protected]",
        "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": []
}