# Deploys

```
GET    /api/v1/sources/{id}/deploys
GET    /api/v1/sources/{id}/deploys/{deploy}
POST   /api/v1/sources/{id}/deploys
```

Read needs `deploys:read`, write needs `deploys:write`. A deploy marks a release of the app behind a source. The
dashboard's **Changes and incidents** card draws it on the last 24 hours of errors, and flags a deploy whose source
logged at least twice as many errors in the two hours after it as in the two hours before. About 15 minutes after each
deploy, Tailcove also checks whether it made things worse (see [Deploy checks](https://tailcove.dev/docs/deploy-checks)).

| Field          | Required | Notes                                                            |
| -------------- | -------- | ---------------------------------------------------------------- |
| `version`      | yes      | up to 100 characters, e.g. `v3.8.0`                              |
| `kind`         | no       | `deploy` (default) or `rollback`                                 |
| `description`  | no       | up to 255 characters, e.g. the commit title                      |
| `environment`  | no       | up to 40 letters, digits, `.`, `_`, `-`, `/` (e.g. `production`) |
| `commit_sha`   | no       | 7 to 64 hex characters                                           |
| `pull_request` | no       | a positive number, the pull request a preview was built from     |
| `branch`       | no       | up to 255 characters, the branch it was built from               |
| `deployed_at`  | no       | ISO 8601, within the last 24 hours; now when left out            |

Record one from a CI step after the release goes out:

```bash
curl -X POST https://tailcove.dev/api/v1/sources/$TAILCOVE_SOURCE_ID/deploys \
  -H "Authorization: Bearer $TAILCOVE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"version\": \"$GITHUB_REF_NAME\", \"commit_sha\": \"$GITHUB_SHA\", \"environment\": \"production\"}"
```

Send the full 40-character `commit_sha` if you want the check as a commit status on GitHub.

### Previews and pull requests

A deploy with a `pull_request`, or with the environment `preview`, `review` or `pr` (alone or followed by `-`, `_` or
`/`, like `pr-482` or `review/fix-login`), is a preview. It gets the preview check: new error patterns compared with a
week of the source's comparison source, new issues, and no error-rate rule (see
[Deploy checks](https://tailcove.dev/docs/deploy-checks#previews-and-pull-requests)). Its GitHub commit status is called
`Tailcove preview check`.

```bash
curl -X POST https://tailcove.dev/api/v1/sources/$TAILCOVE_SOURCE_ID/deploys \
  -H "Authorization: Bearer $TAILCOVE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"version\": \"pr-482\", \"environment\": \"preview\", \"pull_request\": 482, \"branch\": \"fix-login\", \"commit_sha\": \"$HEAD_SHA\"}"
```

On a GitHub Actions `pull_request` run, `$HEAD_SHA` is `${{ github.event.pull_request.head.sha }}`. `GITHUB_SHA` is a
merge commit there, and a status set on it doesn't show on the pull request.

The source it's compared with is the source's `preview_compare_source_id` (`PUT /api/v1/sources/{id}`, a source id of the
same team, or null for the source itself); `GET` on a source returns it as `previewCompareSourceId`.

## The check

Every deploy the API returns carries a `check` object:

```json
{
  "data": {
    "id": "dep_01jbx5q8k7m3n2p4r6s8t0v1w3",
    "sourceId": "src_01jbx5q8k7m3n2p4r6s8t0v1w3",
    "kind": "deploy",
    "version": "v1.4.2",
    "description": "Retry SMS on failure",
    "environment": "production",
    "commitSha": "3f9a1c0d2b4e6f8091a2b3c4d5e6f708192a3b4c",
    "pullRequest": null,
    "branch": null,
    "deployedAt": "2026-11-30T11:30:00+00:00",
    "check": {
      "kind": "release",
      "status": "regressed",
      "checked_at": "2026-11-30T11:46:03+00:00",
      "summary": {
        "errors_before_per_minute": 0.4,
        "errors_after_per_minute": 2.13,
        "new_patterns": 3,
        "new_issues": 0
      },
      "url": "https://tailcove.dev/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/deploys/dep_01jbx5q8k7m3n2p4r6s8t0v1w3"
    }
  }
}
```

`kind` is `release` or `preview`, the rule the check uses. `status` is `pending` until the check has run, then `healthy`, `regressed`, `no_data` (nothing to compare) or `skipped`
(not checked: the source has checks off, or the deploy is older than checks or too old to check). `summary` is null
while pending and when skipped. `url` is the report page.

To gate a pipeline on it, poll the deploy every minute until `check.status` is no longer `pending`, or use
`tailcove deploy --wait`, which does that and exits with `1` on a regression:

```bash
curl https://tailcove.dev/api/v1/sources/$TAILCOVE_SOURCE_ID/deploys/$DEPLOY_ID \
  -H "Authorization: Bearer $TAILCOVE_API_TOKEN"
```

A source records at most 200 deploys in any 24 hours; past that the answer is `429`. Deploys are kept as long as your plan keeps [issue history](https://tailcove.dev/docs/issues#history-after-the-lines-expire): 90 days on Free, 365 on Pro and 730 on Business.
