Pivotal Knowledge Base


How to use Curl Calling BOSH API


Pivotal Cloud Foundry versions 1.7 and above


BOSH CLI commands can be used to perform system administration tasks. Besides that, you could also use API endpoints provided by the Director to do the same tasks. This article shows you how to use curl calling Bosh API.


The Director can be configured in two authentication modes: Basic Authentication and UAA. All of the supported versions of Pivotal Cloud Foundry use UAA so we could use "uaac curl" to calling BOSH API with authentication.

1. Set UAAC target to the BOSH Director

ubuntu@pivotal-ops-manager:~$ uaac target


Context: readonly, from client readonly

2. Fetch the access token

ubuntu@pivotal-ops-manager:~$ uaac token client get readonly
Client secret: ********

Successfully fetched token via client credentials grant.
Context: readonly, from client readonly

3. Now you can use the following command to query an endpoint

uaac curl -k https://<ops-manager-ip>:25555/<endpoint>

Here is an example, the query endpoint is /deployments/{name of deployment}/instances to list all the instances which is equivalent to "bosh instances" CLI command.

ubuntu@pivotal-ops-manager:~$ uaac curl -k|grep -A100 "RESPONSE BODY"|grep -v "RESPONSE BODY"|jq .
[ { "id": "8453b9f0-c2b4-4864-ae47-e61a14841579", "index": 0, "job": "diego_cell-partition-75437f0a091c320d8ca4", "cid": "vm-09b407fb-e478-4eda-81ac-9b37bf113c99", "agent_id": "376adc2c-d63d-4689-8f60-95edfbda6ed0" }, ... { "id": "7ac9a5ea-4f4d-4533-8581-cfb31ee32aca", "index": 0, "job": "mysql_monitor-partition-75437f0a091c320d8ca4", "cid": "vm-914b5e7a-a4b6-4e44-a5a4-906a693d7071", "agent_id": "c12c86ce-5e1c-41f8-8a06-310ea908e065" } ]

Additional Information

In step 2, for more information on the read-only client, please refer to How to add a Read-Only BOSH user.

In step 3, for more information on the whole API endpoints provided by the Director, please see Director API v1.



Powered by Zendesk