# Make your first request

> Authenticate, list servers, and read the response

---

Site [llms.txt](/llms.txt)

---

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:

```bash
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:

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

[API authentication](/docs/cmp/developer-resources/rest-api/authentication/) covers logging in against a directory domain, refreshing an expired token, and personal access tokens.

## List servers

```bash
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`.

```json
{
  "_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:

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

[API conventions](/docs/cmp/developer-resources/rest-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.
1. Create a request and set its method, for example, **GET**.
1. Set the URL to the endpoint, for example `https://cmp.example.com/api/v3/cmp/servers/`.
1. On the **Authorization** tab, choose **Bearer Token** and supply the token.
1. Select **Send**.

<div class="alert alert-warning" role="alert">


Do not choose **Basic Auth**. HTTP Basic authentication is disabled by default, so any request using it is rejected unless it has been re-enabled.
</div>


## Related

- [API authentication](/docs/cmp/developer-resources/rest-api/authentication/): obtaining, passing, and refreshing a token.
- [API conventions](/docs/cmp/developer-resources/rest-api/conventions/): URLs, parameters, pagination, limits, and errors.
