User

Summary

Resource

Operation

Description

User

POST /api/users

Creates a new user. Requires the admin role.

GET /api/users/(int:user_id)

Gets a single user given its ID.

GET /api/users

Gets a list of all the users.

PUT /api/users/(int:user_id)

Updates an existing user. Requires the admin role.

DELETE /api/users/(int:user_id)

Deletes a user. Requires the admin role.

Create

JSON Schema

Required parameters are in bold.

type

object

properties

  • email

type

string

maxLength

255

minLength

1

  • first_name

type

string

maxLength

50

minLength

1

  • last_name

type

string

maxLength

50

minLength

1

  • password

type

string

minLength

1

  • roles

type

array

items

type

string

maxLength

80

minLength

1

minItems

1

  • username

type

string

maxLength

255

minLength

1

additionalProperties

False


POST /api/users

Creates a new user. Requires the admin role.

Example request:

POST /users HTTP/1.1
Host: 127.0.0.1
Content-Type: application/json

{
  "email": "johndoe@company.com",
  "first_name": "John",
  "last_name": "Doe",
  "password": "asdfasdfasdf",
  "roles": ["analyst"],
  "username": "johndoe"
}

Example response:

HTTP/1.1 201 Created
Content-Type: application/json

{
  "active": true,
  "apikey": "11111111-1111-1111-1111-111111111111",
  "email": "johndoe@company.com",
  "first_name": "John",
  "id": 2,
  "last_name": "Doe",
  "roles": ["analyst"],
  "username": "johndoe"
}
Request Headers
Response Headers
Status Codes

Read Single

GET /api/users/(int: user_id)

Gets a single user given its ID.

Example request:

GET /users/2 HTTP/1.1
Host: 127.0.0.1
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "active": true,
  "email": "johndoe@company.com",
  "first_name": "John",
  "id": 2,
  "last_name": "Doe",
  "roles": ["analyst"],
  "username": "johndoe"
}
Request Headers
Response Headers
Status Codes

Read Multiple

GET /api/users

Gets a list of all the users.

Example request:

GET /users HTTP/1.1
Host: 127.0.0.1
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

[
  {
    "active": true,
    "email": "admin@localhost",
    "first_name": "Admin",
    "id": 1,
    "last_name": "Admin",
    "roles": ["admin", "analyst"],
    "username": "admin"
  },
  {
    "active": true,
    "email": "johndoe@company.com",
    "first_name": "John",
    "id": 2,
    "last_name": "Doe",
    "roles": ["analyst"],
    "username": "johndoe"
  }
]
Request Headers
Response Headers
Status Codes

Update

JSON Schema

Required parameters are in bold.

type

object

properties

  • active

type

boolean

  • email

type

string

maxLength

255

minLength

1

  • first_name

type

string

maxLength

50

minLength

1

  • last_name

type

string

maxLength

50

minLength

1

  • password

type

string

minLength

1

  • roles

type

array

items

type

string

maxLength

80

minLength

1

minItems

1

  • username

type

string

maxLength

255

minLength

1

additionalProperties

False


PUT /api/users/(int: user_id)

Updates an existing user. Requires the admin role.

Example request:

PUT /users/2 HTTP/1.1
Host: 127.0.0.1
Content-Type: application/json

{
  "active": false
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "active": false,
  "email": "johndoe@company.com",
  "first_name": "John",
  "id": 2,
  "last_name": "Doe",
  "roles": ["analyst"],
  "username": "johndoe"
}
Request Headers
Response Headers
Status Codes

Delete

DELETE /api/users/(int: user_id)

Deletes a user. Requires the admin role.

Example request:

DELETE /users/2 HTTP/1.1
Host: 127.0.0.1

Example response:

HTTP/1.1 204 No Content
Request Headers
Status Codes