Namespaces API

The /namespaces API endpoint

/namespaces (GET)

The /namespaces API endpoint provides HTTP GET access to namespace data.

EXAMPLE

The following example demonstrates a request to the /namespaces API endpoint, resulting in a JSON array that contains namespace definitions.

curl -X GET \
http://127.0.0.1:8080/api/core/v2/namespaces \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN"

HTTP/1.1 200 OK
[
  {
    "name": "default"
  },
  {
    "name": "development"
  }
]

API Specification

/namespaces (GET)
description Returns the list of namespaces.
example url http://hostname:8080/api/core/v2/namespaces
pagination This endpoint supports pagination using the limit query parameter.
response filtering This endpoint supports API response filtering.
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "name": "default"
  },
  {
    "name": "development"
  }
]

/namespaces (POST)

The /namespaces API endpoint provides HTTP POST access to create Sensu namespaces.

EXAMPLE

In the following example, an HTTP POST request is submitted to the /namespaces API endpoint to create the namespace development. The request returns a successful HTTP 201 Created response.

curl -X POST \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
  "name": "development"
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/namespaces

HTTP/1.1 201 Created

API Specification

/namespaces (POST)
description Creates a Sensu namespace.
example URL http://hostname:8080/api/core/v2/namespaces
payload
{
  "name": "development"
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

The /namespaces/:namespace API endpoint

/namespaces/:namespace (PUT)

The /namespaces/:namespace API endpoint provides HTTP PUT access to create or update specific Sensu namespaces, by namespace name.

EXAMPLE

In the following example, an HTTP PUT request is submitted to the /namespaces/:namespace API endpoint to create the namespace development. The request returns a successful HTTP 201 Created response.

curl -X PUT \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
  "name": "development"
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/namespaces/development

HTTP/1.1 201 Created

API Specification

/namespaces/:namespace (PUT)
description Creates or updates a Sensu namespace.
example URL http://hostname:8080/api/core/v2/namespaces/development
payload
{
  "name": "development"
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

/namespaces/:namespace (DELETE)

The /namespaces/:namespace API endpoint provides HTTP DELETE access to delete a namespace from Sensu (specified by the namespace name).

EXAMPLE

The following example shows a request to the /namespaces/:namespace API endpoint to delete the namespace development, resulting in a successful HTTP 204 No Content response.

curl -X DELETE \
http://127.0.0.1:8080/api/core/v2/namespaces/development \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN"

HTTP/1.1 204 No Content

API Specification

/namespaces/:namespace (DELETE)
description Removes the specified namespace from Sensu.
example url http://hostname:8080/api/core/v2/namespaces/development
response codes
  • Success: 204 (No Content)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)

The /user-namespaces API endpoint

/user-namespaces (GET)

The /user-namespaces API endpoint provides HTTP GET access to the namespaces the user has access to.

EXAMPLE

The following example demonstrates a request to the /user-namespaces API endpoint, resulting in a JSON array that contains the namespaces the user has access to.

curl -X GET \
http://127.0.0.1:8080/api/enterprise/user-namespaces \
-H "Authorization: Bearer $SENSU_ACCESS_TOKEN"

HTTP/1.1 200 OK
[
  {
    "name": "default"
  },
  {
    "name": "development"
  }
]

API Specification

/user-namespaces (GET)
description Returns the list of namespaces a user has access to.
example url http://hostname:8080/api/enterprise/user-namespaces
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "name": "default"
  },
  {
    "name": "development"
  }
]