Create a deployment
Report a deployment of a commit to an environment, from any CI or script. ref is the branch, tag or commit deployed; sha is resolved from it unless you give the whole commit id. environment is production unless you say (any name up to 255 characters, such as staging or review/feature-x; names are matched without regard to case, and the first spelling is kept). task is deploy unless you say; payload is any JSON object, returned as given. production_environment is true for an environment named production unless you say; transient_environment marks one that goes away, such as a review app.
/repos/{owner}/{name}/deploymentsIts first status is state (queued unless you say), with environment_url and log_url. Each status also shows on the commit as the check deploy / <environment>, which a ruleset’s required_deployments rule can require. Needs the Write role. Returns the deployment with its statuses.
Report from any CI with an access token that has deployments:write (the CI preset has it) and the Write role. Then report each step with POST …/deployments/{id}/statuses. Each status sets the check deploy / <environment> on the commit. A g1t Actions job with an environment: does all of this itself. See Deployments API.
- Authentication: Required. Send an access token as
Authorization: Bearer. - MCP tool:
workflowwithactioncreate_deployment, and the same inputs - Scope: An access token needs
deployments:write.
Path parameters
Section titled “Path parameters”| Name | Type | Required | Description |
|---|---|---|---|
owner |
string | Yes | The workspace that owns the repository. |
name |
string | Yes | The repository’s name. |
Body parameters
Section titled “Body parameters”Send a JSON object. Names are snake_case, as in responses; the camelCase spelling is accepted too.
| Name | Type | Required | Description |
|---|---|---|---|
ref |
string | Yes | The branch, tag or commit deployed, such as main or v1.4.0. |
sha |
string | No | The commit deployed; resolved from ref when left out. |
environment |
string | No | Where it went, such as production, staging or review/feature-x; production unless you say. |
task |
string | No | What kind of deployment, such as deploy or deploy:migrations; deploy unless you say. |
description |
string | No | A short note, at most 1,000 characters. |
payload |
object | No | Anything else to keep with it, as a JSON object (a JSON string of one is read too), at most 64 KB. Returned as given. |
production_environment |
boolean | No | Whether people use this environment directly. True for production unless you say. |
transient_environment |
boolean | No | Whether the environment goes away, such as a review app. False unless you say. |
state |
string | No | Its first status: queued unless you say. Report in_progress, then success or failure, as it goes. One of queued, in_progress, success, failure, error, inactive. |
environment_url |
string | No | Where it is served, an http(s) address. |
log_url |
string | No | Where its output can be read, an http(s) address. |
Example request
Section titled “Example request”curl -X POST https://api.g1t.sh/repos/flagon-io/g1t/deployments \ -H "Authorization: Bearer $G1T_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "ref": "main", "environment": "staging", "description": "Deployed by the release pipeline", "payload": { "pipeline": 4182, "region": "us-east" }, "state": "in_progress", "log_url": "https://ci.example.com/pipelines/4182" }'Example response
Section titled “Example response”A successful request answers 200 with:
{ "id": "dep_01kq7z9a1c3e5g7j9m1p3r5t7v", "environment": "staging", "ref": "main", "sha": "4b8d0f2a6c1e3579bd02468ace13579bdf02468a", "task": "deploy", "description": "Deployed by the release pipeline", "payload": { "pipeline": 4182, "region": "us-east" }, "transient_environment": false, "production_environment": false, "state": "in_progress", "environment_url": null, "log_url": "https://ci.example.com/pipelines/4182", "creator": "flagon-io", "source": "api", "run_id": null, "run_url": null, "project": null, "number": null, "created_at": "2026-10-06T21:40:03.512Z", "updated_at": "2026-10-06T21:40:03.512Z", "statuses": [ { "id": "dst_01kq7z9a1d4f6h8k0m2p4r6t8v", "deployment_id": "dep_01kq7z9a1c3e5g7j9m1p3r5t7v", "state": "in_progress", "description": "Deployed by the release pipeline", "environment_url": null, "log_url": "https://ci.example.com/pipelines/4182", "creator": "flagon-io", "created_at": "2026-10-06T21:40:03.512Z" } ]}Errors
Section titled “Errors”A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See errors.
| Status | Code | When |
|---|---|---|
| 401 | unauthenticated |
A token is required, or the one sent is not valid. |
| 403 | forbidden |
The token is valid but not allowed to do this, such as a member-only change or an agent token outside its repository. |
| 404 | not_found |
It does not exist, or you cannot see it. |
| 409 | conflict |
The request conflicts with the current state. |
| 422 | invalid |
The input is not valid. message says which field and why. |