APIKeys API

The /apikeys API endpoint

/apikeys (GET)

The /apikeys GET endpoint retrieves all API keys.

EXAMPLE

The following example demonstrates a request to the /apikeys API, resulting in a JSON array containing all API keys.

curl http://127.0.0.1:8080/api/core/v2/apikeys -H "Authorization: Bearer $SENSU_TOKEN"

HTTP/1.1 200 OK

[
  {
    "metadata": {
      "name": "83abef1e-e7d7-4beb-91fc-79ad90084d5b"
    },
    "username": "admin",
    "created_at": 1570640363
  }
]

API Specification

/apikeys (GET)
description Returns the list of API keys.
example url http://hostname:8080/api/core/v2/apikeys
pagination This endpoint supports pagination using the limit and continue query parameters. See the API overview for details.
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "metadata": {
      "name": "83abef1e-e7d7-4beb-91fc-79ad90084d5b"
    },
    "username": "admin",
    "created_at": 1570640363
  }
]

/apikeys (POST)

/apikeys (POST)
description Creates a new API key, a Sensu-generated UUID. The response will include HTTP 201 and a Location header that contains the relative path to the new API key.
example URL http://hostname:8080/api/core/v2/apikeys
response codes
  • Success: 200 (OK)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)
request payload
{
  "username": "admin"
}
response payload
Location: /api/core/v2/apikeys/83abef1e-e7d7-4beb-91fc-79ad90084d5b
{
  "metadata": {
    "name": "83abef1e-e7d7-4beb-91fc-79ad90084d5b"
  },
  "username": "admin",
  "created_at": 1570640363
}

The /apikeys/:apikey API endpoint

/apikeys/:apikey (GET)

The /apikeys/:apikey GET endpoint retrieves the specified API key.

EXAMPLE

In the following example, querying the /apikeys/:apikey API returns the requested :apikey definition or an error if the key is not found.

curl http://127.0.0.1:8080/api/core/v2/apikeys/83abef1e-e7d7-4beb-91fc-79ad90084d5b -H "Authorization: Bearer $SENSU_TOKEN"

HTTP/1.1 200 OK
{
  "metadata": {
    "name": "83abef1e-e7d7-4beb-91fc-79ad90084d5b"
  },
  "username": "admin",
  "created_at": 1570640363
}

API Specification

/apikeys/:apikey (GET)
description Returns the specified API key.
example url http://hostname:8080/api/core/v2/apikeys/83abef1e-e7d7-4beb-91fc-79ad90084d5b
response type Map
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "metadata": {
    "name": "83abef1e-e7d7-4beb-91fc-79ad90084d5b"
  },
  "username": "admin",
  "created_at": 1570640363
}

/apikeys/:apikey (DELETE)

API Specification

/apikeys/:apikey (DELETE)
description Revokes the specified API key.
example URL http://hostname:8080/api/core/v2/apikeys/83abef1e-e7d7-4beb-91fc-79ad90084d5b
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
curl -X DELETE -H "Authorization: Bearer $SENSU_TOKEN"  http://localhost:8080/api/core/v2/apikeys/83abef1e-e7d7-4beb-91fc-79ad90084d5b

curl -I -X DELETE -H "Authorization: Bearer $SENSU_TOKEN"  http://
demo.sensuplusgremlin.rocks:8080/api/core/v2/apikeys/83abef1e-e7d7-4beb-91fc-79ad90084d5b
4
HTTP/1.1 204 No Content
Content-Type: application/json
Date: Mon, 26 Aug 2019 18:51:28 GMT