> ## Documentation Index
> Fetch the complete documentation index at: https://docs.infraudit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API endpoints for scheduled jobs — GET /jobs

> Create, list, trigger manually, and inspect execution history for InfraAudit scheduled jobs including drift detection, vulnerability scans, and billing syncs.

Jobs are the scheduled tasks InfraAudit uses to run drift detection, vulnerability scans, compliance assessments, and billing syncs. The jobs endpoints let you inspect scheduled jobs, trigger them manually, and view execution history.

Base path: `/api/v1/jobs`

***

## GET /jobs — list jobs

Returns all configured jobs with their schedules and last execution status.

```http theme={null}
GET /api/v1/jobs
Authorization: Bearer <token>
```

### Response

```json theme={null}
[
  {
    "id": 1,
    "type": "drift_detection",
    "schedule": "0 */4 * * *",
    "enabled": true,
    "last_execution_status": "succeeded",
    "last_run_at": "2024-01-15T08:00:00Z",
    "next_run_at": "2024-01-15T12:00:00Z"
  }
]
```

<ResponseField name="type" type="string">
  Job type: `drift_detection`, `vulnerability_scan`, `compliance_assess`, or `billing_sync`.
</ResponseField>

<ResponseField name="schedule" type="string">
  Cron expression for the job's schedule.
</ResponseField>

***

## GET /jobs/{id} — get job

Returns details for a single job.

```http theme={null}
GET /api/v1/jobs/{id}
Authorization: Bearer <token>
```

***

## POST /jobs/{id}/trigger — trigger manual run

Runs the job immediately regardless of its schedule. Returns `202 Accepted` with an execution ID.

```http theme={null}
POST /api/v1/jobs/{id}/trigger
Authorization: Bearer <token>
```

### Response `202`

```json theme={null}
{
  "execution_id": 88,
  "status": "running",
  "started_at": "2024-01-15T10:30:00Z"
}
```

***

## GET /jobs/{id}/executions — list execution history

Returns past executions for a job.

```http theme={null}
GET /api/v1/jobs/{id}/executions
Authorization: Bearer <token>
```

### Query parameters

<ParamField query="status" type="string">
  Filter by execution status: `running`, `succeeded`, or `failed`.
</ParamField>

<ParamField query="page" type="integer" default="1">
  Page number.
</ParamField>

<ParamField query="per_page" type="integer" default="20">
  Results per page.
</ParamField>

### Response

```json theme={null}
{
  "data": [
    {
      "id": 88,
      "job_id": 1,
      "status": "succeeded",
      "started_at": "2024-01-15T08:00:00Z",
      "ended_at": "2024-01-15T08:03:42Z",
      "duration_ms": 222000,
      "findings_count": 3
    }
  ]
}
```

<ResponseField name="findings_count" type="integer">
  Number of new findings created during this execution (drifts, vulnerabilities, etc.).
</ResponseField>

***

## GET /jobs/{id}/executions/{execution_id} — get execution detail

Returns the full execution record including a log excerpt.

```http theme={null}
GET /api/v1/jobs/{id}/executions/{execution_id}
Authorization: Bearer <token>
```
