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

# Update environment

> Rename an environment, change its start URL, flip its production flag, or set the mobile build it launches by default, as Settings → Applications & Envs does.

Only the fields you pass change. `url` applies to web and API applications; `applicationBuildShortId` and `otherApplicationBuildShortIds` apply to mobile applications. GitHub App runs, scheduled runs, chats, and runs without a build override use the environment's build, so call this after `create_application_build` on merges to your default branch to track the latest merged code.



## OpenAPI

````yaml /api-reference/api.json patch /v1/applications/{applicationShortId}/environments/{environmentShortId}
openapi: 3.0.0
info:
  title: QA.tech API
  version: 1.0.0
  contact:
    name: QA.tech
    url: https://qa.tech
    email: support@qa.tech
  description: API for triggering and managing AI-powered test runs
servers:
  - url: https://api.qa.tech
    description: Production
    variables: {}
security:
  - BearerAuth: []
tags:
  - name: Runs
  - name: Infrastructure
  - name: Test Cases
  - name: Application Builds
  - name: Status badge
  - name: Remote Tunnels
  - name: Chat
  - name: Applications
  - name: Features
  - name: Metrics
  - name: Projects
  - name: Knowledge
  - name: Rules
  - name: Configs
  - name: Labels
  - name: Issues
  - name: Todos
  - name: Automations
  - name: Test plans
paths:
  /v1/applications/{applicationShortId}/environments/{environmentShortId}:
    patch:
      tags:
        - Applications
      summary: Update environment
      description: >-
        Rename an environment, change its start URL, flip its production flag,
        or set the mobile build it launches by default, as Settings →
        Applications & Envs does.


        Only the fields you pass change. `url` applies to web and API
        applications; `applicationBuildShortId` and
        `otherApplicationBuildShortIds` apply to mobile applications. GitHub App
        runs, scheduled runs, chats, and runs without a build override use the
        environment's build, so call this after `create_application_build` on
        merges to your default branch to track the latest merged code.
      operationId: UpdateApplicationEnvironment
      parameters:
        - name: applicationShortId
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/ApplicationShortId'
        - name: environmentShortId
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/EnvironmentShortId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateApplicationEnvironmentRequest'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateApplicationEnvironmentResponse'
components:
  schemas:
    ApplicationShortId:
      type: string
      pattern: ^app(-.+_.+|_.+)$
    EnvironmentShortId:
      type: string
      pattern: ^env(-.+_.+|_.+)$
    UpdateApplicationEnvironmentRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: New environment name, unique within the application.
        url:
          type: string
          format: uri
          description: New public http(s) start URL. Web and API applications only.
        isProduction:
          type: boolean
          description: >-
            Mark the environment as production. The agent avoids destructive
            actions on production.
        applicationBuildShortId:
          allOf:
            - $ref: '#/components/schemas/ApplicationBuildShortId'
          description: >-
            Mobile only. Build to launch by default, from
            `create_application_build` or `GET
            /applications/{applicationShortId}/builds`. It must belong to the
            same application and use the environment's platform.
        otherApplicationBuildShortIds:
          type: array
          items:
            $ref: '#/components/schemas/ApplicationBuildShortId'
          description: >-
            Mobile only, together with `applicationBuildShortId`. Companion apps
            installed next to the primary build, replacing the current list.
            Omit to keep the current list; pass `[]` to clear it. Every build
            must belong to the same application, use the same platform, and have
            a distinct bundle ID. At most 3.
        projectShortId:
          allOf:
            - $ref: '#/components/schemas/ProjectShortId'
          description: >-
            Target a specific project by its prefixed short ID
            (proj-slug_shortId or proj_shortId), as returned by the projects
            API. Required for organization-scoped API keys; project-scoped keys
            may only pass their own project's short ID.
      description: >-
        Fields to change on an environment. Omitted fields keep their current
        value; pass at least one.
    UpdateApplicationEnvironmentResponse:
      type: object
      required:
        - environment
      properties:
        environment:
          $ref: '#/components/schemas/EnvironmentItem'
    ApplicationBuildShortId:
      type: string
      pattern: ^build(-.+_.+|_.+)$
    ProjectShortId:
      type: string
      pattern: ^proj(-.+_.+|_.+)$
    EnvironmentItem:
      type: object
      required:
        - shortId
        - name
        - url
        - isProduction
      properties:
        shortId:
          $ref: '#/components/schemas/EnvironmentShortId'
        name:
          type: string
        url:
          type: string
          nullable: true
        isProduction:
          type: boolean
        applicationBuildShortId:
          allOf:
            - $ref: '#/components/schemas/ApplicationBuildShortId'
          description: >-
            Mobile build the environment launches by default: GitHub App runs,
            scheduled runs, chats and runs without a build override use it.
            Omitted for web and API environments and mobile environments with no
            build.
        otherApplicationBuildShortIds:
          type: array
          items:
            $ref: '#/components/schemas/ApplicationBuildShortId'
          description: Companion mobile apps installed next to the primary build.
        customHeaders:
          type: array
          items:
            $ref: '#/components/schemas/EnvironmentCustomHeaderRule'
          description: >-
            Custom headers applied to matching hosts when tests run against this
            environment.
        basicAuth:
          type: array
          items:
            $ref: '#/components/schemas/EnvironmentBasicAuthRuleSummary'
          description: >-
            Basic auth rules sent to matching hosts when tests run against this
            environment. Passwords are write-only and never returned.
    EnvironmentCustomHeaderRule:
      type: object
      required:
        - domains
        - headers
      properties:
        domains:
          type: array
          items:
            type: string
          description: >-
            Host patterns that receive these headers. `*.preview.example.com`
            matches the apex and any subdomain.
        headers:
          type: object
          additionalProperties:
            type: string
          description: >-
            Header name to value. Applied by the platform on matching requests;
            generated test code cannot read the values.
      description: >-
        Host patterns (`*.preview.example.com` or an exact host) and the headers
        to attach to matching requests. Used for auth, deployment-protection
        bypass, and similar platform access. When provided on an environment
        override, the rules are persisted on the environment.
    EnvironmentBasicAuthRuleSummary:
      type: object
      required:
        - domains
        - username
      properties:
        domains:
          type: array
          items:
            type: string
          description: Host patterns that receive these credentials.
        username:
          type: string
          description: Basic auth username.
      description: >-
        Basic auth rule as returned on reads. The password is write-only and
        never returned.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: Bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.