Create VM
/v2.1/serversTo create a new virtual machine (VM), you can send a POST request to the /v2.1/servers endpoint of the compute service. This request requires an authentication token, which you should include in the request headers.
You should add X-OpenStack-Nova-API-Version: 2.67 to the request headers to ensure compatibility with the API version.
Source: create-server
Request
Body Parameters
serverobjectrequiredA server object.
flavorRefstringrequiredFlavor reference (ID/UUID or full URL).
namestringrequiredServer name.
networksarrayrequiredNetwork attachments. Required when multiple networks exist. From 2.37, supports string values "auto" or "none" (not a list) and cannot be combined with other network values. Interface tag accepted in 2.32–2.36 and from 2.42.
8 fields
uuidstringbodyNetwork UUID for a NIC. Required if port is omitted. Enforced UUID format from 2.37.
portstringbodyExisting port ID (must be DOWN). Required if uuid is omitted. Requested security groups are not applied to pre-existing ports.
fixed_ipsarraybodyFixed IPs. If specifying an IP, a network uuid/net_id is also required.
ip_addressstringbodyFixed IP address.
ip_versionintegerbodyIP version 4 or 6. Default 4.
port_security_enabledbooleanrequiredbodyDefault port_security_enabled for a created port. New in 2.42.
security_groupsarrayrequiredbodySecurity group IDs for the port. New in 2.67.
tagstringbodyDevice role tag exposed via metadata/config drive. Accepted in 2.32–2.36 and from 2.42.
accessIPv4stringIPv4 address to access the server.
accessIPv6stringIPv6 address to access the server.
adminPassstringAdmin password; generated if omitted.
block_device_mapping_v2arrayAdvanced block device mappings (boot from volume, etc.). Tags accepted in 2.32 and from 2.42.
13 fields
boot_indexintegerrequiredbodyBoot order; 0 boots first; negative or None disables.
delete_on_terminationbooleanbodyDelete volume on server deletion. Default false.
destination_typestringbodyDevice location: local or volume.
device_namestringbodyDevice path; ignored by libvirt since 12.0.0.
device_typestringbodyDevice type (e.g., disk, cdrom).
disk_busstringbodyBus type (e.g., ide, scsi, virtio).
guest_formatstringbodyFilesystem (e.g., ext4, xfs, swap). Swap has specific restrictions.
no_devicebooleanbodyMarks as no device if true.
source_typestringbodySource: blank, image, snapshot, or volume. Required unless no_device is true.
uuidstringbodySource resource UUID (image/snapshot/volume).
volume_sizeintegerbodyVolume size (GiB). Required for image→volume and blank→volume.
tagstringbodyBlock device role tag; accepted in 2.32 and from 2.42.
volume_typestringbodyVolume type ID or name; only with source blank/image/snapshot and destination volume. New in 2.67.
config_drivebooleanEnable config drive for metadata injection.
imageRefstringImage UUID. Required unless booting from volume.
key_namestringKey pair name.
metadataobjectMetadata key/value pairs (max 255 bytes each).
OS-DCF:diskConfigstringDisk partitioning: AUTO or MANUAL. Cannot force MANUAL image to AUTO.
2 values
AUTOBuilds the server with a single partition the size of the target flavor disk, and grows the file system to fill it.MANUALUses the partition scheme and file system from the source image. Extra space stays unpartitioned.
personalityarrayInject text files at launch. Available until 2.56.
user_datastringBase64-encoded user data (< 65535 bytes).
descriptionstringFree-form description (< 255 chars). New in 2.19.
tagsarrayUp to 50 tags; each non-empty, < 60 chars; '/' and ',' not allowed. New in 2.52.
trusted_image_certificatesarrayUp to 50 certificate IDs for image signature verification; not for volume-backed. New in 2.63.
hoststringTarget compute host name; typically admin-only. New in 2.74.
hypervisor_hostnamestringTarget hypervisor hostname; typically admin-only. New in 2.74.
os:scheduler_hintsobjectTop-level scheduler hints; availability varies by cloud.
8 fields
build_near_host_ipstringbodyPrefer hosts near this IP (with cidr). Requires SimpleCIDRAffinityFilter.
cidrstringbodyCIDR for build_near_host_ip; defaults to /24 if omitted.
different_cellarraybodySchedule away from listed cells (names/routes). Cell v1 env.
different_hostarraybodyPrefer hosts different from given server UUIDs.
groupstringbodyServer group UUID; applies group policy (affinity/anti-affinity).
querystringbodyJsonFilter expression.
same_hostarraybodyPrefer same host as given server UUIDs.
target_cellstringbodyTarget cell name. Cell v1 env.
- cURL
- HTTP
curl -ks -H 'Content-Type: application/json' -H 'X-Auth-Token: gAAAAA<...>' -H 'X-OpenStack-Nova-API-Version: 2.67' \
-d '{
"server": {
"name": "Ubuntu24",
"imageRef": "b4d9c688-1b96-4604-8cf1-d78c5c80a984",
"block_device_mapping_v2": [
{
"boot_index": "0",
"uuid": "b4d9c688-1b96-4604-8cf1-d78c5c80a984",
"source_type": "image",
"volume_size": "10",
"destination_type": "volume",
"volume_type": "nvmer3",
"delete_on_termination": true
}
],
"OS-DCF:diskConfig": "AUTO",
"flavorRef": "468c0c15-08bd-4e1d-8564-5053ce12966b",
"networks": [
{
"uuid": "8ae2b710-ad3d-469e-a75a-c3e203887d2e"
}
],
"key_name": "Docs Writter"
}
}' https://api.vietnix.cloud:8774/v2.1/servers
POST https://api.vietnix.cloud:8774/v2.1/servers
Content-Type: application/json
X-Auth-Token: gAAAAA<...>
X-OpenStack-Nova-API-Version: 2.67
{
"server": {
"name": "Ubuntu24",
"imageRef": "b4d9c688-1b96-4604-8cf1-d78c5c80a984",
"block_device_mapping_v2": [
{
"boot_index": "0",
"uuid": "b4d9c688-1b96-4604-8cf1-d78c5c80a984",
"source_type": "image",
"volume_size": "10",
"destination_type": "volume",
"volume_type": "nvmer3",
"delete_on_termination": true
}
],
"OS-DCF:diskConfig": "AUTO",
"flavorRef": "468c0c15-08bd-4e1d-8564-5053ce12966b",
"networks": [
{
"uuid": "8ae2b710-ad3d-469e-a75a-c3e203887d2e"
}
],
"key_name": "Docs Writter"
}
}
Response
Parameters
LocationstringrequiredheaderLocation URL of the created server. Returned in the Location response header.
serverobjectrequiredbodyServer object.
idstringrequiredbodyUUID of the server.
linksarrayrequiredbodyArray of links to related resources.
adminPassstringrequiredbodyAdministrative password for the server. Optional; returned only if enable_instance_password is True.
security_groupsarrayrequiredbodyOne or more security group objects.
1 field
namestringrequiredbodySecurity group name.
OS-DCFstringrequiredbodyDisk configuration. One of: AUTO (single partition sized to flavor disk), MANUAL (use source image layout; extra space remains unpartitioned).
Status Codes
Success
| Status Code | Description |
|---|---|
| 200 - OK | Request was successful. |
| 202 - Accepted | Request was accepted for processing, but the processing has not been completed. A 'Location' header is included in the response which contains a link to check the progress of the request. |
Error
| Status Code | Description |
|---|---|
| 400 - Bad Request | Some content in the request was invalid. |
| 401 - Unauthorized | User must authenticate before making a request. |
| 403 - Forbidden | Policy does not allow current user to do this operation. |
| 404 - Not Found | The requested resource could not be found. |
| 409 - Conflict | This operation conflicted with another operation on this resource. |
Sample Response
Response body
{
"server": {
"id": "70748c08-0f81-4e73-b2f1-7568e5339faa",
"links": [
{
"rel": "self",
"href": "https://api.vietnix.cloud:8774/v2.1/servers/70748c08-0f81-4e73-b2f1-7568e5339faa"
},
{
"rel": "bookmark",
"href": "https://api.vietnix.cloud:8774/servers/70748c08-0f81-4e73-b2f1-7568e5339faa"
}
],
"OS-DCF:diskConfig": "AUTO",
"security_groups": [
{
"name": "default"
}
],
"adminPass": "z344qQ3xajM4"
}
}