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

# Applications & Environments

> Set up applications and environments to organize your tests and run them against different deployments

Applications and environments are the two core building blocks inside a [project](https://docs.qa.tech/core-concepts/projects.md). The hierarchy, when to create a project, and the decision guide are on [Projects](https://docs.qa.tech/core-concepts/projects.md).

## Applications

**Applications** represent distinct apps or services you want to test. **Test cases belong to applications** - each test is associated with one application.

Use separate applications when they have their own set of tests that won't run in other applications. For example:

* Customer-facing app vs admin panel (different test suites)
* Web app vs mobile app (different user flows)
* Frontend vs API (different execution models and assertions)
* Frontend vs backoffice (different functionality to test)

### Application Types

Choose the application type based on what the test agent needs to interact with:

| Application type | Use it to test | Execution |
| - | - | - |
| **Web application** | Websites and browser-based applications | Browser |
| **Mobile application** | iOS and Android applications | Mobile device |
| **API application** | REST and HTTP APIs | Isolated code execution sandbox |

API applications use a dedicated agent that makes HTTP requests and executes validation code without opening a browser. See [API Testing](https://docs.qa.tech/core-concepts/api-testing) for the execution model and [Creating API Tests](https://docs.qa.tech/best-practices/creating-api-tests.md) for setup.

## Environments

**Environments** represent different configurations of the same application - typically different URLs for the same app.

Use environments when you want to run the same tests against the same application in different stages or markets. For example:

* Same app, different deployments (dev, staging, production)
* Same app, different markets (/en, /de, /se)
* Same app, different preview deployments (PR branches)

**Key benefit:** Tests written for an application can run on any of its environments without modification.

For mobile applications, an environment selects a primary app build and can also pin up to three **other app** builds installed on the same device. Use other apps for companion or helper packages that participate in the primary app's tests. If another app needs its own test suite, model it as a separate Application instead.

### Maximum Concurrent Tests

Each environment can limit how many test cases run in parallel against that environment's URL. Leaving **Maximum Concurrent Tests** empty allows unlimited parallel runs for that environment. A positive number limits parallel tests to that value, with additional tests waiting in queue.

When a run uses multiple environments, the **lowest** configured limit applies.

See [Parallel Tests](https://docs.qa.tech/core-concepts/parallel-test-execution.md) for how to configure this in the dashboard and when to use limits.

### Production Environment Toggle

When creating or editing an environment, you can mark it as a production environment using the "Production Environment" toggle. Currently, this setting is used for data collection to understand how many customers run tests against production environments. In the future, we may add additional safety checks to help prevent breaking production environments (such as avoiding overload or more intensive security testing).

### Custom headers

Environment custom headers attach HTTP headers to matching hosts when tests run against that environment. Use them for **authentication, deployment protection bypass, and similar platform access** (for example Vercel Protection Bypass or a Cloudflare WAF allowlist header).

Each rule lists:

* **Domains** - host patterns such as `*.preview.example.com` (matches the apex and any subdomain) or an exact host like `api.example.com`
* **Headers** - name/value pairs the platform injects on matching requests

Browser tests, the crawler, and API sandbox tests all apply these rules. Header values are stored on the environment and are not shown again in the dashboard after save.

Set headers in **Settings → Applications & Envs → \[application] → Edit environment**. Those headers apply when a run targets that environment.

Pull request previews get their own rows. Set **Preview defaults** on the same application, under **Preview Environments**, and QA.tech copies them onto each new preview. See [Vercel preview protection](https://docs.qa.tech/configuration/vercel-preview-protection.md).

Persist headers when you create or reuse an environment from CI. Passing `customHeaders` always writes them to that environment and replaces the preview-default headers for that preview. Omit the field to leave stored headers unchanged. Pass `[]` to clear them.

> [tab] GitHub Actions
>
> Pass `customHeaders` on the environment in `applications_config`. The Test Run Action keys the `applications` map by application short ID:
>
> ```yaml theme={null}
> - uses: QAdottech/run-action@v4
>   with:
>     project_short_id: 'proj_abc123'
>     api_token: ${{ secrets.QATECH_API_TOKEN }}
>     test_plan_short_id: 'pln_abc123'
>     applications_config: |
>       {
>         "applications": {
>           "app_abc123": {
>             "environment": {
>               "url": "https://pr-123.vercel.app",
>               "name": "PR-123",
>               "customHeaders": [
>                 {
>                   "domains": ["*.vercel.app"],
>                   "headers": {
>                     "x-vercel-protection-bypass": "${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}",
>                     "x-vercel-set-bypass-cookie": "true"
>                   }
>                 }
>               ]
>             }
>           }
>         }
>       }
> ```
>
> The same `customHeaders` field works with `environment.shortId` or `environment.applicationBuildShortId`. See [GitHub regression testing](https://docs.qa.tech/regression-testing/github.md#persist-environment-custom-headers).

> [tab] Start Run API
>
> The REST body uses an `applications` array (not a map). `POST /v1/run`:
>
> ```bash theme={null}
> curl -X POST https://api.qa.tech/v1/run \
>   -H "Authorization: Bearer YOUR_API_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "testPlanShortId": "pln_abc123",
>     "applications": [
>       {
>         "applicationShortId": "app_abc123",
>         "environment": {
>           "url": "https://pr-123.vercel.app",
>           "name": "PR-123",
>           "customHeaders": [
>             {
>               "domains": ["*.vercel.app"],
>               "headers": {
>                 "x-vercel-protection-bypass": "YOUR_SECRET",
>                 "x-vercel-set-bypass-cookie": "true"
>               }
>             }
>           ]
>         }
>       }
>     ]
>   }'
> ```
>
> See [Start Test Run](https://docs.qa.tech/api-reference/runs/start-test-run.md) for the full request schema.

For headers that belong to a **test scenario** (locale, feature flags, a one-off `Authorization` for a specific suite), use [device preset custom headers](https://docs.qa.tech/test-features/device-presets.md#custom-headers) instead. Environment headers win when both match the same request.

### Basic auth

Environment basic auth sends HTTP Basic Authentication credentials (the browser username/password popup) to matching hosts only. Use it when a staging site or preview deployment sits behind basic auth, especially when:

* Only some domains need credentials, for example `*.staging.example.com` but not your auth provider or CDN
* Different hosts need different credentials
* Every pull request preview needs the same credentials

Each rule lists:

* **Domains** - host patterns such as `*.preview.example.com` (matches the apex and any subdomain) or an exact host like `staging.example.com`
* **Username** and **Password** - the credentials sent to matching hosts. Usernames cannot contain `:`.

Requests to hosts that match no rule get no credentials. When several rules match the same host, the last one wins.

Set basic auth in **Settings → Applications & Envs → \[application] → Edit environment → Basic auth**. Saved passwords are never sent back to the dashboard: the field shows a stored-password placeholder, leaving it blank keeps the saved password, and typing a new one replaces it. For pull request previews, set it under **Preview defaults** on the Preview Environments card and QA.tech copies it onto each new preview.

Browser tests, the crawler, and API sandbox tests all apply these rules:

* **Browser tests** send credentials on page loads (including iframes), same-origin requests, and cross-origin images, scripts, and stylesheets on matching hosts. Cross-origin `fetch`/XHR calls from the page do not get credentials, the same as in a real browser, so they never trigger an extra CORS preflight.
* **Your app's own `Authorization` header** - when the page sets `Authorization` itself, for example a `Bearer` token on API calls after sign-in, browser tests keep it and do not replace it with basic auth credentials, the same as in a real browser.
* **Redirects** - if a page redirects from another host into a matching host and that host answers `401`, QA.tech reloads the target URL once with the credentials.
* **Crawler and API tests** send an `Authorization: Basic ...` header to matching hosts.
* **Network logs** show the `Authorization` header as `[REDACTED]`.

**Precedence:** on a matching host, environment basic auth wins over the [config "Use for Basic Auth" checkbox](https://docs.qa.tech/core-concepts/configs.md#when-to-enable-basic-auth) and over an `Authorization` header from environment custom headers or a device preset. Hosts that match no rule keep using the config checkbox, so existing configs keep working.

> [!WARNING]
>
> Basic auth uses the `Authorization` header. On a matching host it replaces an
> `Authorization: Bearer ...` token your app sends on same-origin requests. The
> config checkbox behaves the same way. Keep domain patterns narrow (for example
> the web host, not your API host) if your app relies on bearer tokens.

From CI or the API, pass `basicAuth` on the environment next to `customHeaders`. The semantics match `customHeaders`: omit the field to leave stored rules unchanged, pass `[]` to clear them, or pass a list to replace them. On a new preview, an explicit `basicAuth` replaces the preview-default basic auth for that preview.

Passwords are write-only over the API: [List Application Environments](https://docs.qa.tech/api-reference/applications/list-application-environments.md) returns each rule's domains and username, never the password.

> [tab] GitHub Actions
>
> ```yaml theme={null}
> - uses: QAdottech/run-action@v4
>   with:
>     project_short_id: 'proj_abc123'
>     api_token: ${{ secrets.QATECH_API_TOKEN }}
>     test_plan_short_id: 'pln_abc123'
>     applications_config: |
>       {
>         "applications": {
>           "app_abc123": {
>             "environment": {
>               "url": "https://pr-123.preview.example.com",
>               "name": "PR-123",
>               "basicAuth": [
>                 {
>                   "domains": ["*.preview.example.com"],
>                   "username": "preview",
>                   "password": "${{ secrets.PREVIEW_BASIC_AUTH_PASSWORD }}"
>                 }
>               ]
>             }
>           }
>         }
>       }
> ```

> [tab] Start Run API
>
> ```bash theme={null}
> curl -X POST https://api.qa.tech/v1/run \
>   -H "Authorization: Bearer YOUR_API_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "testPlanShortId": "pln_abc123",
>     "applications": [
>       {
>         "applicationShortId": "app_abc123",
>         "environment": {
>           "url": "https://pr-123.preview.example.com",
>           "name": "PR-123",
>           "basicAuth": [
>             {
>               "domains": ["*.preview.example.com"],
>               "username": "preview",
>               "password": "YOUR_PASSWORD"
>             }
>           ]
>         }
>       }
>     ]
>   }'
> ```

You can also ask the [AI chat assistant](https://docs.qa.tech/core-concepts/ai-chat-assistant.md) to set basic auth or custom headers on an environment or on preview defaults. It only ever shows domains, header names, and usernames back, never the stored secrets.

## Common Patterns

### Staging vs Production

**Use case:** Test the same functionality against staging and production environments.

**Structure:** One application with multiple environments.

**Example:**

```
Project: E-commerce Platform
└── Application: Storefront
    ├── Environment: Staging (staging.store.com)
    └── Environment: Production (store.com)
```

**Benefits:** Write tests once, run against both environments. Use test plans to select which environment to test.

### Multi-Market/Storefronts

**Use case:** Test functionality across different markets or storefronts.

**Decision factor:** Will the same tests run in both markets? If yes, use environments. If the markets have different features or user flows requiring different test suites, use separate applications.

**Example with environments (same tests, different markets):**

```
Project: Global Store
└── Application: Storefront
    ├── Environment: Sweden (store.com/se)
    ├── Environment: Germany (store.com/de)
    └── Environment: US (store.com/us)
```

Same checkout flow, same product catalog - just different markets. The same tests run in all environments.

**Example with applications (different test suites):**

```
Project: Multi-Brand Platform
├── Application: Germany Storefront
└── Application: Sweden Storefront
```

Different brands with different features, product catalogs, or checkout flows. Each requires its own set of tests.

### Multi-App Flows

**Use case:** Test flows that span multiple applications (e.g., create order in frontend, verify in admin panel).

**Structure:** Multiple applications with test dependencies.

**Example:**

```
Project: E-commerce Platform
├── Application: Customer Frontend
│   └── Environment: Production
└── Application: Admin Panel
    └── Environment: Production
```

**Important:** Browser state (sessions, cookies) doesn't transfer across different domains. When testing across applications with different domains (e.g., `customer.example.com` and `admin.example.com`), use [Wait For dependencies](https://docs.qa.tech/core-concepts/dependencies.md#application-environment-and-domain-constraints) to pass data between tests. Resume From dependencies can work across applications, but only if they're in the same Environment and share the same domain.

### Third-Party Integrations

**Use case:** Test end-to-end flows that require interacting with both your application and a third-party service's web interface in the same test flow.

**When to use this pattern:** Some integrations require your tests to interact with external services that have their own web UIs. For example:

* **OAuth flows:** Your app redirects to Google/Microsoft for authentication, then redirects back
* **Payment providers:** Checkout redirects to Stripe/PayPal payment pages, then returns to your app
* **Admin panels:** You need to configure settings in a third-party admin panel (e.g., HubSpot, Salesforce) before testing your app's integration

Choose based on what determines the test result:

| Need | Use |
| - | - |
| Validate your API's behavior directly | [API application](https://docs.qa.tech/core-concepts/api-testing) |
| Make an individual HTTP request during a web or mobile test | [API Call Configuration](https://docs.qa.tech/test-features/api-calls.md) |
| Interact with a third party's web interface | Separate web application |

**Why separate applications:** When your test flow requires interacting with UIs on different domains (your app and the third-party service), you need separate applications because:

* Each application represents a different domain/URL that the browser navigates to
* Browser state (cookies, sessions) doesn't transfer across different domains
* You can configure separate login credentials and test data for each domain
* The test can navigate between your app and the third-party service's UI in a single flow

**Example:**

```
Project: E-commerce Platform
├── Application: Customer Storefront
│   └── Environment: Production (store.example.com)
└── Application: Payment Provider Admin
    └── Environment: Production (dashboard.stripe.com)
```

**Test flow example:**

1. **Test in Payment Provider Admin:** "Configure test payment method" (sets up test data in Stripe dashboard)
2. **Test in Customer Storefront:** "Complete checkout with Stripe" (uses the configured payment method, redirects to Stripe, completes payment, returns to your app)

**Strategy:**

* Create login tests for each application (your app and the third-party service)
* Use [Wait For dependencies](https://docs.qa.tech/core-concepts/dependencies.md#application-environment-and-domain-constraints) to ensure the third-party configuration completes before testing your app's integration
* Each test starts with fresh browser state on its target domain (browser state doesn't transfer across domains)

Tests can be reused across different applications in the same project. You can create dependencies between tests in different applications using [Wait For dependencies](https://docs.qa.tech/core-concepts/dependencies.md#application-environment-and-domain-constraints), which pass output data (like user IDs or resource names) between tests.

Browser state (login sessions, cookies) can be shared via Resume From dependencies across applications, but only when both tests use the same Environment. See [Test Dependencies](https://docs.qa.tech/core-concepts/dependencies.md#application-environment-and-domain-constraints) for details on cross-application testing patterns.

## Preview Environments

Preview environments are temporary environments automatically created when you trigger test runs with dynamic URLs via the API. They're perfect for testing pull request deployments, feature branches, and ephemeral CI/CD-created environments.

Preview environments are **automatically created** when you call the [Start Run API](https://docs.qa.tech/api-reference/runs/start-test-run.md) with a URL override in the `applications` parameter:

```json theme={null}
{
  "testPlanShortId": "pln_abc123",
  "applications": [
    {
      "applicationShortId": "app_abc123",
      "environment": {
        "url": "https://pr-123-frontend.vercel.app",
        "name": "PR-123-Frontend",
        "customHeaders": [
          {
            "domains": ["*.vercel.app"],
            "headers": {
              "x-vercel-protection-bypass": "YOUR_SECRET",
              "x-vercel-set-bypass-cookie": "true"
            }
          }
        ]
      }
    }
  ]
}
```

When QA.tech receives this request:

1. It creates a preview environment with `is_preview: true`
2. Associates it with branch/PR metadata (if provided)
3. Runs your tests against the preview URL
4. The preview environment appears in your application settings

You do not create preview environments manually. CI, the GitHub App, and GitLab create them. **Preview defaults** on the Preview Environments card (access headers, basic auth, and maximum concurrent tests) are copied onto each new preview. Pass `customHeaders` or `basicAuth` in the request to replace that setting for the preview. Omit them on create to use the preview defaults.

### Viewing and Managing Preview Environments

Preview environments appear in **Settings → Applications & Envs → \[Select Application] → Preview Environments** card.

**Available actions:**

* **Promote to Custom Environment** - Convert a preview environment to a permanent custom environment
* **Delete** - Remove the preview environment (recommended after PRs are merged or branches are deleted)

Preview environments are automatically associated with branch/PR information when created via GitHub Actions or GitLab CI with proper trigger data.

### CI/CD Integration

Preview environments work seamlessly with CI/CD pipelines:

* **[GitHub regression testing](https://docs.qa.tech/regression-testing/github.md)** - Pass preview URLs between jobs
* **[GitHub Deployments](https://docs.qa.tech/configuration/github-deployments.md)** - Create GitHub deployment records so the GitHub App can find preview URLs
* **[GitLab CI](https://docs.qa.tech/configuration/gitlab.md)** - Use dotenv artifacts to pass preview URLs
* **Any CI/CD platform** - Use the Start Run API with `applications[].environment.url`

For per-CI examples, see [PR Testing](https://docs.qa.tech/pr-testing/overview.md#pick-your-ci) and [Regression Testing](https://docs.qa.tech/regression-testing/overview.md#pick-your-ci).

## Test Plans & API Configuration

Test plans allow you to configure which environment and device preset to use per application when running tests. This lets you run the same test cases against different environments (e.g., staging vs production) or with different device configurations (e.g., mobile vs desktop) by selecting different test plans.

**How it works:** When you create a test plan, you can configure application-specific settings that determine which environment URL and device preset to use for each application's tests. These settings are applied whenever the test plan runs, whether triggered manually, via API, or on a schedule. See [Test Plans](https://docs.qa.tech/core-concepts/test-plans.md) for details on creating and configuring test plans.

### Environment Selection

**In Test Plan UI:** Select which environment to use for each application.

**Via API:** You can override environments when triggering runs:

```json theme={null}
{
  "testPlanShortId": "pln_abc123",
  "applications": [
    {
      "applicationShortId": "app_abc123",
      "environment": {
        "url": "https://preview.example.com"
      }
    }
  ]
}
```

This allows you to:

* Run the same test plan against different environments
* Test preview deployments dynamically
* Switch between staging and production without changing test plan settings

### Device Preset Configuration

**In Test Plan UI:** Select which device preset to use for each application.

**Via API:** Device preset overrides are supported using the `devicePresetShortId` field in the `applications` array. See [Start Run API](https://docs.qa.tech/api-reference/runs/start-test-run.md) for details.

### Parameter Precedence

When running tests, QA.tech resolves environment and device preset settings in this order:

1. **Project defaults** - Base configuration from application settings
2. **Test plan parameters** - Overrides configured in the test plan UI
3. **Per-run API overrides** - Overrides passed via API at runtime

Later settings override earlier ones. For example, a per-run API override takes precedence over test plan parameters, which take precedence over project defaults.

> [!TIP]
>
> Use test plan parameters when you want consistent overrides for a specific
> test plan. Use API overrides when you need dynamic configuration at runtime
> (e.g., preview deployments, CI/CD).

## Finding Short IDs for API Usage

When using the [Start Run API](https://docs.qa.tech/api-reference/runs/start-test-run.md) to override environments, you need Application and Environment Short IDs.

| ID Type | Where to Find | What It's Used For |
| - | - | - |
| Application Short ID | Settings → Applications & Envs (column or dropdown menu) | `applicationShortId` in `applications` array |
| Environment Short ID | Settings → Applications & Envs → \[App] → Environments (above name) | `environment.shortId` field |

For detailed steps, see [Understanding Different IDs](https://docs.qa.tech/api-reference/introduction.md#understanding-different-ids).

## Creating Applications & Environments

**1. Navigate to applications settings**

Go to [**Settings → Applications &
Envs**](https://app.qa.tech/current-project/settings/applications) in your
project dashboard.

**2. Create new application**

Click **Create Application**, enter a name, and select **Web application**,
**Mobile application**, or **API application**.

**3. Configure the default environment**

Enter the environment details required for the application type. API
applications require an HTTPS base URL.

**4. Save application**

Click "Create Application" to save your application with its associated
environment.

**5. Add additional environments (optional)**

Select the application, then click "Add Environment" to create additional
environments (e.g., staging, production, preview).


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