---
type: api
title: Get environments for service
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-getenvironmentsforservice
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-getenvironmentsforservice
products:
  - Kibana
---

# Get environments for service

- Server: `https://{kibana_url}`

## Paths

- `GET` `/api/apm/settings/agent-configuration/environments`
- `GET` `/s/{space_id}/api/apm/settings/agent-configuration/environments`

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Query string parameters

- `serviceName` (string) — optional
  The name of the service

## Header parameters

- `elastic-api-version` (enum · default: 2023-10-31) — required
  The version of the API to use
  Values: `2023-10-31`

## Responses

#### `200`

Successful response

`application/json`

- `environments` (object[])
  Service environment list
  - `alreadyConfigured` (boolean)
    Already configured
  - `name` (string)
    Service environment name
#### `400`

Bad Request response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
#### `401`

Unauthorized response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
#### `404`

Not found response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
## Code examples

#### Console

```console
GET kbn:/api/apm/settings/agent-configuration/environments
```

#### curl

```curl
curl -X GET "${KIBANA_URL}/api/apm/settings/agent-configuration/environments" \
  -H "elastic-api-version: 2023-10-31" \
  -H "Authorization: ApiKey ${API_KEY}"
```

