Create VM
To 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.
note
You should add X-OpenStack-Nova-API-Version: 2.67 to the request headers to ensure compatibility with the API version.
info
Source: create-server
Request
Body Parameters
| Name | In | Type | Description |
|---|---|---|---|
| server | body | object | A server object. |
| flavorRef | body | string | Flavor reference (ID/UUID or full URL). |
| name | body | string | Server name. |
| networks | body | array | Network 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. |
| networks.uuid (Optional) | body | string | Network UUID for a NIC. Required if port is omitted. Enforced UUID format from 2.37. |
| networks.port (Optional) | body | string | Existing port ID (must be DOWN). Required if uuid is omitted. Requested security groups are not applied to pre-existing ports. |
| networks.fixed_ips (Optional) | body | array | Fixed IPs. If specifying an IP, a network uuid/net_id is also required. |
| networks.ip_address (Optional) | body | string | Fixed IP address. |
| networks.ip_version (Optional) | body | integer | IP version 4 or 6. Default 4. |
| networks.port_security_enabled | body | boolean | Default port_security_enabled for a created port. New in 2.42. |
| networks.security_groups | body | array | Security group IDs for the port. New in 2.67. |
| networks.tag (Optional) | body | string | Device role tag exposed via metadata/config drive. Accepted in 2.32–2.36 and from 2.42. |
| accessIPv4 (Optional) | body | string | IPv4 address to access the server. |
| accessIPv6 (Optional) | body | string | IPv6 address to access the server. |
| adminPass (Optional) | body | string | Admin password; generated if omitted. |
| block_device_mapping_v2 (Optional) | body | array | Advanced block device mappings (boot from volume, etc.). Tags accepted in 2.32 and from 2.42. |
| block_device_mapping_v2.boot_index | body | integer | Boot order; 0 boots first; negative or None disables. |
| block_device_mapping_v2.delete_on_termination (Optional) | body | boolean | Delete volume on server deletion. Default false. |
| block_device_mapping_v2.destination_type (Optional) | body | string | Device location: local or volume. |
| block_device_mapping_v2.device_name (Optional) | body | string | Device path; ignored by libvirt since 12.0.0. |
| block_device_mapping_v2.device_type (Optional) | body | string | Device type (e.g., disk, cdrom). |
| block_device_mapping_v2.disk_bus (Optional) | body | string | Bus type (e.g., ide, scsi, virtio). |
| block_device_mapping_v2.guest_format (Optional) | body | string | Filesystem (e.g., ext4, xfs, swap). Swap has specific restrictions. |
| block_device_mapping_v2.no_device (Optional) | body | boolean | Marks as no device if true. |
| block_device_mapping_v2.source_type (Optional) | body | string | Source: blank, image, snapshot, or volume. Required unless no_device is true. |
| block_device_mapping_v2.uuid (Optional) | body | string | Source resource UUID (image/snapshot/volume). |
| block_device_mapping_v2.volume_size (Optional) | body | integer | Volume size (GiB). Required for image→volume and blank→volume. |
| block_device_mapping_v2.tag (Optional) | body | string | Block device role tag; accepted in 2.32 and from 2.42. |
| block_device_mapping_v2.volume_type (Optional) | body | string | Volume type ID or name; only with source blank/image/snapshot and destination volume. New in 2.67. |
| config_drive (Optional) | body | boolean | Enable config drive for metadata injection. |
| imageRef (Optional) | body | string | Image UUID. Required unless booting from volume. |
| key_name (Optional) | body | string | Key pair name. |
| metadata (Optional) | body | object | Metadata key/value pairs (max 255 bytes each). |
| OS-DCF:diskConfig (Optional) | body | string | Disk partitioning: AUTO or MANUAL. Cannot force MANUAL image to AUTO. |
| personality (Optional) | body | array | Inject text files at launch. Available until 2.56. |
| user_data (Optional) | body | string | Base64-encoded user data (< 65535 bytes). |
| description (Optional) | body | string | Free-form description (< 255 chars). New in 2.19. |
| tags (Optional) | body | array | Up to 50 tags; each non-empty, < 60 chars; '/' and ',' not allowed. New in 2.52. |
| trusted_image_certificates (Optional) | body | array | Up to 50 certificate IDs for image signature verification; not for volume-backed. New in 2.63. |
| host (Optional) | body | string | Target compute host name; typically admin-only. New in 2.74. |
| hypervisor_hostname (Optional) | body | string | Target hypervisor hostname; typically admin-only. New in 2.74. |
| os:scheduler_hints (Optional) | body | object | Top-level scheduler hints; availability varies by cloud. |
| os:scheduler_hints.build_near_host_ip (Optional) | body | string | Prefer hosts near this IP (with cidr). Requires SimpleCIDRAffinityFilter. |
| os:scheduler_hints.cidr (Optional) | body | string | CIDR for build_near_host_ip; defaults to /24 if omitted. |
| os:scheduler_hints.different_cell (Optional) | body | array | Schedule away from listed cells (names/routes). Cell v1 env. |
| os:scheduler_hints.different_host (Optional) | body | array | Prefer hosts different from given server UUIDs. |
| os:scheduler_hints.group (Optional) | body | string | Server group UUID; applies group policy (affinity/anti-affinity). |
| os:scheduler_hints.query (Optional) | body | string | JsonFilter expression. |
| os:scheduler_hints.same_host (Optional) | body | array | Prefer same host as given server UUIDs. |
| os:scheduler_hints.target_cell (Optional) | body | string | Target cell name. Cell v1 env. |
Using curl
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
Using HTTP request
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
| Name | In | Type | Description |
|---|---|---|---|
| Location | header | string | Location URL of the created server. Returned in the Location response header. |
| server | body | object | Server object. |
| id | body | string | UUID of the server. |
| links | body | array | Array of links to related resources. |
| adminPass | body | string | Administrative password for the server. Optional; returned only if enable_instance_password is True. |
| security_groups | body | array | One or more security group objects. |
| security_groups.name | body | string | Security group name. |
| OS-DCF:diskConfig | body | string | Disk 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
{
"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"
}
}