Make your first request

Authenticate, list servers, and read the response

These examples use curl, but the requests are the same regardless of the client. To browse the full list of endpoints, use the API console at /api-docs/v3/cmp/.

Get a token

Exchange your Cloud Management Platform (CMP) credentials for a token:

curl -X POST -H "Content-Type: application/json" \
  -d '{"username":"<username>","password":"<password>"}' \
  "https://<cmp-ip-or-hostname>/api/v3/cmp/apiToken/"

The response returns two tokens. token is the short-lived access token used in the requests below; refreshToken is the longer-lived one you exchange for a new access token when it expires. Keep the access token and your CMP address in shell variables:

TOKEN="<access-token>"
CMP="https://<cmp-ip-or-hostname>"

API authentication covers logging in against a directory domain, refreshing an expired token, and personal access tokens.

List servers

curl -H "Accept: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  "$CMP/api/v3/cmp/servers/"

Collections come back paginated. total counts every matching object and count counts those on this page. The objects sit under _embedded, keyed by the collection in the request path, such as servers.

{
  "_links": {
    "self": {
      "href": "/api/v3/cmp/servers/?page=1",
      "title": "List of Servers - Page 1 of 5"
    }
  },
  "total": 42,
  "count": 10,
  "_embedded": {
    "servers": [ ... ]
  }
}

Filter the results

Add a filter to return only the servers you want:

curl -H "Authorization: Bearer $TOKEN" \
  "$CMP/api/v3/cmp/servers/?filter=hostname:linprodsvr0213"

API conventions covers the query string parameters, how paging works, and errors.

Using Postman

  1. Obtain a token as above, and store it as a Postman variable.
  2. Create a request and set its method, for example, GET.
  3. Set the URL to the endpoint, for example https://cmp.example.com/api/v3/cmp/servers/.
  4. On the Authorization tab, choose Bearer Token and supply the token.
  5. Select Send.