---
title: "Create an environment deployment"
url: https://docs.corefinity.com/api/reference/enterprise/create-environment-deployment
type: endpoint
last_updated: 2026-11-13
feature: enterprise-deployments
related:
  - https://docs.corefinity.com/guides/corestack-enterprise/deployments-and-pipelines.md
---
# Create an environment deployment

Starts a deployment and answers it with `status` `7` (Queued): send JSON with `git` true to deploy a commit of
one of the environment's repositories, or `multipart/form-data` to deploy a release archive you upload through
the pipeline `pipeline_id` names. Your role needs the Create Deployments permission, and the token the
`deploy` ability as well as the `write` scope.

```http
POST /api/environments/{environment}/deployments
```

- Scope: `write`
- Also needs `deploy` when Always
- Rate limit: 60 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

- `environment` (integer, required): The id of a CoreStack Enterprise environment. Not the same number as a site row id.

## Body

- `git` (boolean, required): True to deploy a commit. Without it the request is an archive upload.
- `git_commit` (string, required): The full commit id, 40 or 64 hexadecimal characters. A short id or a branch name is refused.
- `git_repository` (integer, required): The id of one of the environment's repositories. The deployment runs on that repository's pipeline.
- `name` (string or null): A name for the deployment. The commit id when left out.
- `notes` (string or null)

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/environments/1311/deployments \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "git": true,
    "git_commit": "93ac3ee17c1306a5c478c583f0946e40d2e291f0",
    "git_repository": 3301,
    "name": "Release 2026.11.1",
    "notes": "Checkout fixes"
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/environments/1311/deployments', [
        'git' => true,
        'git_commit' => '93ac3ee17c1306a5c478c583f0946e40d2e291f0',
        'git_repository' => 3301,
        'name' => 'Release 2026.11.1',
        'notes' => 'Checkout fixes',
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/environments/1311/deployments', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    git: true,
    git_commit: '93ac3ee17c1306a5c478c583f0946e40d2e291f0',
    git_repository: 3301,
    name: 'Release 2026.11.1',
    notes: 'Checkout fixes',
  }),
});

// 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/environments/1311/deployments",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "git": True,
        "git_commit": "93ac3ee17c1306a5c478c583f0946e40d2e291f0",
        "git_repository": 3301,
        "name": "Release 2026.11.1",
        "notes": "Checkout fixes",
    },
)

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

## Responses

### 201 The new deployment, queued.

```json
{
  "deployment": {
    "artifact_pruned_at": null,
    "attempt_id": 190417,
    "environment_deployment_pipeline_id": "2210",
    "environment_id": "1311",
    "error": null,
    "git_author": null,
    "git_commit": "93ac3ee17c1306a5c478c583f0946e40d2e291f0",
    "git_commit_url": null,
    "git_merge_request": null,
    "hash": "8697839e-ee34-4255-8328-61f0651f63b4",
    "id": "88231",
    "name": "Release 2026.11.1",
    "notes": "Checkout fixes",
    "status": "7",
    "status_description": "Queued"
  }
}
```

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

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

### 403 The token lacks the `write` scope or the `deploy` ability (`scope_required`; `scope` names which), your role lacks the Create Deployments permission (`forbidden`, with `permission`), or you may not deploy to this environment. For an archive uploaded to an environment of a CoreStack or CoreCluster site, also a person who cannot deploy the site.

```json
{
  "code": "forbidden",
  "message": "You need the Create Deployments permission to do this. An owner of your company can grant it in Roles.",
  "permission": "createDeployments",
  "reason": "forbidden"
}
```

### 404 The id does not exist, or it is something you cannot see. Both answer the same body.

```json
{
  "message": "Not found."
}
```

### 409 Nothing was created. `reason` says why: `no_namespace` (the environment has nowhere to deploy to) or `stale` (the pipeline the deployment would use is no longer the environment's). An archive uploaded to an environment of a CoreStack or CoreCluster site that cannot take it answers a message only.

```json
{
  "code": "no_namespace",
  "message": "This environment has no namespace on its cluster, so there is nothing to deploy to.",
  "reason": "no_namespace"
}
```

### 422 A field is missing or wrong (`invalid`). An uploaded archive that is refused answers a message that says why and ends with a code in brackets, such as `(unsupported_archive_type)` or `(unsafe_entry_path)`. An archive uploaded to an environment of a site that is not live answers a message only.

```json
{
  "message": "That archive could not be accepted: only .tar, .tar.gz, .tar.xz, .tar.zst and .zip archives are supported. (unsupported_archive_type)"
}
```

### 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 | `forbidden` | The person is not allowed to do this. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 404 |  | Check the id. You see only what your account can reach. |
| 409 | `no_namespace` | The environment is not set up on its cluster yet. Contact support. |
| 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 |  | Fix the field named in `field`; `errors` says why. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Deployments and pipelines](https://docs.corefinity.com/guides/corestack-enterprise/deployments-and-pipelines.md)
