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

# CI Autopilot: Read CI jobs, logs and failure analysis in the v2 API

> List the CI jobs and workflow runs on a commit, read a failed job's analysis and log, and group failures by cause through the v2 API.

**Your scripts and agents can now read why CI failed straight from the v2 API.**

### New features

* **CI jobs on a commit.** [List the CI jobs on a commit](https://docs.trunk.io/api/cijobs/list-the-ci-jobs-on-a-commit.md) by pull request or by repository and commit SHA. Each failed job includes its failing step, Trunk's AI analysis and a log excerpt.
* **Workflow runs.** [List the CI workflow runs on a commit](https://docs.trunk.io/api/ciworkflowruns/list-the-ci-workflow-runs-on-a-commit.md), each with its jobs counted.
* **Commits that ran CI.** [List the commits that ran CI on a pull request](https://docs.trunk.io/api/pullrequests/list-the-commits-that-ran-ci-on-a-pull-request.md), newest first.
* **Job logs.** [Read a CI job's log lines](https://docs.trunk.io/api/cijobs/list-a-ci-jobs-log-lines.md), or just the failing lines. Logs are kept for 30 days. This needs the new **Read CI logs** API key permission.
* **Failures with no log.** [List a CI job's check-run annotations](https://docs.trunk.io/api/cijobs/list-a-ci-jobs-check-run-annotations.md) to see why a job failed when no log step explains it, such as a disconnected runner.
* **Failure clusters.** [Get a CI failure cluster](https://docs.trunk.io/api/cifailureclusters/get-a-ci-failure-cluster.md) to see how often failures with the same cause happened.

To have an agent fix a flaky test with this context, see [Fix Flaky Tests](https://docs.trunk.io/flaky-tests/recipes/autofix-flaky-tests.md). See the [API reference](https://docs.trunk.io/api.md) for all v2 endpoints.
