# Get an environment

> Get one environment by name, matched without regard to case, with its current and latest deployments and its protection rules (see update_environment).

<div class="g1t-endpoint"><span class="g1t-method" data-method="get">GET</span><code>/repos/{owner}/{name}/environments/{environment}</code></div>

An environment with rules but no deployment yet is found too. A name with slashes is URL-encoded in the path. Needs the Read role.

- **Authentication:** Optional. Public data can be read without a token; send one to see what is private.
- **MCP tool:** [`workflow`](/reference/mcp/#workflow) with `action` `get_environment`, and the same inputs
- **Scope:** An access token needs [`deployments:read`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | The workspace that owns the repository. |
| `name` | string | Yes | The repository's name. |
| `environment` | string | Yes | The environment's name, such as production. |

## Example request

```sh
curl https://api.g1t.sh/repos/flagon-io/docs/environments/preview \
  -H "Authorization: Bearer $G1T_TOKEN"
```

## Example response

A successful request answers `200` with:

```json
{
  "name": "preview",
  "url": "https://docs-git-docs-deployments-flagon-io.g1t.page",
  "production_environment": false,
  "transient_environment": true,
  "deployments_count": 87,
  "latest": {
    "id": "dpl_01kq8p2b4d6f8h0k2m4p6r8t0v",
    "environment": "preview",
    "ref": "docs-deployments",
    "sha": "e2f4a6c8b0d1e3f5a7c9b1d3e5f7a9c1b3d5e7f9",
    "task": "deploy",
    "description": "Preview of docs-deployments on g1t.page",
    "payload": {},
    "transient_environment": true,
    "production_environment": false,
    "state": "success",
    "environment_url": "https://docs-git-docs-deployments-flagon-io.g1t.page",
    "log_url": "https://g1t.sh/flagon-io/docs/deployments/dpl_01kq8p2b4d6f8h0k2m4p6r8t0v",
    "creator": "syntaqx",
    "source": "g1t_page",
    "run_id": null,
    "run_url": null,
    "project": "docs",
    "number": 412,
    "created_at": "2026-10-08T01:12:44.630Z",
    "updated_at": "2026-10-08T01:13:52.101Z"
  },
  "current": {
    "id": "dpl_01kq8p2b4d6f8h0k2m4p6r8t0v",
    "environment": "preview",
    "ref": "docs-deployments",
    "sha": "e2f4a6c8b0d1e3f5a7c9b1d3e5f7a9c1b3d5e7f9",
    "task": "deploy",
    "description": "Preview of docs-deployments on g1t.page",
    "payload": {},
    "transient_environment": true,
    "production_environment": false,
    "state": "success",
    "environment_url": "https://docs-git-docs-deployments-flagon-io.g1t.page",
    "log_url": "https://g1t.sh/flagon-io/docs/deployments/dpl_01kq8p2b4d6f8h0k2m4p6r8t0v",
    "creator": "syntaqx",
    "source": "g1t_page",
    "run_id": null,
    "run_url": null,
    "project": "docs",
    "number": 412,
    "created_at": "2026-10-08T01:12:44.630Z",
    "updated_at": "2026-10-08T01:13:52.101Z"
  },
  "updated_at": "2026-10-08T01:13:52.101Z"
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#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. |
