---
title: "Copy a pipeline from another environment"
url: https://docs.corefinity.com/api/reference/deployments/copy-site-deployment-pipeline
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_pipeline_copy.md
---
# Copy a pipeline from another environment

Copies the chosen parts of the pipeline of another environment of the same site onto this one: its stages,
settings, variables, registry secrets and deployment options. Send `dry_run` true to see what would change and
write nothing; copying onto a production environment needs `confirm_production` true. Your role needs the Edit
Environment Deployment Pipeline permission.

```http
POST /api/corestack/sites/{site}/deployments/pipeline/{binding}/copy
```

- Scope: `write`
- Also needs `exec` when The copied stages bring a command this pipeline does not run now (never for a dry run)
- Two-factor: required on your account (all)
- Rate limit: 20 a minute
- Try it in the console: off. It overwrites data that cannot be brought back. 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.
- `binding` (integer, required): The id of one of the environment's pipelines, as the pipeline read answers it in `binding_id` and `bindings[].id`. Digits only.

## Body

- `confirm_production` (boolean): True to copy onto a production environment.
- `dry_run` (boolean): Write nothing and answer what would change.
- `from_binding_id` (integer): One of that environment's pipelines. Its repository's pipeline when left out.
- `from_site_id` (integer, required): The site row of another environment of the same site.
- `parts` (array of strings, required)
- `revision` (string): The revision of this pipeline that you read. Needed to copy `stages` or `settings`, which are refused `stale` without it; a dry run checks against the pipeline as it is now when it is left out.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/deployments/pipeline/2210/copy \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "from_site_id": 1042,
    "parts": [
      "stages",
      "settings"
    ],
    "revision": "3b4b4f4d2bd57cc6"
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/deployments/pipeline/2210/copy', [
        'from_site_id' => 1042,
        'parts' => [
            'stages',
            'settings',
        ],
        'revision' => '3b4b4f4d2bd57cc6',
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/deployments/pipeline/2210/copy', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    from_site_id: 1042,
    parts: [
      'stages',
      'settings',
    ],
    revision: '3b4b4f4d2bd57cc6',
  }),
});

// 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/pipeline/2210/copy",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "from_site_id": 1042,
        "parts": [
            "stages",
            "settings",
        ],
        "revision": "3b4b4f4d2bd57cc6",
    },
)

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

## Responses

### 200 What was, or would be, copied, part by part.

```json
{
  "dry_run": false,
  "from_site_id": 1042,
  "parts": [
    {
      "added": [],
      "overwritten": [
        "post_deploy"
      ],
      "part": "stages",
      "removed": [],
      "unchanged": [
        "build",
        "database"
      ]
    },
    {
      "added": [],
      "overwritten": [],
      "part": "settings",
      "removed": [],
      "unchanged": [
        "maintenance_policy",
        "tunnels",
        "pause_crons",
        "run_migrations",
        "timeouts",
        "keep_node_modules"
      ]
    }
  ]
}
```

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

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

### 403 The token lacks the scope (`scope_required`, with the `scope` to use: `write`, or `exec` when the change brings a command the pipeline does not run now), 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 pipeline changed since the `revision` you sent, or no revision was sent (`stale`): read it again. A reset to the template also answers the `revision` the pipeline is at now. Or Corefinity has locked the pipeline (`pipeline_locked`), it is not a three-stage pipeline yet or the version cannot be restored (`pipeline_classic`), a carried-over pipeline still waits for its review (`pipeline_review_pending`, on a reset), or the site is managed by another control panel (`managed_elsewhere`).

```json
{
  "code": "managed_elsewhere",
  "message": "This site is managed by another control panel",
  "reason": "managed_elsewhere"
}
```

### 422 The request was refused and nothing was saved. - `invalid`: a field is missing, of the wrong type or not a value it takes. `field` names it. - `confirm`: a production environment, and `confirm_production` is not true. - `line_credentials`: a line holds a credential (move it into a variable); `line_own_shell`: a line such as a lone `cd`, which does nothing for the next line. - `too_many_lines`, `line_too_long`: a stage holds more lines, or a line more bytes, than it can. - `preset_unavailable`, `node_too_old`: a build preset, or a Node.js version, that cannot be used here. - `maintenance_policy_unavailable`, `wrong_platform`, `timeout_out_of_range`: a setting the site's platform does not offer, or a timeout outside its bounds. - `version_unavailable`, `not_reached`: on a reset, a template version that cannot be held here, or a pipeline that does not follow a template. - `too_many_variables`, `variable_reserved`, `variable_tool_credential`, `variable_invalid`: on a copy of `variables`, a variable this environment cannot take. Nothing of the copy is kept. Every reason but `invalid` names its field in `errors` only.

```json
{
  "code": "confirm",
  "errors": {
    "confirm_production": [
      "Copying into production changes how it deploys. Confirm to continue."
    ]
  },
  "message": "Copying into production changes how it deploys. Confirm to continue.",
  "reason": "confirm"
}
```

### 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
}
```

## 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 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `forbidden` | The person is not allowed to do this. |
| 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 | `managed_elsewhere` | This site is read-only here. Change it in the control panel that manages it. |
| 409 | `pipeline_classic` | Corefinity still runs this pipeline in its classic form, so it cannot be edited yet. |
| 409 | `pipeline_locked` | Corefinity has locked this pipeline: Held while a migration is checked. |
| 409 | `stale` | What you read has changed since you read it. Read it again, then send the change with its new version or quote. |
| 422 | `confirm` | The action needs an explicit confirmation field. Ask the person, then send it. |
| 422 | `line_credentials` | This line holds a credential. Move this value into a variable, then save again. |
| 422 | `maintenance_policy_unavailable` | Choose Always or Off: this platform has no pending-upgrade check. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 422 | `timeout_out_of_range` | Choose a timeout between 60 and 3600 seconds. |
| 422 | `version_unavailable` | This version is not available here. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

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