CredHub has two API endpoints for identifying and reusing variables. To see all the credentials associated with your product, or to troubleshoot problems specific to one virtual machine (VM), you can use these API endpoints.

The API endpoints perform these functions:

  • Identifying and printing the name of a variable
  • Using the name of the variable to identify and print the value of the variable

Using the API endpoints

You can use the API endpoints to view variables for any product in Tanzu Operations Manager except the BOSH Director. These endpoints are read-only. You cannot use them to add, remove, or rotate variables.

Fetching Variables

This endpoint returns the list of variables associated with a product that is stored in CredHub. If you call a variable that is not stored in CredHub, the call returns an empty value.

You can use the variable name in the next endpoint call to return the variable value.

Example query:

$ curl "https://OPS-MAN-FQDN/api/variables"
    -X GET \
    -H "Authorization: Bearer EXAMPLE_UAA_ACCESS_TOKEN"

Example response:

HTTP/1.1 200 OK

{
  "variables": ["FIRST-EXAMPLE-VARIABLE", "SECOND-EXAMPLE-VARIABLE", "THIRD-EXAMPLE-VARIABLE"]
}

**Query parameters:**
Parameter Description
product_guid The unique product identifier, formatted as a text string

Fetching variable values

This endpoint returns the value of a variable stored in CredHub. If you call a variable that is not in CredHub, the call returns an empty value.

Example query:

$ curl "https://OPS-MAN-FQDN/api/variables" name=EXAMPLE-VARIABLE-NAME" \
    -X GET \
    -H "Authorization: Bearer UAA_ACCESS_TOKEN"

Example Response:

HTTP/1.1 200 OK

{
  "credhub-password": "EXAMPLE-PASSWORD"
}

**Query parameters:**
Parameter Description
variable_name The name of the variable, formatted as a text string
product_guid The unique product identifier, formatted as a text string
check-circle-line exclamation-circle-line close-line
Scroll to top icon