APIKeys API

Get all API keys

The /apikeys GET endpoint retrieves all API keys.

Example

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

curl -X GET \
http://127.0.0.1:8080/api/core/v2/apikeys \
-H "Authorization: Bearer $SENSU_ACCESS_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
  }
]

Create a new API key

The /apikeys API endpoint provides HTTP POST access to create a new API key.

Example

In the following example, an HTTP POST request is submitted to the /apikeys API endpoint to create a new API key. The request includes the API key definition in the request body and returns a successful HTTP 201 Created response.

curl -X POST \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
  "username": "admin"
}' \
http://127.0.0.1:8080/api/core/v2/apikeys

HTTP/1.1 201 Created

API Specification

/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
request payload
{
  "username": "admin"
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

Get a specific API key

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 -X GET \
http://127.0.0.1:8080/api/core/v2/apikeys/83abef1e-e7d7-4beb-91fc-79ad90084d5b \
-H "Authorization: Bearer $SENSU_ACCESS_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
}

Delete an API key

The /apikeys/:apikey API endpoint provides HTTP DELETE access to remove an API key.

Example

The following example shows a request to the /apikeys/:apikey API endpoint to delete the API key 83abef1e-e7d7-4beb-91fc-79ad90084d5b, resulting in a successful HTTP 204 No Content response.

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

HTTP/1.1 204 No Content

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: 204 (No Content)
  • Error: 500 (Internal Server Error)