Skip to content

List the environments a repository's deployments went to, those people use directly first (production by name before others), then the most recently deployed, and after them those with protection rules but no deployment yet.

GET/repos/{owner}/{name}/environments

Each has its name, url (where its current deployment is served), production_environment, transient_environment, deployments_count, latest (its newest deployment, whatever its state), current (its newest successful deployment that is still active) and updated_at, and, when it has rules, protection_rules (required_reviewers, wait_timer, branch_policy), deployment_branch_policy, branch_policies and can_admins_bypass. total_count counts deployments across every environment. Needs the Read role.

Production comes first, then the most recently deployed. latest is the newest deployment whatever its state; current is the newest that succeeded and is still active, and url is where it is served.

  • Authentication: Optional. Public data can be read without a token; send one to see what is private.
  • MCP tool: workflow with action list_environments, and the same inputs
  • Scope: An access token needs deployments:read.
Name Type Required Description
owner string Yes The workspace that owns the repository.
name string Yes The repository’s name.
curl https://api.g1t.sh/repos/flagon-io/g1t/environments \
-H "Authorization: Bearer $G1T_TOKEN"

A successful request answers 200 with:

{
"total_count": 304,
"environments": [
{
"name": "production",
"url": "https://g1t.sh",
"production_environment": true,
"transient_environment": false,
"deployments_count": 281,
"latest": {
"id": "dep_01kq8m3t5v7x9z1b3d5f7h9k2m",
"environment": "production",
"ref": "main",
"sha": "7c1e9a4b2d6f80135ac9e2b7d4f6a8c0e1b3d5f7",
"task": "deploy",
"description": "Deploy",
"payload": {},
"transient_environment": false,
"production_environment": true,
"state": "success",
"environment_url": "https://g1t.sh",
"log_url": "https://g1t.sh/flagon-io/g1t/actions/runs/run_01kq8m2r4t6v8x0z2b4d6f8h0k",
"creator": "syntaqx",
"source": "actions",
"run_id": "run_01kq8m2r4t6v8x0z2b4d6f8h0k",
"run_url": "https://g1t.sh/flagon-io/g1t/actions/runs/run_01kq8m2r4t6v8x0z2b4d6f8h0k",
"project": null,
"number": null,
"created_at": "2026-10-07T18:02:11.204Z",
"updated_at": "2026-10-07T18:19:47.881Z"
},
"current": {
"id": "dep_01kq8m3t5v7x9z1b3d5f7h9k2m",
"environment": "production",
"ref": "main",
"sha": "7c1e9a4b2d6f80135ac9e2b7d4f6a8c0e1b3d5f7",
"task": "deploy",
"description": "Deploy",
"payload": {},
"transient_environment": false,
"production_environment": true,
"state": "success",
"environment_url": "https://g1t.sh",
"log_url": "https://g1t.sh/flagon-io/g1t/actions/runs/run_01kq8m2r4t6v8x0z2b4d6f8h0k",
"creator": "syntaqx",
"source": "actions",
"run_id": "run_01kq8m2r4t6v8x0z2b4d6f8h0k",
"run_url": "https://g1t.sh/flagon-io/g1t/actions/runs/run_01kq8m2r4t6v8x0z2b4d6f8h0k",
"project": null,
"number": null,
"created_at": "2026-10-07T18:02:11.204Z",
"updated_at": "2026-10-07T18:19:47.881Z"
},
"updated_at": "2026-10-07T18:19:47.881Z"
},
{
"name": "staging",
"url": null,
"production_environment": false,
"transient_environment": false,
"deployments_count": 19,
"latest": {
"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": "failure",
"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:44:58.020Z"
},
"current": null,
"updated_at": "2026-10-06T21:44:58.020Z"
}
]
}

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.
422 invalid The input is not valid. message says which field and why.