Provisioning a VM (API example)
This page provides a generic example workflow for provisioning a OneCloud VM using the OneProvider API. Exact endpoints, parameters, and required fields can vary—always follow the current API reference for your account/region.
Important
Treat API tokens as secrets. Store them securely and never expose them in client-side code or public repositories.
Typical workflow
A common VM provisioning flow looks like this:
- Authenticate (API token)
- Select a project
- Choose a region/location
- Choose an OS image
- Choose a flavor/plan (CPU/RAM/disk)
- (Optional) Upload/select an SSH key
- Create the instance
- Poll the instance status until it is ACTIVE/RUNNING
- Retrieve the public IP and connect via SSH/RDP
Example request structure (pseudo-code)
BASH
# 1) Set your API token (example only)
export OP_API_TOKEN="YOUR_TOKEN"
# 2) Create a VM (endpoint and payload are illustrative)
curl -X POST "https://api.oneprovider.com/v1/instances" \
-H "Authorization: Bearer $OP_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"project_id": "PROJECT_ID",
"name": "example-vm-01",
"region": "REGION_CODE",
"image_id": "IMAGE_ID",
"flavor_id": "FLAVOR_ID",
"ssh_key_id": "SSH_KEY_ID"
}'
Note
The field names above are examples only. Use the exact fields required by the API documentation for your product/version.
Check provisioning status
After creating an instance, automation commonly polls the instance status until it becomes ready:
BASH
curl -X GET "https://api.oneprovider.com/v1/instances/INSTANCE_ID" \
-H "Authorization: Bearer $OP_API_TOKEN"
When the instance is ready, retrieve:
- Status (running/active)
- Assigned IP address(es)
- Login/access information (depending on OS)
Common errors
- 401/403: invalid token, missing permissions, or account restrictions
- 404: wrong resource ID (project/image/flavor not found in that region)
- 409/422: capacity/quota limits, invalid payload, or incompatible options
- 429: rate limiting (implement backoff)