===== Users ===== .. include:: ../../complete.rst The Users endpoints provide a way to view user details, as well, as update, deactivate and control user access to applications. Get a List of Users ------------------- .. http:get:: /api/v1/jb/users/ Get a list of Users **Example Request**: .. code:: GET /api/v1/jb/users/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [ { "extra": { }, "last_login": "2016-06-01T13:34:30.718746Z", "email": "user@juice.com", "handle": "@user", "first_name": "User", "last_name": "User", "is_active": true, "date_joined": "2013-07-28T21:04:32Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/o.png", "last_activated": "2016-06-01T13:22:24.439209Z", "last_deactivated": null, "apps": [ "zylTKNVx" ], "clientadmin_of": [] } ] :>json int extra: extra data associated with the user for use in your apps :>json string email: the user's email address :>json string handle: the user's discussion handle :>json string first_name: the user's first name :>json string last_name: the user's last name :>json boolean is_active: the active status of the user :>json boolean is_demo_user: the demo status of the user :>json string profile_color: hex color code of the user's profile :>json string profile_avatar: the user's selected avatar :>json array apps: A list of app ids to which the user has access :>json array clientadmin_of: A list of client ids to which the user is an admin :>json date last_login: the last date the user logged into the system :>json date date_joined: the date the user was created :>json date last_activated: the date the user was last activated :>json date last_deactivated: the date the user was last deactivated :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 200: OK :statuscode 403: Authentication Failed Get a List of Users for an app ------------------------------ .. http:get:: /api/v1/jb/users/?app={slug} Get a list of Users for an app **Example Request**: .. code:: GET /api/v1/jb/users/?app=jb3demo Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [ { "extra": { }, "last_login": "2016-06-01T13:34:30.718746Z", "email": "user@juice.com", "handle": "@user", "first_name": "User", "last_name": "User", "is_active": true, "date_joined": "2013-07-28T21:04:32Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/o.png", "last_activated": "2016-06-01T13:22:24.439209Z", "last_deactivated": null, "apps": [ "zylTKNVx" ], "clientadmin_of": [] } ] :>json int extra: extra data associated with the user for use in your apps :>json string email: the user's email address :>json string handle: the user's discussion handle :>json string first_name: the user's first name :>json string last_name: the user's last name :>json boolean is_active: the active status of the user :>json boolean is_demo_user: the demo status of the user :>json string profile_color: hex color code of the user's profile :>json string profile_avatar: the user's selected avatar :>json array apps: A list of app ids to which the user has access :>json array clientadmin_of: A list of client ids to which the user is an admin :>json date last_login: the last date the user logged into the system :>json date date_joined: the date the user was created :>json date last_activated: the date the user was last activated :>json date last_deactivated: the date the user was last deactivated :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 200: OK :statuscode 403: Authentication Failed :statuscode 404: App not found Get a User's Details -------------------- .. http:get:: /api/v1/jb/users/(string:email)/ Get a User's Details **Example Request**: .. code:: GET /api/v1/jb/users/user@juice.com/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "extra": { }, "last_login": "2016-06-01T13:34:30.718746Z", "email": "user@juice.com", "handle": "@user", "first_name": "User", "last_name": "User", "is_active": true, "date_joined": "2013-07-28T21:04:32Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/o.png", "last_activated": "2016-06-01T13:22:24.439209Z", "last_deactivated": null, "apps": [ "zylTKNVx" ], "clientadmin_of": [] } :param string email: The user's email address :>json int extra: extra data associated with the user for use in your apps :>json string email: the user's email address :>json string handle: the user's discussion handle :>json string first_name: the user's first name :>json string last_name: the user's last name :>json boolean is_active: the active status of the user :>json boolean is_demo_user: the demo status of the user :>json string profile_color: hex color code of the user's profile :>json string profile_avatar: the user's selected avatar :>json array apps: A list of app ids to which the user has access :>json array clientadmin_of: A list of client ids to which the user is an admin :>json date last_login: the last date the user logged into the system :>json date date_joined: the date the user was created :>json date last_activated: the date the user was last activated :>json date last_deactivated: the date the user was last deactivated :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 200: OK :statuscode 403: Authentication Failed :statuscode 404: User with the supplied email not found Updating a User's Details ------------------------- .. http:patch:: /api/v1/jb/users/(string:email)/ It's possible to update a user's first name, last name, active status, demo status, extra data, and assigned applications. Client admins cannot be updated via the API. **Example Request**: .. code:: PATCH /api/v1/jb/users/user@juice.com/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 { "apps": [ "zylTKNVx" ] } **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "extra": { }, "last_login": "2016-06-01T13:34:30.718746Z", "email": "user@juice.com", "handle": "@user", "first_name": "User", "last_name": "User", "is_active": true, "date_joined": "2013-07-28T21:04:32Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/o.png", "last_activated": "2016-06-01T13:22:24.439209Z", "last_deactivated": null, "apps": [ "zylTKNVx" ], "clientadmin_of": [] } :param string email: The user's email address :json object extra: extra data associated with the user for use in your apps :>json string email: the user's email address :>json string handle: the user's discussion handle :>json string first_name: the user's first name :>json string last_name: the user's last name :>json boolean is_active: the active status of the user :>json boolean is_demo_user: the demo status of the user :>json string profile_color: hex color code of the user's profile :>json string profile_avatar: the user's selected avatar :>json array apps: A list of app ids to which the user has access :>json array clientadmin_of: A list of client ids to which the user is an admin :>json date last_login: the last date the user logged into the system :>json date date_joined: the date the user was created :>json date last_activated: the date the user was last activated :>json date last_deactivated: the date the user was last deactivated :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 200: OK :statuscode 403: Authentication Failed :statuscode 404: User with the supplied email not found Creating a User --------------- .. http:post:: /api/v1/jb/users/ Create a user. **Example Request**: .. code:: POST /api/v1/jb/users/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 { "email": "new_user@juiceanalytics.com", "extra": {}, "first_name": "Jane", "last_name": "Doe", "is_demo_user": false, "apps": ["abcdefgh"] } **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "extra": { }, "last_login": "2016-06-01T13:34:30.718746Z", "email": "new_user@juiceanalytics.com", "handle": "@new_user", "first_name": "Jane", "last_name": "Doe", "is_active": true, "date_joined": "2013-07-28T21:04:32Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/o.png", "last_activated": "2016-06-01T13:22:24.439209Z", "last_deactivated": null, "apps": ["abcdefgh"], "clientadmin_of": [] } :json object extra: extra data associated with the user for use in your apps :>json string email: the user's email address :>json string handle: the user's discussion handle :>json string first_name: the user's first name :>json string last_name: the user's last name :>json boolean is_active: the active status of the user :>json boolean is_demo_user: the demo status of the user :>json string profile_color: hex color code of the user's profile :>json string profile_avatar: the user's selected avatar :>json array apps: A list of app ids to which the user has access :>json array clientadmin_of: A list of client ids to which the user is an admin :>json date last_login: the last date the user logged into the system :>json date date_joined: the date the user was created :>json date last_activated: the date the user was last activated :>json date last_deactivated: the date the user was last deactivated :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 201: Invite Created :statuscode 400: Bad data was provided, see response for details :statuscode 403: Authentication Failed :statuscode 404: Client with the supplied ID not found Deactivating a User ------------------- .. http:delete:: /api/v1/jb/users/(string:email)/ Deactivate a User by email **Example Request**: .. code:: DELETE /api/v1/jb/users/user@juice.com/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 **Example Response**: .. code:: HTTP/1.1 204 NO CONTENT Vary: Accept, Cookie :param string email: The user's email address Get a List of Users You've Invited ---------------------------------- .. http:get:: /api/v1/jb/users/invitations/ Get a list of pending invited users **Example Request**: .. code:: GET /api/v1/jb/users/invitations/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [ { "id": 3, "user": { "extra": {}, "last_login": null, "email": "jason@juice.com", "handle": "@jason", "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-06-01T18:13:17.943920Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png", "last_activated": "2016-06-01T18:13:17.943951Z", "last_deactivated": null, "apps": [] }, "initial_apps": [], "extra": {}, "email": "invited_user@juiceanalytics.com", "key": "0626d808767dc0abc76a4266ad2df687b3008156", "date_invited": "2016-06-01T18:24:04.358609Z", "invitation_email_count": 1 }, ] :>json int id: the id of the invite :>json object user: the user who performed the invite :>json int extra: extra data associated with the user for use in your apps :>json string email: the invited user's email address :>json string key: a unique key to identify the invited user :>json array initial_apps: A list of app ids to which the user has been invited :>json date date_invited: the date the user invited to join the system :>json int invitation_email_count: a counter to show how many times the user has been sent an invite :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 200: OK :statuscode 403: Authentication Failed Get a List of Users You've Invited for an app --------------------------------------------- .. http:get:: /api/v1/jb/users/invitations/?app={slug} Get a list of pending invited users for an app **Example Request**: .. code:: GET /api/v1/jb/users/invitations/?app=jb3demo Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [ { "id": 3, "user": { "extra": {}, "last_login": null, "email": "jason@juice.com", "handle": "@jason", "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-06-01T18:13:17.943920Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png", "last_activated": "2016-06-01T18:13:17.943951Z", "last_deactivated": null, "apps": [] }, "initial_apps": [], "extra": {}, "email": "invited_user@juiceanalytics.com", "key": "0626d808767dc0abc76a4266ad2df687b3008156", "date_invited": "2016-06-01T18:24:04.358609Z", "invitation_email_count": 1 }, ] :>json int id: the id of the invite :>json object user: the user who performed the invite :>json int extra: extra data associated with the user for use in your apps :>json string email: the invited user's email address :>json string key: a unique key to identify the invited user :>json array initial_apps: A list of app ids to which the user has been invited :>json date date_invited: the date the user invited to join the system :>json int invitation_email_count: a counter to show how many times the user has been sent an invite :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 200: OK :statuscode 403: Authentication Failed :statuscode 404: App not found Invite a User ------------- .. http:post:: /api/v1/jb/users/invitations/ Invite a User **Example Request**: .. code:: POST /api/v1/jb/users/invitations/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 { "email": "new_user@juiceanalytics.com", "client": 1, "extra": {}, "initial_apps": [ "zylTKNVx", ], "is_demo_user": "true" } **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "id": 4, "user": { "extra": {}, "last_login": null, "email": "jason@juice.com", "handle": "@jason", "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-06-01T18:13:17.943920Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png", "last_activated": "2016-06-01T18:13:17.943951Z", "last_deactivated": null, "apps": [] }, "initial_apps": ["zylTKNVx",], "extra": {}, "email": "new_user@juiceanalytics.com", "key": "0626d808767dc0abc76a4266ad2df687b3008156", "date_invited": "2016-06-01T18:24:04.358609Z", "invitation_email_count": 1, "is_demo_user": "true" }, :json object user: the user who performed the invite :>json object extra: extra data associated with the user for use in your apps :>json string email: the invited user's email address :>json string key: a unique key to identify the invited user :>json array initial_apps: A list of app details to which the user has been invited :>json date date_invited: the date the user invited to join the system :>json int invitation_email_count: a counter to show how many times the user has been sent an invite :>json string is_demo_user: Will the invitee be a demo_user :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 201: Invite Created :statuscode 403: Authentication Failed :statuscode 404: Client with the supplied ID not found Invite a list of Users ---------------------- .. http:post:: /api/v1/jb/users/invitations/ Invite a list of Users **Example Request**: .. code:: POST /api/v1/jb/users/invitations/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 [{ "email": "new_user@juiceanalytics.com", "client": 1, "extra": {}, "initial_apps": [ "zylTKNVx", ], "is_demo_user": "true" }, { "email": "new_user2@juiceanalytics.com", "client": 1, "extra": {}, "initial_apps": [ "hsYD763", ], "is_demo_user": "true" }, { "email": "new_user3@juiceanalytics.com", "client": 1, "extra": {}, "initial_apps": [ "sMfh63S", ], "is_demo_user": "true" }] **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript [{ "id": 4, "user": { "extra": {}, "last_login": null, "email": "jason@juice.com", "handle": "@jason", "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-06-01T18:13:17.943920Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png", "last_activated": "2016-06-01T18:13:17.943951Z", "last_deactivated": null, "apps": [] }, "initial_apps": ["zylTKNVx",], "extra": {}, "email": "new_user@juiceanalytics.com", "key": "0626d808767dc0abc76a4266ad2df687b3008156", "date_invited": "2016-06-01T18:24:04.358609Z", "invitation_email_count": 1, "is_demo_user": "true" }, { "id": 4, "user": { "extra": {}, "last_login": null, "email": "jason@juice.com", "handle": "@jason", "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-06-01T18:13:17.943920Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png", "last_activated": "2016-06-01T18:13:17.943951Z", "last_deactivated": null, "apps": [] }, "initial_apps": ["hsYD763",], "extra": {}, "email": "new_user2@juiceanalytics.com", "key": "0626fd8fds78f87dsa4266adfdsfsdfsd7b3008156", "date_invited": "2016-06-01T18:24:04.358609Z", "invitation_email_count": 1, "is_demo_user": "true" }, { "id": 4, "user": { "extra": {}, "last_login": null, "email": "jason@juice.com", "handle": "@jason", "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-06-01T18:13:17.943920Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png", "last_activated": "2016-06-01T18:13:17.943951Z", "last_deactivated": null, "apps": [] }, "initial_apps": ["sMfh63S",], "extra": {}, "email": "new_user3@juiceanalytics.com", "key": "0626d88sjdgwte63HDFS7266ad2df687b3008156", "date_invited": "2016-06-01T18:24:04.358609Z", "invitation_email_count": 1, "is_demo_user": "true" }] :json object user: the user who performed the invite :>json object extra: extra data associated with the user for use in your apps :>json string email: the invited user's email address :>json string key: a unique key to identify the invited user :>json array initial_apps: A list of app details to which the user has been invited :>json date date_invited: the date the user invited to join the system :>json int invitation_email_count: a counter to show how many times the user has been sent an invite :>json string is_demo_user: Will the invitee be a demo_user :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 201: Invite Created :statuscode 400: Email being invited already exists as an Invitation or User :statuscode 403: Authentication Failed :statuscode 404: Client with the supplied ID not found Change an invited user's initial apps ------------------------------------- .. http:patch:: /api/v1/jb/users/invitations/new_user@juiceanalytics.com/ Change an invited user's initial apps **Example Request**: .. code:: PATCH /api/v1/jb/users/invitations/new_user@juiceanalytics.com/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 { "initial_apps": [ "KNVxzylT" ] } **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "id": 4, "user": { "extra": {}, "last_login": null, "email": "jason@juice.com", "handle": "@jason", "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-06-01T18:13:17.943920Z", "is_demo_user": false, "profile_color": "ff0000", "profile_avatar": "https://fruition-snapshots.s3.amazonaws.com/avatars/profile-defaults/default.png", "last_activated": "2016-06-01T18:13:17.943951Z", "last_deactivated": null, "apps": [] }, "initial_apps": ["KNVxzylT"], "extra": {}, "email": "new_user@juiceanalytics.com", "key": "0626d808767dc0abc76a4266ad2df687b3008156", "date_invited": "2016-06-01T18:24:04.358609Z", "invitation_email_count": 1 }, :json object user: the user who performed the invite :>json object extra: extra data associated with the user for use in your apps :>json string email: the invited user's email address :>json string key: a unique key to identify the invited user :>json array initial_apps: A list of app details to which the user has been invited :>json date date_invited: the date the user invited to join the system :>json int invitation_email_count: a counter to show how many times the user has been sent an invite :reqheader Accept: the response content type depends on ``Accept`` header :reqheader Authorization: contains the token to be used for authentication :resheader Content-Type: this depends on ``Accept`` header of request :statuscode 200: Change successful :statuscode 403: Authentication Failed :statuscode 404: User with the supplied email not found View a users usage for an app ------------------------------------- .. http:get:: /api/v1/jb/users/{email}/usage/{app_id}/ View a users usage for an app **Example Request**: .. code:: GET /api/v1/jb/users/user@juiceanalytics.com/usage/9f01c600/ Accept: application/json Authorization: Token 7297b3ebb0e7f7baf5f54d39908dda99f5ea8665 {} **Example Response**: .. code:: HTTP/1.1 200 OK Vary: Accept Content-Type: text/javascript { "action_description": "Viewed Dashboard stack for TDOE ePlan", "email": "user@juiceanalytics.com", "full_name": "Christian Oliver", "timestamp": "2018-07-24T18:29:48.111374Z", "action": "STACK_ACCESS", "extra": { "app": "TDOE ePlan", "request": { "path": "/tdoe_eplan/dashboard", "session": "ylxgp8feaxc5vyor65ab5cs26zz8fsxx", "META": { "HTTP_USER_AGENT": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", "SERVER_NAME": "31ca45546fe6", "HTTP_REFERER": "http://localhost:8000/", "REMOTE_ADDR": "172.20.0.1", "CONTENT_TYPE": "text/plain", "REQUEST_METHOD": "GET", "HTTP_HOST": "localhost:8000", "SERVER_PORT": "8000", "QUERY_STRING": "", "HTTP_ACCEPT_ENCODING": "gzip, deflate, br" } }, "stack": "Dashboard", "app_id": "9f01c600" } }