
# Trigger a deploy

A deploy publishes your saved pages as a static site. The response arrives as soon as the deploy is queued. Poll [get deploy status](/api/deployments/get-deployments-latest) to know when it finished: it answers `queued` until the build starts, then `running`, and finally `success` or `failed`. A deploy queued here never waits on broken links, so it never ends `held`.

```sh
POST https://sitepaste.com/api/v1/public/sites/{siteId}/deployments
```

Requires the `deploy` scope.

## Usage

```bash
curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
  -H "Authorization: Bearer $TOKEN"
```

## Authorizations

| Header | Type | Required | Description |
|--------|------|----------|-------------|
| Authorization | string | Yes | Bearer token (`Authorization: Bearer sp_...`). Created in the dashboard under Account > Tokens. See [authentication](/api/authentication). |

This endpoint takes no body fields. An empty body or `{}` is accepted.

## Response

202 Accepted, with a `Location` header pointing at the status to poll:

```
Location: /api/v1/public/sites/{siteId}/deployments/latest
```

```json
{
  "deployUrl": "https://yourusername.sitepaste.com"
}
```

| Field | Type | Description |
|-------|------|-------------|
| deployUrl | string | The site's sitepaste.com address. Always the workspace subdomain, even when a [custom domain](/concepts/custom-domains) is connected. |

## Quotas and cooldown

The Pro plan includes 1,000 deploys per month. There is a 30-second cooldown between deploys, and this route also spends from the hourly [deploy budget](/api/overview#rate-limiting) of 300 that it shares with preview builds. The route refuses with 429 once that budget runs out. Deploy once after a batch of page writes rather than once per page.

## Errors

Every refusal uses the standard [error envelope](/api/overview#errors), which is a human-readable `error` and a stable `code` to branch on.

Quota exceeded returns 402:

```json
{
  "error": "Monthly build limit of 1000 reached. Upgrade your plan or wait for the next billing cycle.",
  "code": "quota_exceeded"
}
```

Cooldown active returns 429, and carries `Retry-After` with the whole seconds left on the 30-second cooldown, rounded up, so waiting exactly that long is enough:

```json
{
  "error": "Please wait 20 seconds before triggering another build.",
  "code": "cooldown_active"
}
```

A 402 with `"code": "plan_required"` means the workspace's subscription does not allow API deploys.

A 402 with `"code": "pro_features_in_use"` means the workspace is not on Pro but the site still uses Pro features, typically ones set during a Pro trial that has ended. The site is not rebuilt, and the live site stays as it is. `features` names them, with the same values as [pending changes](/api/deployments/get-pending-changes) reports in `proFeaturesInUse`. Upgrade to Pro, or remove the features, to deploy again.

```json
{
  "error": "This site uses Pro features (site_protection). Upgrade to Pro to deploy with them, or remove them.",
  "code": "pro_features_in_use",
  "features": ["site_protection"]
}
```

## Publishing after a write

Writing content and publishing it are two requests. Write with [POST /sites/{siteId}/pages](/api/pages/post-pages) or [POST /sites/{siteId}/pages/batch](/api/pages/post-pages-batch), then post here once the write has succeeded.

```bash
curl -X POST https://sitepaste.com/api/v1/public/sites/default/pages/batch \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"pages": [{"title": "Hello", "content": "Hi"}]}'

curl -X POST https://sitepaste.com/api/v1/public/sites/default/deployments \
  -H "Authorization: Bearer $TOKEN"
```

No write route publishes. Writing needs the `content` scope and deploying needs `deploy`, so a token holding only `content` can fill a site without putting it live. A refused deploy leaves the content saved, so retry the deploy alone.