# Trigger preview deployment

Authenticate with an admin API key.

Use this endpoint to programmatically create or update a preview deployment for a Git branch. If a preview already exists for the specified branch, the endpoint triggers a redeployment instead of creating a duplicate.

The response includes a `statusId` that you can pass to [Get deployment status](/guides/admin-update-status) to track the deployment progress.

## Branch requirements

The `branch` must exist in the repository connected to your Mintlify project and you must have the Mintlify GitHub App installed. Branches on forks are not supported. See [Fork pull requests](/guides/manage-your-site-deploy-preview-deployments#fork-pull-requests) for how to preview changes from a fork.

## Use cases

- **CI/CD pipelines**: Automatically create preview deployments when users open or update pull requests.
- **Scheduled previews**: Build previews from long-running feature branches on a schedule.
- **Custom tooling**: Integrate preview creation into internal workflows or Slack bots.

## Access to previews

Previews created with this endpoint are publicly accessible unless you enable authentication for your previews, which applies to every preview in your deployment. You cannot password-protect an individual preview through this endpoint. See [Restrict access to preview deployments](/guides/manage-your-site-deploy-preview-deployments#restrict-access-to-preview-deployments).

## Rate limits

This endpoint allows up to 5 requests per minute per organization.

**OpenAPI**

**Related topics**

- [Mintlify REST API introduction](/guides/api-reference-introduction)
- [Preview deployments](/guides/manage-your-site-deploy-preview-deployments)
- [Preview deployment not created for a fork branch](/guides/help-center-preview-deployment-not-created-for-fork-branch)

`POST /project/preview/{projectId}`

:::code-group
```bash title="cURL"
curl --request POST \
  --url https://api.mintlify.com/v1/project/preview/{projectId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "branch": "<string>"
}'
```

```python title="Python"
import requests

url = "https://api.mintlify.com/v1/project/preview/{projectId}"

payload = {
  "branch": "<string>"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

```javascript title="JavaScript"
const options = {method: "POST", headers: {"Authorization": "Bearer <token>", "Content-Type": "application/json"}, body: JSON.stringify({
  "branch": "<string>"
})};

fetch("https://api.mintlify.com/v1/project/preview/{projectId}", options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

```php title="PHP"
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.mintlify.com/v1/project/preview/{projectId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"branch\":\"<string>\"}",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

```go title="Go"
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mintlify.com/v1/project/preview/{projectId}"

	payload := strings.NewReader("{\"branch\":\"<string>\"}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

```java title="Java"
HttpResponse<String> response = Unirest.post("https://api.mintlify.com/v1/project/preview/{projectId}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\"branch\":\"<string>\"}")
  .asString();
```

```ruby title="Ruby"
require 'uri'
require 'net/http'

url = URI("https://api.mintlify.com/v1/project/preview/{projectId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\"branch\":\"<string>\"}"

response = http.request(request)
puts response.read_body
```
:::

:::code-group
```json title="202"
{
  "statusId": "<string>",
  "previewUrl": "<string>"
}
```

```json title="400"
{
  "error": "<string>"
}
```

```json title="403"
{
  "error": "<string>"
}
```
:::

#### Authorizations

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `Authorization` | `string` | - |  |

The Authorization header expects a Bearer token. Use an admin API key. This is a server-side secret key. Generate one on the [API keys page](https://app.mintlify.com/settings/organization/api-keys) in your dashboard.

#### Path Parameters

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `projectId` | `string` | - |  |

Your project ID. Can be copied from the [API keys](https://app.mintlify.com/settings/organization/api-keys) page in your dashboard.

#### Body

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `branch` | `string` | - | The name of the Git branch to create a preview deployment for. Required string length: 1+ |

#### Response

`202` — Preview deployment queued successfully.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `statusId?` | `string` | - |  |

The status ID for tracking the preview deployment. Use this with the [Get deployment status](/guides/admin-update-status) endpoint.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `previewUrl?` | `string` | - | The URL where the preview deployment is hosted. |

## Related pages

- [Admin](./admin-index.md)
- [Agent](./agent-2-index.md)
- [Agent](./agent-index.md)
- [Agent-ready content](./agent-ready-content-index.md)
- [AI](./ai-index.md)
- [Analytics](./analytics-index.md)
- [API docs](./api-docs-index.md)
- [API reference](./api-reference-index.md)
- [Assistant](./assistant-2-index.md)
- [Assistant](./assistant-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
