---
title: "Start a pipeline rehearsal"
url: https://docs.corefinity.com/api/reference/deployments/start-site-deployment-rehearsal
type: endpoint
last_updated: 2026-11-13
feature: deployment-pipeline
related:
  - https://docs.corefinity.com/guides/sites/code-and-deployments/pipeline-stages.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_rehearse.md
---
# Start a pipeline rehearsal

Runs a pipeline's stages on a staging environment without changing what the environment serves, to show
whether a deployment would succeed. Only one rehearsal of an environment runs at a time, and a production
environment is never rehearsed on. Your role needs the Edit Environment Deployment Pipeline permission, and
the token the `deploy` ability as well as the `exec` scope: a rehearsal builds and runs a deployment.

```http
POST /api/corestack/sites/{site}/deployments/rehearsals
```

- Scope: `exec`
- Also needs `deploy` when Always
- Two-factor: required on your account (all)
- Rate limit: 20 a minute
- Long-running: answers with an operation to poll
- Try it in the console: off. It runs commands on a live site. Copy the request and run it yourself when you are sure.

## Path parameters

- `site` (integer, required): The id of a site row. A website's production site and each of its environments has its own id. Digits only.

## Body

- `binding_id` (integer, required): This environment's pipeline, or one of another environment of the same site, whose stages then run here.
- `proposal` (object): Stages or settings that are not saved, by name (`build`, `database`, `post_deploy`, `settings`), each as its save takes it. Checked and rehearsed, never saved.
- `ref` (string): A branch or a commit to build. The head of the repository's branch when left out.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/deployments/rehearsals \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "binding_id": 2211
  }'
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/deployments/rehearsals', [
        'binding_id' => 2211,
    ]);

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/deployments/rehearsals', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    binding_id: 2211,
  }),
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.post(
    "https://manage.corefinity.com/api/corestack/sites/1042/deployments/rehearsals",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "binding_id": 2211,
    },
)

data = res.json() if res.content else None
```

## Responses

### 202 The rehearsal started.

```json
{
  "rehearsal": {
    "binding_id": 2211,
    "finished_at": null,
    "id": 77,
    "per_stage": {
      "build": "skipped",
      "database": "skipped",
      "platform_step": "pending",
      "shared_files": "pending",
      "upload": "pending"
    },
    "skipped": [],
    "started_at": "2026-11-09T10:42:07Z",
    "state": "running"
  }
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the `exec` scope or the `deploy` ability (`scope_required`; `scope` names which), your company requires two-factor authentication and you have not set it up, or your role lacks the Edit Environment Deployment Pipeline permission (`forbidden`, with `permission`).

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist or is something you cannot see, or the feature is not on for your company (`feature_off`).

```json
{
  "code": "feature_off",
  "message": "Not found.",
  "reason": "feature_off"
}
```

### 409 The rehearsal cannot start as things are. `reason` says why: `rehearsal_production` (a production environment), `deployment_running` or `busy` (a deployment or another rehearsal is running), `restore_running`, `command_running`, `install_running` or `exec_unresolved` (other work is running on it, or an earlier command's outcome is still being checked), `pipeline_classic`, `pipeline_untranslated`, `pipeline_review_pending` or `pipeline_switched_off` (the pipeline cannot run as three stages yet), `not_available` (the environment has no pipeline to rehearse on), `tunnels_switched_off`, `host_key_unconfirmed`, `needs_reauth` (reconnect the git account), `stale` or `pipeline_locked` (a proposal that cannot be saved), `removed` or `managed_elsewhere`.

```json
{
  "code": "deployment_running",
  "message": "A deployment is running. Wait for it to finish, or stop it from its page.",
  "reason": "deployment_running"
}
```

### 422 A field is wrong (`invalid`, with the `field`), the site has no repository connected (`no_repository`), or a proposed stage or setting is refused as a save of it would be, its field under `proposal.`.

```json
{
  "code": "invalid",
  "errors": {
    "binding_id": [
      "Choose the pipeline to rehearse."
    ]
  },
  "field": "binding_id",
  "message": "Choose the pipeline to rehearse.",
  "reason": "invalid"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

### 502 A provider the request depends on did not answer. Nothing was changed; try again.

```json
{
  "message": "GitLab did not answer. Try again."
}
```

### 503 Corefinity has switched commands on sites off for the moment (`switched_off`). Try again later.

```json
{
  "code": "switched_off",
  "message": "Site commands are switched off at the moment",
  "reason": "switched_off",
  "switch": "exec"
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `forbidden` | The person is not allowed to do this. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 404 | `feature_off` | This feature is not on for your organisation yet. |
| 409 | `deployment_running` | A deployment of the environment is running, or a stopped one is still being cleaned up. Wait for it to finish, then try again. |
| 409 | `rehearsal_production` | Rehearse on a staging environment of this site first. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 502 |  | Read the message; it says what happened. |
| 503 | `switched_off` | Corefinity has switched this action off for the moment. Try again later. |

## The same task elsewhere

- Guide: [Pipeline](https://docs.corefinity.com/guides/sites/code-and-deployments/pipeline-stages.md)
- MCP tool: [`corestack_deployments_rehearse`](https://docs.corefinity.com/mcp/tools/corestack_deployments_rehearse.md)
