JSON payload to send multiple API requests as a single batch. This sample creates 4 virtual machines – 3 simple/shell VMs, and 1 detailed/advanced VM.
Request Parameters
The below parameters should be used with the sample payload.
Please note you will need to alter {{placeholder}} values to match your environment, e.g. subnet name and UUID, cluster name and UUID.
Request URL:
https://[prism_central_ip_address]:9440/api/nutanix/v3/batch
Request method:
POST
Recommended Reading
In conjunction with this code sample, it is recommended to read the article titled “Batch Brewing – Multiple Requests with the Nutanix APIs“. It contains walk-through information about how to use API batch requests.
Payload
{
"action_on_failure": "CONTINUE",
"execution_order": "SEQUENTIAL",
"api_request_list": [
{
"operation": "POST",
"path_and_params": "/api/nutanix/v3/vms",
"body": {
"spec": {
"name": "batch_create_vm_1_basic",
"resources": {}
},
"metadata": {
"kind": "vm"
}
}
},
{
"operation": "POST",
"path_and_params": "/api/nutanix/v3/vms",
"body": {
"spec": {
"name": "batch_create_vm_2_basic",
"resources": {}
},
"metadata": {
"kind": "vm"
}
}
},
{
"operation": "POST",
"path_and_params": "/api/nutanix/v3/vms",
"body": {
"spec": {
"name": "batch_create_vm_3_basic",
"resources": {}
},
"metadata": {
"kind": "vm"
}
}
},
{
"operation": "POST",
"path_and_params": "/api/nutanix/v3/vms",
"body": {
"spec": {
"name": "batch_create_vm_4_detailed",
"resources": {
"power_state": "ON",
"num_vcpus_per_socket": 1,
"num_sockets": 1,
"memory_size_mib": 1024,
"disk_list": [
{
"disk_size_mib": 1024,
"device_properties": {
"device_type": "DISK"
}
},
{
"device_properties": {
"device_type": "CDROM"
}
}
],
"nic_list": [
{
"nic_type": "NORMAL_NIC",
"is_connected": true,
"ip_endpoint_list": [
{
"ip_type": "DHCP"
}
],
"subnet_reference": {
"kind": "subnet",
"name": "{{subnet_name}}",
"uuid": "{{subnet_uuid}}"
}
}
],
"guest_tools": {
"nutanix_guest_tools": {
"state": "ENABLED",
"iso_mount_state": "MOUNTED"
}
}
},
"cluster_reference": {
"kind": "cluster",
"name": "{{cluster_name}}",
"uuid": "{{cluster_uuid}}"
}
},
"api_version": "3.1.0",
"metadata": {
"kind": "vm"
}
}
}
],
"api_version": "3.0"
}