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

# Update an environment

> Updates an environment by ID. The project is derived from the entity. Returns the bare updated row (no `data` envelope), matching the dashboard settings UI it serves.



## OpenAPI

````yaml /api-reference/openapi.generated.json patch /api/environments/{id}
openapi: 3.1.0
info:
  title: Empirical API
  version: 1.0.0
  description: Programmatic access to Empirical test runs, snoozes, and more.
  contact:
    name: Empirical
    url: https://empirical.run
servers:
  - url: https://api.empirical.run
security:
  - Bearer: []
tags:
  - name: Analytics
    description: Aggregated test-run, test-count and test-case analytics for a project.
  - name: Analytics (Deprecated)
    description: >-
      Legacy analytics endpoints retained for backwards compatibility; prefer
      the v2 equivalents.
  - name: Environments
    description: >-
      Named deployment targets (slug + Playwright project filters) a project's
      tests run against.
  - name: Snoozes
    description: Temporarily suppress known test failures for specific Playwright tests.
  - name: Telemetry
    description: Product telemetry derived from analytics events, scoped to a project.
  - name: Test Cases
    description: >-
      Browse the Playwright test cases synced from a project's repository and
      manage their tags.
paths:
  /api/environments/{id}:
    patch:
      tags:
        - Environments
      summary: Update an environment
      description: >-
        Updates an environment by ID. The project is derived from the entity.
        Returns the bare updated row (no `data` envelope), matching the
        dashboard settings UI it serves.
      operationId: updateEnvironment
      parameters:
        - schema:
            type: integer
            minimum: 1
            description: Environment ID.
          required: true
          description: Environment ID.
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateEnvironmentRequest'
      responses:
        '200':
          description: The updated environment row (no `data` envelope).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Environment'
        '400':
          description: Invalid request, or the slug already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentMutationError'
        '403':
          description: Environment is in an environments.yaml-managed project.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentMutationError'
        '404':
          description: Environment not found or not accessible.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentMutationError'
components:
  schemas:
    UpdateEnvironmentRequest:
      type: object
      properties:
        name:
          type: string
          description: Display name.
        slug:
          type: string
          description: URL-friendly identifier.
        is_disabled:
          type: boolean
          description: Whether the environment is disabled.
        playwright_projects_match:
          type: array
          items:
            type: string
          description: Playwright project names to include. Items must not start with '!'.
        playwright_projects_ignore:
          type: array
          items:
            type: string
          description: Playwright project names to exclude.
        scheduled_trigger:
          type: string
          nullable: true
          description: Cron expression for scheduled triggers, or null.
    Environment:
      type: object
      properties:
        id:
          type: number
          description: Unique identifier.
        project_id:
          type: number
          description: Project identifier.
        slug:
          type: string
          description: URL-friendly identifier.
        name:
          type: string
          description: Display name.
        playwright_projects_match:
          type: array
          items:
            type: string
          description: Playwright project names to match.
        playwright_projects_ignore:
          type: array
          items:
            type: string
          description: Playwright project names to ignore.
        is_disabled:
          type: boolean
          nullable: true
          description: Whether the environment is disabled.
        env_files:
          type: array
          items:
            type: string
          description: Environment file paths.
        scheduled_trigger:
          type: string
          nullable: true
          description: Cron expression for scheduled triggers.
        created_at:
          type: string
          nullable: true
          description: ISO 8601 timestamp.
        updated_at:
          type: string
          nullable: true
          description: ISO 8601 timestamp.
      required:
        - id
        - project_id
        - slug
        - name
        - playwright_projects_match
        - playwright_projects_ignore
        - is_disabled
        - env_files
        - scheduled_trigger
        - created_at
        - updated_at
    EnvironmentMutationError:
      type: object
      properties:
        error:
          anyOf:
            - type: string
            - type: object
              properties:
                message:
                  type: string
                  description: Error message.
              required:
                - message
          description: >-
            Error, returned as a bare string or a `{ message }` object (legacy
            shape).
      required:
        - error
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````