---
title: "Start an autofixer analysis run for the given error group. Creates the run record immediately and spawns analysis in the background."
method: POST
path: "/projects/{project_id}/autofixer/analyze"
tags: ["Autofixer"]
---

# Start an autofixer analysis run for the given error group. Creates the run record immediately and spawns analysis in the background.

`POST /projects/{project_id}/autofixer/analyze`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/projects/{project_id}/autofixer/analyze`
- Auth: HTTP bearer

## Path parameters

- `project_id` integer, required

## Request body

- StartAnalysisRequest
  - `branch` string, nullable: Branch to clone instead of the project's main branch.
  - `error_group_id` integer, required
  - `max_turns` integer, nullable: Per-run turn cap applied to every phase (1–200). Only enforced for CLIs with a turn flag (Claude Code). `None` uses the provider's configured defaults.
  - `model` string, nullable: Model id for the chosen provider. `None` uses the provider's saved default model.
  - `provider` string, nullable: AI provider id ("claude_cli", "codex_cli", "opencode"). `None` uses the platform default provider.
  - `user_context` string, nullable: Free-text notes for the model (extra context about the error, retry guidance, constraints). Included verbatim in the analysis prompt.

## Response `202`

Analysis started; returns run_id for streaming

- AutofixerRunResponse
  - `ai_model` string, nullable
  - `ai_output` string, nullable
  - `ai_provider` string, nullable: AI provider slug this run executes with (e.g. claude_cli, codex_cli).
  - `analysis` string, nullable
  - `branch_name` string, nullable
  - `completed_at` string, nullable
  - `created_at` string, required
  - `error_message` string, nullable
  - `files_changed` integer, required
  - `id` integer, required
  - `phase` string, nullable
  - `pr_number` integer, nullable
  - `pr_url` string, nullable
  - `project_id` integer, required
  - `run_config` AutofixRunConfig, nullable: User-chosen per-run options, persisted as JSON in `agent_runs.run_config`. Every field is optional — unset fields fall back to the provider defaults in settings, then to built-in defaults.
    - `branch` string, nullable: Branch to clone instead of the project's main branch.
    - `max_turns` integer, nullable: Per-run turn cap applied to every phase of this run. Only enforced for CLIs with a turn flag (Claude Code); Codex/OpenCode run to completion. `None` uses the provider's per-phase defaults.
    - `model` string, nullable: Model id for the chosen provider. `None` uses the provider's saved default model, or the CLI's own default.
    - `provider` string, nullable: AI provider id ("claude_cli", "codex_cli", "opencode"). `None` uses the platform default provider from agent sandbox settings.
  - `started_at` string, nullable
  - `status` string, required
  - `tokens_input` integer, required
  - `tokens_output` integer, required
  - `trigger_source_id` integer, nullable
  - `user_context` string, nullable

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions
- `500`: Internal server error

## Changes

- **2026-07-27** `1b060c0a4ba3`: 6 info
  - added the new optional request property `branch`
  - added the new optional request property `max_turns`
  - added the new optional request property `model`
  - added the new optional request property `provider`
  - …2 more
- **2026-04-25** `774be20905f2`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/projects/:project_id/autofixer/analyze/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
