> ## Documentation Index
> Fetch the complete documentation index at: https://kosli-mbevc1-patch-1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# List environments

> List environments of an organization.



## OpenAPI

````yaml https://app.kosli.com/api/v2/openapi.json get /environments/{org}
openapi: 3.1.0
info:
  title: Kosli API
  summary: The API for communicating with Kosli
  description: >

    # Authentication 


    When making requests against Kosli API, you can authenticate your requests
    using a bearer token. 

    Set the bearer token in the request Authorization header to a valid API
    key. 

    API Keys can be personal or for service accounts. Check the [service
    accounts
    documentation](https://docs.kosli.com/getting_started/service-accounts/) for
    details. 


    ## Curl example


    ```shell

    curl -H "Authorization: Bearer <<your-api-key>>"
    https://app.kosli.com/api/v2/environments/<<your-org-name>>

    ```
  version: '2.0'
servers:
  - url: https://app.kosli.com/api/v2
    description: EU
  - url: https://app.us.kosli.com/api/v2
    description: US
security:
  - HTTPBearer: []
paths:
  /environments/{org}:
    get:
      tags:
        - Environments
      summary: List environments
      description: List environments of an organization.
      operationId: list_envs
      parameters:
        - name: org
          in: path
          required: true
          schema:
            type: string
            title: Org
        - name: page
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
                minimum: 1
              - type: 'null'
            description: Page number
            title: Page
          description: Page number
        - name: per_page
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
                maximum: 50
                minimum: 1
              - type: 'null'
            description: Number of environments per page
            title: Per Page
          description: Number of environments per page
        - name: sort
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/EnvironmentSortField'
            description: Sort field
            default: name
          description: Sort field
        - name: sort_direction
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/SortDirection'
            description: Sort direction
            default: asc
          description: Sort direction
        - name: space_id
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by space ID. Can be repeated for OR semantics, e.g.
              space_id=a&space_id=b
            title: Space Id
          description: >-
            Filter by space ID. Can be repeated for OR semantics, e.g.
            space_id=a&space_id=b
        - name: name
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by name (case-insensitive substring match)
            title: Name
          description: Filter by name (case-insensitive substring match)
        - name: type
          in: query
          required: false
          schema:
            anyOf:
              - type: array
                items:
                  $ref: '#/components/schemas/EnvironmentTypeFilter'
              - type: 'null'
            description: >-
              Filter by environment type. Can be repeated, e.g.
              type=K8S&type=ECS
            title: Type
          description: Filter by environment type. Can be repeated, e.g. type=K8S&type=ECS
        - name: tag
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by tag key or key:value. Can be repeated, e.g. tag=team or
              tag=team:platform
            title: Tag
          description: >-
            Filter by tag key or key:value. Can be repeated, e.g. tag=team or
            tag=team:platform
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/EnvironmentListResponse'
                  - type: array
                    items:
                      $ref: '#/components/schemas/GetEnvironmentResponse'
                title: Response List Envs
      security:
        - HTTPBearer: []
        - HTTPBasic: []
components:
  schemas:
    EnvironmentSortField:
      type: string
      enum:
        - name
        - last_modified_at
        - last_changed_at
      title: EnvironmentSortField
    SortDirection:
      type: string
      enum:
        - asc
        - desc
      title: SortDirection
    EnvironmentTypeFilter:
      type: string
      enum:
        - K8S
        - ECS
        - S3
        - lambda
        - server
        - docker
        - azure-apps
        - cloud-run
        - logical
      title: EnvironmentTypeFilter
    EnvironmentListResponse:
      properties:
        _links:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Links
        page:
          type: integer
          title: Page
        per_page:
          type: integer
          title: Per Page
        total_pages:
          type: integer
          title: Total Pages
        total_count:
          type: integer
          title: Total Count
        environments:
          items:
            $ref: '#/components/schemas/GetEnvironmentResponse'
          type: array
          title: Environments
      additionalProperties: false
      type: object
      required:
        - page
        - per_page
        - total_pages
        - total_count
        - environments
      title: EnvironmentListResponse
    GetEnvironmentResponse:
      properties:
        org:
          type: string
          title: Org
          description: Organization which owns the environment
        name:
          type: string
          title: Name
          description: Name for the environment
        type:
          type: string
          title: Type
          description: Type of the report source infrastructure
        description:
          type: string
          title: Description
          description: Description for the environment
        last_modified_at:
          type: number
          title: Last Modified At
          description: Last report modification timestamp
        last_reported_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Reported At
          description: Last report received timestamp
        last_changed_at:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Changed At
          description: Timestamp of the last change detected in the environment
        state:
          anyOf:
            - type: boolean
            - type: 'null'
          title: State
          description: Compliance state of the environment
        include_scaling:
          type: boolean
          title: Include Scaling
          description: If the environment record scaling events
        tags:
          additionalProperties: true
          type: object
          title: Tags
          description: User-defined tags for the environment
        policies:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Policies
          description: List of attached policies to the environment
        included_environments:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Included Environments
          description: List of included environments for logical environments
      type: object
      required:
        - org
        - name
        - type
        - description
        - last_modified_at
        - include_scaling
        - tags
      title: GetEnvironmentResponse
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````