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

# Deployments API

> Report completed deployments to Struct from your pipeline.

Report the actual deployed commit and environment once rollout has finished. This is the only public API guide in this documentation.

Use this when your deploy pipeline does not create GitHub Deployment records. If it does, Struct picks up deploys automatically. See [Deploys](https://docs.struct.ai/agent/jobs/instrument-and-monitor.md).

> [!TIP]
>
> Deploying from GitHub Actions? Use the [notify-deploy action](https://github.com/struct-dot-ai/notify-deploy) instead of calling this endpoint yourself. It sends this request with the commit, repository, and idempotency key filled in:
>
> ```yaml theme={null}
> - uses: struct-dot-ai/notify-deploy@v1
>   with:
>     api-key: ${{ secrets.STRUCT_DEPLOY_KEY }}
>     environment: production
> ```

By default the action reports the workflow run's commit (`github.sha`) and repository. Pass `sha:` when the run was not started by the deployed commit, for example with `repository_dispatch`, `workflow_run` or a schedule, where `github.sha` is the tip of the default branch. Pass `repository:` when the deploy runs from a different repository than the code, such as a separate GitOps repository. The action never fails your deploy if Struct is unreachable; its README lists every input, including how to report failed deploys.

If one run deploys several services from the same commit, give each deploy its own `idempotency-key` built from the service, environment, commit and run, using the same environment value you pass to `environment:`:

```yaml theme={null}
idempotency-key: api-production-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
```

A fixed key such as `api` records only the service's first deploy, and a key without the environment drops the production deploy that follows a canary in the same run.

## Authentication

Create a **deployment key** in **Settings → API Keys** (admins only), leaving **Record deployments** ticked. The key starts with `sk-` and is shown once. Send it as a bearer token.

## Request

```bash theme={null}
curl -X POST "https://api.struct.ai/api/deployments/" \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "repository": "acme/api",
    "sha": "abc1234deadbeef",
    "environment": "production",
    "status": "success",
    "idempotencyKey": "production-abc1234"
  }'
```

| Field | Required | Notes |
| - | - | - |
| `repository` | Yes | `owner/name` of the GitHub repository |
| `sha` | Yes | The Git SHA that reached the environment, at least 7 characters |
| `environment` | Yes | Must match your Auto Monitors environment exactly, including case |
| `status` | No | `success`, `failure`, or `error`. Defaults to `success` |
| `idempotencyKey` | Yes | Your unique ID for this deploy event. Retrying with the same key does not create a duplicate |

## Behavior

* Post once the SHA has reached, or failed to reach, the environment. There is no "in progress" status.
* Canary then production is two posts: same SHA, two environment names, two idempotency keys.
* The Struct GitHub App still needs access to the repository so Struct can read the diff and open fixes.
* Do not point a GitHub repository webhook at this endpoint. GitHub cannot send the bearer token, so every delivery is rejected. Use the **GitHub Workflow** option instead.


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