vSphere Automation API
This is the vSphere REST API Reference. It provides API documentation, request/response samples, and usage description of the following vSphere services:
Getting Started with vSphere REST APIs in 5 Minutes
To get you started quickly let’s dive into the necessary steps to enable you to begin calling APIs.
Step 1 - Authenticate to the API Endpoint
The first setup is to create a session ID using the following API:
POST Create Session
Step 2 - Use the session ID in subsequent calls
On subsequent API calls you will need to include the session ID returned in the above call using an HTTP header as follows:
For more details on the API sessions you can refer Common Infrastruture Services documentation.
Step 3 - Create your first Virtual Machine
You have been authenticated and have retrieved your API session ID. Now, you can create your first virtual machine using this API:
POST Create VM
Step 4 - Get details about your VM
Once your VM is created, you can get the details of your VM by passing VM identifier
GET Get VM
API Categories
Appliance
The Appliance APIs provides services for managing vCenter Appliance configuration.
Common Infrastructure Services(CIS)
The CIS APIs provide VMware common infrastructure services such as session management, tags, and task management.
Content
The Content APIs provide services to manage and configure content libraries.
ESX
The ESX APIs provide services related to host management, host provisioning, KMS, and many more.
Snapservice
Note: Snapservice APIs support only the SAML bearer token based authentication.
Here are the steps to perform bearer token based authentication.
- Acquire bearer token from the SSO :
https://${VC}/sts/STSService
- GZIP and BASE64 encode the token received from the SSO Execute HTTP request against endpoint including the following header.
Authorization: SIGN token="{token}"
When the {token}
goes into the Authorization header that contains the 'SIGN token=' value. Note that the 'Accept', 'Content-Type'
and 'vmware-use-header-authn'
headers are also required:
Accept: application/json
Content-Type: application/json
vmware-use-header-authn: true
Example Snapservice About Info Request:
POST https://${SANPSERVICE}/api/snapservice/info/about
Accept: application/json
Content-Type: application/json
vmware-use-header-authn: true
Authorization: SIGN token="H4sIAAAAAAAAANVZaW+j ...."
Examples of how the SAML based authentication is done in the Automation SDKs for Snapservice APIs :
Python: snap_service_client.py
Java: SnapserviceClient.java
VAPI
the VAPI APIs provide access to VAPI meta data.
vCenter
The vcenter API provides services for managing and configuring vSphere environments.
Note: Some APIs from vCenter Rest APIs -> Deployment group need to be invoked on port 5480. The API contract on port 5480 is different than the one on port 443. Please refer to this KB article for more details.
vStats
The vStats APIs provide services to manage and collect metrics on objects inside your vSphere environment.