Skip to content

The Orchestrator REST API

The Orchestrator Client is a web page that calls a REST API, and that API is open to you too. Everything the client does, from listing workflows to importing a package, is a call under /vco/api that a script, a pipeline, or another product can make. Recipes 6.4 and 6.5 already used it to move packages. This recipe steps back and shows how to find your way around it: where its reference lives, how to log in to each kind of Orchestrator, and how to read the objects you’ll want to act on in recipe 7.2.

Getting ready

  • vco01.vmw.lab with vSphere authentication (recipe 1.4).
  • A vSphere SSO user for scripts, svc-vcfguide@vsphere.local, made a member of OrchestratorAdmins. A named account for scripts keeps their runs apart from yours in the logs. With vSphere authentication the only Orchestrator role is administrator (recipe 1.3); recipe 7.2, There’s more, covers accounts with less.
  • The workflow List VMs by name in VCF Orchestrator Guide/Chapter 3, with one input namePattern (string) and one output vmNames (Array/string), from recipe 3.2. Run it once in the client, so it has a run to find.
  • A Linux or macOS shell with curl and jq, and the lab’s CA certificate saved as vmw-lab-ca.pem.
  • For part C, an account in the Provider Consumption organization of VCF Automation that can open its Orchestrate tab (recipe 1.1).

How to do it

A. Open the reference

  1. Browse to https://vco01.vmw.lab/vco/api/docs. The API’s reference opens as a Swagger UI page, grouped into services such as Workflow Service, Workflow Run Service, Packages Service, and Policy Service. The same reference is on Broadcom’s developer portal, at VCF Operations Orchestrator API (latest), when you’re away from the server.
  2. Click Authorize, enter svc-vcfguide@vsphere.local and its password under basic authentication, and close the dialog.
  3. Expand Workflow Service, open GET /workflows, and click Try it out, then Execute. Below the button, the page shows the curl command it sent, the response code 200, and a JSON list of workflows.
Figure 7.1. The REST API reference, served by the Orchestrator itself.
Needs a lab check. Confirm the reference’s address on 9.1.1. A community thread reaches it at /vco/api/docs/swagger-ui/index.html on VCF Automation; check whether /vco/api/docs redirects there on a standalone appliance, and which authentication methods the Authorize dialog offers.

B. Call it from a script

  1. Save this file as vro-env.sh. It asks once for a user name and password, and defines a small vro function that adds the address, the CA certificate, the credentials, and the JSON header to every call:
vro-env.sh
# Source this file: . vro-env.sh
# Sets up the vro function for one Orchestrator.
VRO="${VRO:-https://vco01.vmw.lab/vco/api}"
CACERT="${CACERT:-vmw-lab-ca.pem}"
if [ -z "${VRO_TOKEN:-}" ]; then
read -r -p "User for $VRO: " VRO_USER
read -r -s -p "Password: " VRO_PASS; echo
fi
# Usage: vro METHOD PATH [extra curl options]
vro() {
local method="$1" path="$2"; shift 2
local auth
if [ -n "${VRO_TOKEN:-}" ]; then
auth=(-H "Authorization: Bearer $VRO_TOKEN")
else
auth=(-u "$VRO_USER:$VRO_PASS")
fi
curl --fail-with-body --silent --show-error --cacert "$CACERT" \
"${auth[@]}" -H "Accept: application/json" \
-X "$method" "$@" "$VRO$path"
}
  1. Load it and check who you are:
. vro-env.sh
vro GET /about | jq .
vro GET /users | jq .

/about answers anyone. It gives the version and build of the server, as in recipe 1.1. /users needs a login, and describes the user you logged in as, so it’s a quick test of your credentials. A wrong password gives 401.

On 9.1.1, /users answers with the login name, the display name, the domain, the groups and the role:

GET /vco/api/users on 9.1.1
{
"admin-rights": true,
"role": "ADMINISTRATOR",
"member-groups": [],
"display-name": "svc-vcfguide",
"login-name": "svc-vcfguide",
"domain": ""
}
Needs a lab check. Check on 9.1.1 that –fail-with-body prints the JSON error of a 401.
  1. Find the workflow by name. List calls take a conditions query parameter, and the answer is a list of links, each carrying the object’s attributes as name and value pairs:
vro GET '/workflows?conditions=name=List%20VMs%20by%20name' \
| jq -r '.link[] | [(.attributes[] | select(.name == "id") | .value),
(.attributes[] | select(.name == "categoryName") | .value)] | @tsv'

The output is one line: the workflow’s ID and its folder, Chapter 3. Copy the ID into a variable:

WF_ID='paste-the-id-here'
Figure 7.2. Finding a workflow by name from the shell.

On 9.1.1, conditions=name=List VMs by name matches the exact name, conditions=name~List VMs matches part of it, and each link’s attributes include id, name and categoryName. Add keys=id&keys=name&keys=categoryName to get only those three attributes.

  1. Read the workflow’s inputs and outputs. These are what a script must send when it starts the workflow (recipe 7.2):
vro GET "/workflows/$WF_ID" \
| jq '{name, version, inputs: ."input-parameters", outputs: ."output-parameters"}'
GET /workflows/{id} (shortened)
{
"name": "List VMs by name",
"version": "…",
"inputs": [ { "name": "namePattern", "type": "string" } ],
"outputs": [ { "name": "vmNames", "type": "Array/string" } ]
}
  1. List the workflow’s runs with their state, newest first:
vro GET "/workflows/$WF_ID/executions" \
| jq -r '[.relations.link[] | select(.rel == "down") | .attributes | from_entries]
| sort_by(.startDate) | reverse | .[:5][]
| [.id, .state, .startDate] | @tsv'

The run you started in the client is there, completed, with its ID and start time.

On 9.1.1 the runs are under relations.link, as links with rel = down, next to two links that aren’t runs (up and add). Each run has the attributes id, name, state, startDate, endDate, startedBy and currentItemDisplayName, and relations.total counts them. The list comes oldest first, and sortOrder didn’t change that in the lab, so the filter sorts by startDate itself. maxResult is honoured, but it keeps the oldest runs, so don’t use it to get the latest ones.

C. The Orchestrator embedded in VCF Automation

The embedded Orchestrator doesn’t take a user name and password on its API. It takes a bearer token issued by VCF Automation for your organization. You get one in two steps: create a long-lived API token once, then exchange it for a short-lived access token whenever a script runs.

  1. Log in to the Provider Consumption organization portal at https://auto.vmw.lab, open the user menu at the top right, and choose My Account. On API Tokens, click New, give the token a name such as vcfguide-scripts, and create it. Copy the token: it’s shown only once.
Figure 7.3. An API token for scripts, created in the organization portal.
  1. Exchange it for an access token. Replace <org> with the organization’s name as it appears in the portal’s address:
API_TOKEN='paste-the-api-token-here'
export VRO_TOKEN="$(curl --fail --silent --show-error --cacert vmw-lab-ca.pem \
-H 'Accept: application/json' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode "refresh_token=$API_TOKEN" \
'https://auto.vmw.lab/oauth/tenant/<org>/token' | jq -r .access_token)"
  1. Point the helper at the embedded Orchestrator and repeat steps 5 to 8. Because VRO_TOKEN is set, vro-env.sh doesn’t ask for a password, and sends the token instead:
export VRO='https://auto.vmw.lab/vco/api'
. vro-env.sh
vro GET /users | jq .
Needs a lab check. Walk part C on VCF Automation 9.1 with the Provider Consumption organization and record: where a user of that organization creates an API token (the menu names in step 9 come from the provider portal’s documented procedure); the organization name to use in /oauth/tenant/<org>/token; whether the access token from that call is accepted by /vco/api on auto.vmw.lab as a bearer token; and how long it lasts. Community write-ups give one hour for the access token and 90 days by default for the API token.

How it works

One API, two front doors. Every Orchestrator, standalone or embedded, serves the same API under /vco/api, and the client you click in uses it too. What differs is how you prove who you are, and that follows the authentication provider the server uses (recipe 1.3):

Orchestrator Authentication provider What the API accepts
Standalone, vco01.vmw.lab vSphere (recipe 1.4) Basic authentication with an SSO user
Standalone VCF Automation (recipe 1.5) A bearer token from VCF Automation
Embedded, auto.vmw.lab VCF Automation, always A bearer token from VCF Automation

On a standalone appliance with vSphere authentication, Basic authentication always works. Broadcom KB 440608 notes that the system property com.vmware.o11n.sso.basic-authentication.enabled only applies to Orchestrators integrated with VCF Automation, and that there’s no supported way to turn Basic authentication off on a vSphere-authenticated appliance. Protect the service account’s password like any other administrator password, and use HTTPS with a proper CA certificate, as vro-env.sh does with --cacert.

Needs a lab check. Recipe 1.6 sets up VCF SSO authentication on a standalone appliance. Check which credentials the 9.1.1 API accepts in that mode: Basic authentication, a VCF SSO bearer token, or both.

The API is the client’s permissions, not more. A call runs as the user it authenticates. It can see, run, and change only what that user can in the client, by the same roles and the same folder permissions. A script never needs a special API account, only a suitable ordinary one.

Resources and links. The API is organized around resources: /workflows/{id} is a workflow, /workflows/{id}/executions/{executionId} is one of its runs, /packages/{name} a package. List calls return links to those resources rather than the resources themselves, each with a few attributes such as the ID and name, so that a long list stays small. Follow a link’s href, or build the path from its ID, to get the full object. conditions filters a list on the server, which is faster and safer than downloading every workflow and filtering in jq.

JSON or XML. The API can answer in XML or JSON. Ask for JSON with Accept: application/json on every call, as the helper does, rather than relying on a default.

Tokens expire, API tokens don’t, for a while. The bearer token for the embedded Orchestrator is short-lived on purpose. A script asks for a new one each time it runs, and keeps only the API token, which lasts until its expiry date or until you revoke it. Treat the API token as a password: keep it in your pipeline’s secret store, never in a script or a Git repository.

Back in vRO 5.5–7Call /vco/api with the user name and password of a vRO user, whatever the server's authentication mode.
In Orchestrator 9.xA standalone appliance with vSphere authentication still accepts a user name and password. The Orchestrator embedded in VCF Automation needs a bearer token, exchanged from an API token created in the organization portal.

There's more

Copy what the client does. The quickest way to learn a call is to watch the client make it. Open your browser’s developer tools on the Network tab, do the thing in the Orchestrator Client, and look at the request it sent: the path, the method, and the JSON body. That’s how you’ll find the format of an input in recipe 7.2 when the reference only says object.

The Orchestrator gateway in VCF Automation. VCF Automation 9.1 also has an Automation Orchestrator Gateway API, with paths such as /vro/workflows and /vro/runs, that reaches the Orchestrator integrations of an organization through VCF Automation. It uses query options such as $filter and $top rather than conditions. Use it when a VCF Automation project, rather than one Orchestrator, is the thing you’re scripting against. Its reference is linked from API Documentation in the VCF Automation user menu.

Needs a lab check. Check on VCF Automation 9.1 where the gateway API’s reference is (a community answer points to /vco/api-docs/modern-tenancy), which organization types offer it, and whether POST /vro/runs can run a workflow on the embedded Orchestrator with the same access token as part C.

Don’t reach for -k. Many examples on the internet call Orchestrator with curl -k, which skips certificate checks. That also skips the only thing that tells your script it’s talking to the real server before it sends a password. Keep the CA certificate next to your scripts and pass it with --cacert.

The reference on the developer portal. Broadcom publishes the same API reference at developer.broadcom.com/xapis/vcf-operations-orchestrator-api/latest. It’s the one to bookmark: latest always opens the newest release (9.1.2 as this is written), and a version picker on the page opens 9.1 or 9.0 when your server is older. Every service from the Swagger UI in step 1 has its own page there, and each call has an example body and response. The links in this book’s See also lists point to it.

Read the change log before an upgrade. The API reference on the Broadcom developer portal has an API ChangeLog page per release. Check it before you upgrade an Orchestrator that scripts and pipelines depend on.

PowerShell. On Windows, Invoke-RestMethod does everything curl and jq do here, and returns objects you can filter with Where-Object. Recipe 7.2 shows it.

See also