> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Environments by Project

> Retrieves all environments accessible from a specific project. This endpoint returns environments where the user has access through project membership.

## Endpoint

```
GET /apiops/projects/{projectName}/environments/
```

## Authentication

Requires a Personal API Access Token.

### Header

```
Authorization: Bearer YOUR_TOKEN
```

## Request

### Headers

| Header        | Value          | Required |
| ------------- | -------------- | -------- |
| Authorization | Bearer {token} | Yes      |

### Path Parameters

| Parameter   | Type   | Required | Description  |
| ----------- | ------ | -------- | ------------ |
| projectName | string | Yes      | Project name |

### Query Parameters

None.

## Response

### Success Response (200 OK)

```json theme={null}
{
  "success": true,
  "resultList": [
    {
      "id": "60a7b1c2d3e4f5g6h7i8j9k0",
      "name": "production",
      "description": "Production environment",
      "type": "PRODUCTION",
      "accessUrl": "https://gw.example.com",
      "status": "PUBLISHED",
      "deployed": null,
      "redeployRequired": null
    },
    {
      "id": "60a7b1c2d3e4f5g6h7i8j9k1",
      "name": "staging",
      "description": "Staging environment",
      "type": "SANDBOX",
      "accessUrl": "https://gw-staging.example.com",
      "status": "PUBLISHED",
      "deployed": null,
      "redeployRequired": null
    }
  ],
  "resultCount": 2
}
```

### Response Fields

| Field       | Type           | Description                                      |
| ----------- | -------------- | ------------------------------------------------ |
| success     | boolean        | Indicates if the request was successful          |
| resultList  | array\[object] | List of environments accessible from the project |
| resultCount | integer        | Total number of environments                     |

### Environment Object

| Field            | Type    | Description                                                                     |
| ---------------- | ------- | ------------------------------------------------------------------------------- |
| id               | string  | Environment unique identifier                                                   |
| name             | string  | Environment name                                                                |
| description      | string  | Environment description (optional)                                              |
| type             | string  | Environment type. See EnumEnvironmentType                                       |
| accessUrl        | string  | Gateway access URL for this environment                                         |
| status           | string  | Publish status. See EnumPublishStatus                                           |
| deployed         | boolean | Whether the environment is deployed (only populated in API Proxy/Group context) |
| redeployRequired | boolean | Whether redeployment is required (only populated in API Proxy/Group context)    |

### EnumEnvironmentType

* `PRODUCTION` - Production environment
* `SANDBOX` - Sandbox/staging environment
* `TEST` - Test environment

### EnumPublishStatus

* `PUBLISHED` - Environment is published and active
* `UNPUBLISHED` - Environment is not published
* `REPUBLISH_REQUIRED` - Environment needs to be republished due to configuration changes

### Error Response (400 Bad Request)

```json theme={null}
{
  "error": "bad_request",
  "error_description": "Project not found"
}
```

### Error Response (401 Unauthorized)

```json theme={null}
{
  "error": "unauthorized",
  "error_description": "Invalid or expired token"
}
```

### Error Response (403 Forbidden)

```json theme={null}
{
  "error": "forbidden",
  "error_description": "User does not have access to this project"
}
```

## cURL Example

```bash theme={null}
curl -X GET \
  "https://demo.apinizer.com/apiops/projects/MyProject/environments/" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## Permissions

* User must have **any permission** in the project (read access)

## Notes and Warnings

* **Project Membership**: User must be a member of the project to access environments
* **Returns only environments accessible through project membership**
* **Project Access**: If user doesn't have access to the project, returns 403 Forbidden

## Related Documentation

* [List Environments](/api-reference/environments/list-environments) - Get all environments (admin only)
* [Projects API](/api-reference/projects/list-projects.mdx) - Project management endpoints
* [Authentication Guide](/api-reference/getting-started/authentication) - How to obtain and use API tokens
