Skip to main content

VMware Cloud Director API

VMware Cloud Director API allows you to interact with VMware Cloud Director via a REST client.

A description of all VMware Cloud Director API methods can be found in the VMware documentation.

Authorization

To authorize and start using the API:

  1. Request the API version.
  2. Get a token.

1. Request the API version

  1. Get a list of API versions:

    curl 'https://<url>/api/versions'

    Specify <url> — the address depending on the region:

    • Moscow: vcd-msk.selectel.ru;
    • Saint Petersburg: vcd.selectel.ru.

    For current API versions, the deprecated parameter value will be false, and for obsolete ones — true.

  2. Select any current API version. The request examples use version 36.3.

2. Get a token

  1. Using any tool to convert strings from text format to MIME Base64, convert the following string to MIME Base64 format:

    <username>@<tenant>:<password>

    Specify:

    • <username> — the virtual data center username. For more information, see the Manage virtual data center users instruction;
    • <tenant> — tenant, can be found in the Cloud Director login URL formatted as https://<url>/tenant/<tenant>;
    • <password> — password of the virtual data center user.
  2. Request a token:

    curl -i -XPOST \
    -H 'Accept: application/*;version=<version>' \
    -H 'Authorization: Basic <encoded_string>' \
    'https://<url>/cloudapi/1.0.0/sessions/'

    Specify:

    • <version> — API version;

    • <encoded_string> — the string obtained in step 1;

    • <url> — address depending on the region:

      • Moscow: vcd-msk.selectel.ru;
      • Saint Petersburg: vcd.selectel.ru.
  3. Save:

    • token from the X-VMWARE-VCLOUD-ACCESS-TOKEN field. When the key session expires, you will need to get the token again;
    • organization ID from the org:id field. The field contains data in the format urn:vcloud:org:<org_id>, where <org_id> is the organization ID.

Request examples

Full description of the VMware Cloud Director API in the VMware documentation.

Request organization objects

Returns all available organization objects (virtual data centers, catalogs, tasks, quotas, groups, metadata, and organization networks), as well as a link for organization administration.

Request example:

curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/org/<org_id>'

Specify:

  • <version> — API version;

  • <token> — token;

  • <url> — address depending on the region:

    • Moscow: vcd-msk.selectel.ru;
    • Saint Petersburg: vcd.selectel.ru;
  • <org_id> — organization ID that you saved when getting a token.

Request virtual data center objects

Returns a list of virtual data center objects.

Request example:

curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/query?type=orgVdc'

Specify:

  • <version> — API version;

  • <token> — token;

  • <url> — address depending on the region:

    • Moscow: vcd-msk.selectel.ru;
    • Saint Petersburg: vcd.selectel.ru.

Request a list of virtual machines

Returns a list of virtual machines.

Request example:

curl \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/query?type=vm&fields=name,containerName&filter=isVAppTemplate==false'

Specify <url> — address depending on the region:

  • Moscow: vcd-msk.selectel.ru;
  • Saint Petersburg: vcd.selectel.ru.

Request parameters:

  • type=vm — requests objects of the virtual machine type;
  • fields=name,containerName — for each virtual machine shows only the name and containerName attributes (and by default the href attributes);
  • filter=isVAppTemplate==false — displays only deployed virtual machines without vApp templates.

Turn on a virtual machine

Turns on the specified virtual machine.

Request example:

curl -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/vApp/vm-<vm_id>/power/action/powerOn'

Specify:

  • <version> — API version;

  • <token> — token;

  • <url> — address depending on the region:

    • Moscow: vcd-msk.selectel.ru;
    • Saint Petersburg: vcd.selectel.ru;
  • <vm_id> — virtual machine ID, can be found when requesting a list of virtual machines in the href field.

Turn off a virtual machine

Turns off the specified virtual machine.

Request example:

curl -XPOST \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/api/vApp/vm-<vm_id>/power/action/powerOff'

Specify:

  • <version> — API version;

  • <token> — token;

  • <url> — address depending on the region:

    • Moscow: vcd-msk.selectel.ru;
    • Saint Petersburg: vcd.selectel.ru;
  • <vm_id> — virtual machine ID, can be found when requesting a list of virtual machines in the href field.

Sign out of the session

Deletes the current session.

Request example:

curl -i -XDELETE \
-H 'Accept: application/*;version=<version>' \
-H 'Authorization: Bearer <token>' \
'https://<url>/cloudapi/1.0.0/sessions/'

Specify:

  • <version> — API version;

  • <token> — token;

  • <url> — address depending on the region:

    • Moscow: vcd-msk.selectel.ru;
    • Saint Petersburg: vcd.selectel.ru.