Stashes API

Reference documentation

The /stashes API endpoints

The /stashes API endpoint provides HTTP GET and HTTP POST access to Sensu stash data via the Sensu key/value store.

/stashes (GET)

EXAMPLES

The following example demonstrates a /stashes query, which results in a JSON Array of JSON Hashes containing stash data.

$ curl -s http://localhost:4567/stashes | jq .
[
  {
    "path": "silence/i-424242/chef_client_process",
    "content": {
      "timestamp": 1383441836
    },
    "expire": 3600
  },
  {
    "path": "application/storefront",
    "content": {
      "timestamp": 1381350802,
      "endpoints": [
        "https://hostname/store"
      ]
    },
    "expire": -1
  }
]

API specification

/stashes (GET)
description Returns a list of stashes.
example url http://hostname:4567/stashes
pagination see pagination
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "path": "silence/i-424242/chef_client_process",
    "content": {
      "timestamp": 1383441836
    },
    "expire": 3600
  },
  {
    "path": "application/storefront",
    "content": {
      "timestamp": 1381350802,
      "endpoints": [
        "https://hostname/store"
      ]
    },
    "expire": -1
  }
]

/stashes (POST)

EXAMPLES

The following example demonstrates submitting an HTTP POST containing a JSON document payload to the /stashes API, resulting in a 201 (Created) HTTP response code and a payload containing a JSON Hash confirming the stash path (i.e. the “key” where the stash can be accessed).

curl -s -i -X POST \
-H 'Content-Type: application/json' \
-d '{"path": "example/stash/path", "content": { "foo": "bar" }}' \
http://localhost:4567/stashes

HTTP/1.1 201 Created
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Content-Length: 29
Connection: keep-alive
Server: thin

{"path":"example/stash/path"}

API specification

/stashes (POST)
description Create a stash. (JSON document)
example URL http://hostname:4567/stashes
payload
{
  "path": "example/stash",
  "content": {
    "message": "example"
  },
  "expire": -1
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

The /stashes/:path API endpoints

The /stashes/:path API endpoint provides HTTP GET, HTTP POST, and HTTP DELETE access to Sensu stash data for specified :paths (i.e. “keys”) via the Sensu key/value store.

/stashes/:path (GET)

EXAMPLES

The following example demonstrates a /stashes/:path API query for a stash located at the my/example/path :path, resulting in a JSON Hash of stash content data.

$ curl -s http://localhost:4567/stashes/my/example/stash | jq .
{
  "message": "hello world"
}

NOTE: the /stashes/:path API endpoint provides direct access to stash content data, so only stash content attributes are provided for /stashes/:path API queries (not complete stash definitions).

API specification

/stashes/:path (GET)
description Get a stash. (JSON document)
example URL http://hostname:4567/stashes/example/stash
response type Hash
response codes
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "message": "hello world"
}
_NOTE: the /stashes/:path API endpoint provides direct access to stash content data, so only stash content attributes are provided for /stashes/:path API queries (not complete stash definitions)._

/stashes/:path (POST)

EXAMPLES

The following example demonstrates submitting an HTTP POST to the /stashes/:path API with a :path called my/example/path, resulting in a 201 (Created) HTTP response code (i.e. HTTP/1.1 201 Created), and a payload containing a JSON Hash confirming the stash path (i.e. the “key” where the stash can be accessed).

$ curl -s -i -X POST \
-H 'Content-Type: application/json' \
-d '{"message": "hello world"}' \
http://localhost:4567/stashes/my/example/path

HTTP/1.1 201 Created
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Content-Length: 26
Connection: keep-alive
Server: thin

{"path":"my/example/path"}

API specification

/stashes/:path (POST)
description Create a stash. (JSON document)
example URL http://hostname:4567/stashes/example/stash
payload
{
  "message": "example"
}
_NOTE: the /stashes/:path API endpoint provides direct access to stash content data; as a result, it expects stash content attributes only (i.e. not a complete stash definition)._
response type Hash
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)
output
HTTP/1.1 201 Created
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Content-Length: 26
Connection: keep-alive
Server: thin

{"path":"my/example/path"}

/stashes/:path (DELETE)

EXAMPLES

The following example demonstrates submitting an HTTP DELETE to the /stashes/:path API with a :path called my/example/path, resulting in a 204 (No Response) HTTP response code (i.e. HTTP/1.1 204 No Response).

$ curl -s -i -X DELETE http://localhost:4567/stashes/my/example/path                                                                                                                                                                                        
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Connection: close
Server: thin

API specification

/stashes/:path (DELETE)
description Delete a stash. (JSON document)
example URL http://hostname:4567/stashes/example/stash
response type HTTP-header only (no output)
response codes
  • Success: 204 (No Response)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Connection: close
Server: thin