Skip to content

Using the API

ScenarioRecommended method
Browser-based user sessionOIDC login → session cookie
CLI tool or script running as youPersonal Access Token
Third-party app acting on a user’s behalfOAuth 2.0
CI/CD pipelinePersonal Access Token
Terminal window
curl https://api.hzel.org/api/v1/containers \
-H "Authorization: Bearer hzel_AbCdEfGhIj…"
Terminal window
# Create
curl -X POST https://api.hzel.org/api/v1/containers \
-H "Authorization: Bearer hzel_…" \
-H "Content-Type: application/json" \
-d '{"hostname":"dev-box","cpu_cores":2,"memory_mb":1024,"disk_gb":20}'
# Start (use the id from the create response)
curl -X POST https://api.hzel.org/api/v1/containers/<id>/start \
-H "Authorization: Bearer hzel_…"

No CSRF header is needed when using a PAT.

Terminal window
# Enqueue
JOB=$(curl -sX POST https://api.hzel.org/api/v1/containers/<id>/commands \
-H "Authorization: Bearer hzel_…" \
-H "Content-Type: application/json" \
-d '{"command":"uname -a"}' | jq -r '.data.id')
# Poll result
curl https://api.hzel.org/api/v1/commands/$JOB \
-H "Authorization: Bearer hzel_…"

Or stream in real time over WebSocket:

wss://api.hzel.org/ws/jobs/<job_id>?token=hzel_…

Always check for an error key before reading data:

const res = await fetch('/api/v1/containers', { headers: { Authorization: `Bearer ${token}` } });
const body = await res.json();
if (body.error) {
console.error(body.error.code, body.error.message);
} else {
console.log(body.data);
}