---
title: "Reset environments to their template"
url: https://docs.corefinity.com/api/reference/deployments/reset-deploy-template-environments
type: endpoint
last_updated: 2026-11-13
feature: deployment-templates
related:
  - https://docs.corefinity.com/guides/sites/code-and-deployments/deployment-templates.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_template_environments_reset.md
---
# Reset environments to their template

Makes the named stages of each target environment follow the template again, replacing what the environment
holds for them. Send `dry_run` true first to see what would change; a reset that includes production
environments is then confirmed with `confirm_production` true and `confirm_count`, the dry run's
`production_count`.

```http
POST /api/corestack/companies/{company}/deploy-templates/{platform}/usage/reset
```

- Scope: `write`
- Also needs `exec` when A target environment gains a command it does not run now (never for a dry run)
- Two-factor: required on your account (all)
- Rate limit: 10 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

- `company` (integer, required): The id of a company you belong to or manage. Digits only.
- `platform` (string, required): The platform the template is for, such as `magento2`, `laravel` or `wordpress`. The list answers the ones your company can have.

## Body

- `confirm_count` (integer): The dry run's `production_count`.
- `confirm_production` (boolean)
- `dry_run` (boolean): Answer what would change for each target and write nothing.
- `targets` (array of objects, required)
  - `site_id` (integer, required)
  - `stages` (array of strings, required): The stages to reset, or `["all"]`.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/companies/1204/deploy-templates/magento2/usage/reset \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "confirm_count": 1,
    "confirm_production": true,
    "targets": [
      {
        "site_id": 1042,
        "stages": [
          "all"
        ]
      }
    ]
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/companies/1204/deploy-templates/magento2/usage/reset', [
        'confirm_count' => 1,
        'confirm_production' => true,
        'targets' => [
            [
                'site_id' => 1042,
                'stages' => [
                    'all',
                ],
            ],
        ],
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/companies/1204/deploy-templates/magento2/usage/reset', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    confirm_count: 1,
    confirm_production: true,
    targets: [
      {
        site_id: 1042,
        stages: [
          'all',
        ],
      },
    ],
  }),
});

// 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/companies/1204/deploy-templates/magento2/usage/reset",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "confirm_count": 1,
        "confirm_production": True,
        "targets": [
            {
                "site_id": 1042,
                "stages": [
                    "all",
                ],
            },
        ],
    },
)

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

## Responses

### 200 The targets and, when the reset was made, what was written.

```json
{
  "dry_run": true,
  "production_count": 1,
  "refused": [],
  "targets": [
    {
      "production": true,
      "site_id": 1042,
      "stages": [
        "post_deploy"
      ]
    }
  ],
  "written": null
}
```

### 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` for a reveal and for a change that brings a new command), 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 company does not exist or is not one you manage, the platform has no template, or a target is not a site you can see: all answer `Not found.` with no reason. Or deployment templates are not on for your company (`feature_off`).

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

### 409 The production environments of the reset are not the number you confirmed (`reach_changed`, with `production_count`), or an environment could no longer be reset while it was being made (`reach_changed`, with `refused`). Run the dry run again.

```json
{
  "code": "reach_changed",
  "message": "The production environments of this reset have changed. Review the selection again.",
  "production_count": 1,
  "reason": "reach_changed"
}
```

### 422 A field is wrong (`invalid`, with the `field`), the reset includes production environments and is not confirmed (`confirm`, with `production_count`), or some targets cannot be reset (`template_refused_on`, with `targets` giving each one's `reason`: `not_reached`, `pipeline_classic`, `pipeline_review_pending` or `pipeline_locked`).

```json
{
  "code": "confirm",
  "errors": {
    "confirm_count": [
      "Type the number of production environments to confirm the reset."
    ]
  },
  "message": "Type the number of production environments to confirm the reset.",
  "production_count": 1,
  "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 | `reach_changed` | The production environments of this reset have changed. Review the selection again. |
| 422 | `confirm` | The action needs an explicit confirmation field. Ask the person, then send it. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 422 | `template_refused_on` | Some environments cannot be reset. Deselect them, then reset the rest. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Deployment templates](https://docs.corefinity.com/guides/sites/code-and-deployments/deployment-templates.md)
- MCP tool: [`corestack_deployments_template_environments_reset`](https://docs.corefinity.com/mcp/tools/corestack_deployments_template_environments_reset.md)
