Users API

The /users API endpoint

/users (GET)

The /users API endpoint provides HTTP GET access to user data.

EXAMPLE

The following example demonstrates a request to the /users API, resulting in a JSON Array containing user definitions.

curl -s http://127.0.0.1:8080/api/core/v2/users -H "Authorization: Bearer TOKEN"
[
  {
    "username": "alice",
    "groups": [
      "ops"
    ],
    "password": "****",
    "disabled": false
  },
  {
    "username": "bob",
    "groups": [
      "dev"
    ],
    "password": "****",
    "disabled": false
  }
]

API Specification

/users (GET)
description Returns the list of users.
example url http://hostname:8080/api/core/v2/users
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "username": "alice",
    "groups": [
      "ops"
    ],
    "password": "****",
    "disabled": false
  },
  {
    "username": "bob",
    "groups": [
      "dev"
    ],
    "password": "****",
    "disabled": false
  }
]

/users (POST)

/users (POST)
description Create a Sensu user.
example URL http://hostname:8080/api/core/v2/users/default/users
payload
{
  "username": "alice",
  "groups": [
    "ops"
  ],
  "password": "****",
  "disabled": false
}
response codes
  • Success: 200 (OK)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

The /users/:user API endpoint

/users/:user (GET)

The /users/:user API endpoint provides HTTP GET access to user data for specific :user definitions, by user name.

EXAMPLE

In the following example, querying the /users/:user API returns a JSON Map containing the requested :user definition (in this example: for the :user named alice).

curl -s http://127.0.0.1:8080/api/core/v2/users/alice -H "Authorization: Bearer TOKEN"
{
  "username": "alice",
  "groups": [
    "ops"
  ],
  "password": "****",
  "disabled": false
}

API Specification

/users/:user (GET)
description Returns a user.
example url http://hostname:8080/api/core/v2/users/alice
response type Map
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "username": "alice",
  "groups": [
    "ops"
  ],
  "password": "****",
  "disabled": false
}

/users/:user (PUT)

API Specification

/users/:user (PUT)
description Create or update a Sensu user given the username.
example URL http://hostname:8080/api/core/v2/namespaces/default/users/alice
payload
{
  "username": "alice",
  "groups": [
    "ops"
  ],
  "password": "****",
  "disabled": false
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

/users/:user (DELETE)

API Specification

/users/:user (DELETE)
description Removes a user from Sensu given the username.
example url http://hostname:8080/api/core/v2/namespaces/default/users/alice
response codes
  • Success: 202 (Accepted)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)