> ## 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.

# Create environment

> Add an environment (for example staging or production) to a web or API application.

An unarchived environment with the same name on the application is returned unchanged (`created: false`), so repeating the request does not create a duplicate. Mobile applications are not supported here.



## OpenAPI

````yaml /api-reference/api.json post /v1/applications/{applicationShortId}/environments
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: Labels
  - name: Issues
  - name: Todos
  - name: Automations
  - name: Test plans
paths:
  /v1/applications/{applicationShortId}/environments:
    post:
      tags:
        - Applications
      summary: Create environment
      description: >-
        Add an environment (for example staging or production) to a web or API
        application.


        An unarchived environment with the same name on the application is
        returned unchanged (`created: false`), so repeating the request does not
        create a duplicate. Mobile applications are not supported here.
      operationId: CreateEnvironment
      parameters:
        - name: applicationShortId
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/ApplicationShortId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEnvironmentRequest'
      responses:
        '200':
          description: The request has succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateEnvironmentResponse'
components:
  schemas:
    ApplicationShortId:
      type: string
      pattern: ^app(-.+_.+|_.+)$
    CreateEnvironmentRequest:
      type: object
      required:
        - name
        - url
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Environment name, unique within the application.
        url:
          type: string
          format: uri
          description: Public http(s) start URL.
        isProduction:
          type: boolean
          description: >-
            Mark the environment as production. Defaults to false. The agent
            avoids destructive actions on production.
        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: >-
        Add an environment to a web or API application, e.g. staging next to
        production.
    CreateEnvironmentResponse:
      type: object
      required:
        - created
        - environment
      properties:
        created:
          type: boolean
          description: >-
            False when an unarchived environment with this name already existed
            and was returned unchanged.
        environment:
          $ref: '#/components/schemas/EnvironmentItem'
    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.
    EnvironmentShortId:
      type: string
      pattern: ^env(-.+_.+|_.+)$
    ApplicationBuildShortId:
      type: string
      pattern: ^build(-.+_.+|_.+)$
    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.