---
title: Launch and monitor a job
description: Start a template with the REST API and follow its status and live events.
---

[Set up authentication](/api/authentication), then list your templates with `GET /api/templates` or open a template in the web UI to find its ID. Use a template you have permission to run.

```sh
TEMPLATE_ID=00000000-0000-4000-8000-000000000001
curl --fail-with-body --silent --show-error \
  -H "Authorization: Bearer ${GLODRIK_TOKEN}" \
  -H 'Content-Type: application/json' \
  --data '{"limit":"web1"}' \
  "${GLODRIK_URL}/api/templates/${TEMPLATE_ID}/launch"
```

Replace the example limit with a host pattern appropriate to the inventory. Send `{}` to use the template's defaults if no survey answer is required. If the template has a survey, include answers by variable name, for example `{"survey":{"platform":"aws","region":"eu-central-1"}}`. Answers must match that template's survey. Sending `extra_vars` with a survey requires edit access on the template.

## Check the result

The launch returns HTTP 201 and a job object. Save its `id`. Read `GET /api/jobs/{id}` for status and exit details, and `GET /api/jobs/{id}/hosts` or `GET /api/jobs/{id}/tasks` for summaries.

For stored events, use `GET /api/jobs/{id}/events?after=0&limit=100`. To continue, pass the last event's `counter` as `after`. To watch a live job, use server-sent events:

```sh
curl --fail-with-body --no-buffer \
  -H "Authorization: Bearer ${GLODRIK_TOKEN}" \
  "${GLODRIK_URL}/api/jobs/${JOB_ID}/events/stream"
```

Replace `JOB_ID` with the ID returned at launch. Each `job_event` has a counter as its event ID. The stream ends with an `end` event carrying the job status and exit code. Resume with `Last-Event-ID` or `after`.

Use `POST /api/jobs/{id}/cancel` to request cancellation. When the job supports relaunch, use `POST /api/jobs/{id}/relaunch` with `{"revision":"same"}` or `{"revision":"latest"}` to choose its revision.
