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

# Find the deploy that caused a regression

> Match the first-seen time of an issue to the deployments of its service, and read the deployments near an anomaly.

A regression starts at a point in time, and a deploy is often the change at that point. This recipe
reads when an issue started, lists the deployments of its service, and reads the deployments that
Squasher attaches to an anomaly finding. Reading needs `errors:read`, `deployments:read`, and
`findings:read`.

Deployment records exist when a connected provider sends them or when your pipeline records them
with `deployments.create`. See [Deployments API](https://docs.squasher.ai/api-reference/deployments.md). Without records, the
list is empty.

## Read when the issue started

Read the issue, and note `first_seen` and `service_name`.

> [tab] CLI
>
> ```bash theme={null}
> squasher errors get iss_42 --project "$SQUASHER_PROJECT_ID" --json
> ```

> [tab] MCP
>
> ```javascript theme={null}
> const projectId = "YOUR_PROJECT_ID";
> const issue = await squasher.request({
>   method: "GET",
>   path: `/v1/projects/${projectId}/errors/iss_42`,
> });
> return { first_seen: issue.first_seen, service: issue.service_name, environment: issue.environment };
> ```

> [tab] REST API
>
> ```bash theme={null}
> curl "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/errors/iss_42" \
>   -H "x-squasher-key: $SQUASHER_API_KEY"
> ```

## List the deployments of the service

Filter by the service and the environment of the issue. The result is a list of deployment records.
Compare `started_at` and `finished_at` with `first_seen`: the deploy that finished right before the
issue started is the first suspect.

> [tab] CLI
>
> ```bash theme={null}
> squasher deployments list --project "$SQUASHER_PROJECT_ID" \
>   --service api --environment production --limit 10
> ```
>
> The command prints a table with the provider, service, version, environment, status, and
> deployment ID. It has no times and no commit. It ignores `--json`. To read `started_at` and
> `commit_sha`, use the MCP or REST API tab.

> [tab] MCP
>
> ```javascript theme={null}
> const projectId = "YOUR_PROJECT_ID";
> return await squasher.request({
>   method: "GET",
>   path: `/v1/projects/${projectId}/deployments`,
>   query: { service_name: "api", environment: "production", limit: 10 },
> });
> ```

> [tab] REST API
>
> ```bash theme={null}
> curl -G "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/deployments" \
>   -H "x-squasher-key: $SQUASHER_API_KEY" \
>   --data-urlencode service_name=api \
>   --data-urlencode environment=production \
>   --data-urlencode limit=10
> ```

The response is an array. Each record has this shape:

```json theme={null}
[
  {
    "id": "<uuid>",
    "provider": "github",
    "deployment_id": "<provider deployment ID>",
    "service_name": "api",
    "version": "1.4.0",
    "environment": "production",
    "status": "ready",
    "commit_sha": "<commit SHA>",
    "branch": "main",
    "started_at": "<ISO time>",
    "finished_at": "<ISO time>"
  }
]
```

The filters are `service_name`, `version`, `environment`, `provider`, `status`, and `limit` (1 to
250\).

## Read the deployments near an anomaly

When an anomaly finding opens for the service, the finding carries the deployments from 6 hours
before the first breach to 1 hour after the last one. List the findings for the service, then read
one.

> [tab] CLI
>
> ```bash theme={null}
> squasher findings list --project "$SQUASHER_PROJECT_ID" \
>   --kind anomaly --signal error_rate --service api --status all --limit 5
> squasher findings get FINDING_ID --project "$SQUASHER_PROJECT_ID" --json
> ```

> [tab] MCP
>
> ```javascript theme={null}
> const projectId = "YOUR_PROJECT_ID";
> const list = await squasher.request({
>   method: "GET",
>   path: `/v1/projects/${projectId}/findings`,
>   query: { kind: "anomaly", signal: "error_rate", service: "api", status: "all", limit: 5 },
> });
> const id = list.data[0].id;
> const detail = await squasher.request({
>   method: "GET",
>   path: `/v1/projects/${projectId}/findings/${id}`,
> });
> return detail.evidence;
> ```

> [tab] REST API
>
> ```bash theme={null}
> curl -G "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/findings" \
>   -H "x-squasher-key: $SQUASHER_API_KEY" \
>   --data-urlencode kind=anomaly \
>   --data-urlencode signal=error_rate \
>   --data-urlencode service=api \
>   --data-urlencode status=all
>
> curl "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/findings/FINDING_ID" \
>   -H "x-squasher-key: $SQUASHER_API_KEY"
> ```

`findings get` returns `finding`, `evaluations`, `series`, and `evidence`. `evidence.deployments`
holds up to 10 deployments, and `evidence.error_groups` holds up to 5 top issues of the service in
that time. Both lists are empty when nothing matches.

> [!NOTE]
>
> A deploy that finished before the issue started is a suspect, not proof. Check that the version in
> the first events of the issue matches the deploy, for example with the `release` of a log from the
> [logs query](https://docs.squasher.ai/agent-workflows/query-trace-logs.md).

## Next steps

> [card] [Query the logs of a trace](https://docs.squasher.ai/agent-workflows/query-trace-logs.md)
>
> Read the logs around one failing request.

> [card] [Anomalies and findings](https://docs.squasher.ai/features/anomalies.md)
>
> How Squasher finds services that leave their normal band.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.