Admin - Users API

Endpoints to create and delete a user when logged in as Administrator.

Interfaces

Object Synopses

UserRequest

  • uid String

    Uid must be included. Unique user id

  • first_name String

    User first name

  • last_name String

    User last name

  • full_name String

    User full name

  • sortable_name String

    User sortable name (last, first in European-American culture)

  • email String

    User email address

  • locale String

    The user’s language code

  • manager_id String

    Optional: ID of the user’s manager. Alternatively, the UID of the user’s manager, prefixed with uid:.

  • hire_date Date

    Date that user was hired, in ISO 8601 format (YYYY-MM-DD)

  • job_title string

    Job title of user

  • department string

    Department of user

  • hris_id string

    HRIS ID of user, must be unique

  • custom_fields Array

    Optional custom fields. These must be created before assigning them to users.

Add a user

POST /api/admin/users

Response Codes

  • 200 OK if the user was created
  • 400 Bad Request if the user already exists

Parameters

  • users UserRequest[] Required

    An array of UserRequest objects. Even though an array is passed in to this endpoint, it only adds one user a time. All extra entries in the array are ignored.

Example Request

{
  "users": [
    "{API::UserRequest}"
  ]
}
curl \
  -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{"users":["{API::UserRequest}"]}' \
  http://<bridge>/api/admin/users
    

Example Response

{
  "meta":   {},
  "linked": {},
  "users": [{
    "id": 3,
    "uid": "hsolo",
    "first_name": "Han",
    "last_name":  "Solo",
    "email": "h.solo@millennium-falcon.com",
    "locale": "en",
    "roles": [],
    "name": "Han Solo",
    "avatar_url": null,
    "deleted_at": null,
    "hire_date": "2016-01-31",
    "links": [],
    "meta": {
      "can_masquerade": true
    }
  }]
}

Delete a user

DELETE /api/admin/users/:id

This endpoint deletes the user by id. A user cannot delete himself/herself.

Response Codes

  • 204 No Content when deletion is complete
  • 404 Not Found if requested user id does not exist

Parameters

  • id Integer Required

    The id of the user to be deleted. Alternatively, the user’s uid, prefixed with “uid:”.

  • async Boolean

    If true, the user destroy is processed with an async worker

Return summary information for user

GET /api/admin/users/:id/summary

This endpoint returns counts for the following: Completed Courses Completed Programs Completed Live Trainings Total Completed On Time Total Overdue

Response Codes

  • ‘200’ If user is valid
  • ‘404 Not Found’ if requested user doesn’t exist

Parameters

  • id Integer Required

    The id of the user for which information is to be returned.

  • start_date Date

    Start of the time period to pull data from.

  • end_date Date

    End of the time period to pull data from.

Example Response

{
  "summary": {
    "completed_courses":17,
    "completed_programs":2,
    "completed_live_courses":2,
    "total_on_time":11,
    "total_overdue":8
  }
}

Hide a deleted user

POST /api/admin/users/:id/hide

This endpoint hides the deleted user by id. A user cannot hide himself/herself nor hide an active user.

Response Codes

  • 204 No Content when hiding is complete
  • 404 Not Found if requested user id does not exist

Parameters

  • id Integer Required

    The id of the user to be hidden. Alternatively, the user’s uid, prefixed with “uid:”.