Fly.io runs your apps on servers close to users worldwide. Beyond the CLI, Fly has a powerful Machines API that lets you programmatically create, start, stop, and manage VMs.
Machines API — Create a VM
curl -X POST "https://api.machines.dev/v1/apps/my-app/machines" \
-H "Authorization: Bearer FLY_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"config": {
"image": "registry.fly.io/my-app:latest",
"guest": { "cpu_kind": "shared", "cpus": 1, "memory_mb": 256 },
"services": [{
"ports": [{ "port": 443, "handlers": ["tls", "http"] }],
"protocol": "tcp",
"internal_port": 8080
}]
}
}'
List All Machines
curl "https://api.machines.dev/v1/apps/my-app/machines" \
-H "Authorization: Bearer FLY_API_TOKEN" | jq ".[].id"
Start/Stop Machines
# Stop
curl -X POST "https://api.machines.dev/v1/apps/my-app/machines/MACHINE_ID/stop" \
-H "Authorization: Bearer FLY_API_TOKEN"
# Start
curl -X POST "https://api.machines.dev/v1/apps/my-app/machines/MACHINE_ID/start" \
-H "Authorization: Bearer FLY_API_TOKEN"
Use Cases
- On-demand workers — spin up machines for heavy tasks, destroy when done
- Preview environments — create per-PR deploys programmatically
- Auto-scaling — custom scaling logic beyond built-in autoscaler
- Multi-region — deploy to specific regions based on user location
CLI Quick Deploy
fly launch # Initialize app
fly deploy # Deploy from Dockerfile
fly scale count 3 --region iad,cdg,nrt # Scale to 3 regions
fly status # Check running machines
fly logs # Stream logs
Key Features
- Machines API for programmatic VM management
- Global edge network in 30+ regions
- GPU machines for ML workloads
- Postgres and Redis managed services
- Scale to zero — pay only when running
Need to scrape or monitor web data at scale? Check out my web scraping actors on Apify — ready-made tools that extract data from any website in minutes. Or email me at spinov001@gmail.com for custom solutions.
Top comments (0)