# Application Variants

> Source: https://developers.cloud66.com/v3/endpoints/application-variants/

## List Application Variants

URL: https://developers.cloud66.com/v3/endpoints/application-variants/#list
Endpoint: GET /stacks/:stack_id/application_variants
OAuth scope: redeploy

Returns all application variants (active, rollout, and preview) for the specified stack.

Application variants enable advanced deployment strategies like blue-green deployments, canary releases, and preview environments. Each variant represents a different version of your application that can receive varying amounts of traffic.

**Related models:** Application Variant, Stack

**Variant Types:**
- **Active**: The current production version receiving 100% traffic
- **Canary**: A rollout variant receiving a percentage of traffic for testing
- **Blue/Green**: A rollout variant for blue-green deployments 
- **Preview**: A preview environment for testing changes

<ResponseCodes 
  codes={[200, 401, 403, 404]}
  overrides={{
    200: "Success - Returns list of application variants",
    403: "Forbidden - OAuth token lacks required `redeploy` scope or insufficient permissions",
    404: "Not Found - Stack not found"
  }}
/>

### Parameters

- `stack_id` (string, optional) — Stack UID

### Response

```json
{
  "response": [
    {
      "id": 123,
      "uid": "abc123def456",
      "variant_type": "active",
      "git_hash": "a1b2c3d4e5f6",
      "created_at": "2023-01-15T10:30:00Z",
      "percentage": 100
    },
    {
      "id": 124,
      "uid": "def456ghi789",
      "variant_type": "canary",
      "git_hash": "f6e5d4c3b2a1",
      "created_at": "2023-01-15T11:00:00Z",
      "percentage": 20
    },
    {
      "id": 125,
      "uid": "ghi789jkl012",
      "variant_type": "preview",
      "git_hash": "123456789abc",
      "created_at": "2023-01-15T12:00:00Z",
      "percentage": 0
    }
  ]
}
```

---

## Update Rollout Variant

URL: https://developers.cloud66.com/v3/endpoints/application-variants/#update
Endpoint: PUT /stacks/:stack_id/application_variants/:id
OAuth scope: redeploy

Manages rollout variants by committing changes or adjusting canary percentages.

Only applies to rollout variants (blue-green or canary deployments). Use this endpoint to either finalize a rollout by committing it as the new active version, or to adjust the traffic percentage for canary deployments.

**Related models:** Application Variant, Stack

**Operations:**
- **commit**: Finalize the rollout variant (make it the active version)
- **percentage**: Update canary traffic percentage (canary deployments only)

**Examples:**
- Commit a blue-green deployment: `PUT /stacks/:stack_id/application_variants/:id?operation=commit`
- Update canary percentage: `PUT /stacks/:stack_id/application_variants/:id?operation=percentage&canary_percentage=50`

<ResponseCodes 
  codes={[200, 400, 401, 403, 404]}
  overrides={{
    200: "Success - Rollout variant updated successfully",
    400: "Bad Request - Invalid variant UID, non-rollout variant, or invalid operation parameters",
    403: "Forbidden - OAuth token lacks required `redeploy` scope or insufficient permissions",
    404: "Not Found - Stack or variant not found"
  }}
/>

### Parameters

- `stack_id` (string, optional) — Stack UID
- `id` (string, optional) — Application variant UID
- `operation` (string, optional) — Operation to perform - "commit" to finalize rollout or "percentage" to update canary traffic
- `canary_percentage` (string, optional) — New traffic percentage (0-100) - required when operation=percentage

### Response

```json
{
  "response": {
    "ok": true,
    "message": "Done"
  }
}
```

---

## Delete Preview Variant

URL: https://developers.cloud66.com/v3/endpoints/application-variants/#delete
Endpoint: DELETE /stacks/:stack_id/application_variants/:id
OAuth scope: redeploy

Permanently removes a preview variant from the system.

<Callout type="warning" title="Preview Variants Only">
This operation only applies to preview variants and cannot be undone. The variant management system will be updated to reflect the change and clean up associated resources.
</Callout>

**Related models:** Application Variant, Stack

Preview variants are used for testing changes in isolated environments before promoting them to production through rollout strategies.

<ResponseCodes 
  codes={[200, 400, 401, 403, 404]}
  overrides={{
    200: "Success - Preview variant deleted successfully",
    400: "Bad Request - Invalid variant UID or not a preview variant",
    403: "Forbidden - OAuth token lacks required `redeploy` scope or insufficient permissions",
    404: "Not Found - Stack or preview variant not found"
  }}
/>

### Parameters

- `stack_id` (string, optional) — Stack UID
- `id` (string, optional) — Preview variant UID to delete

### Response

```json
{
  "response": {
    "ok": true,
    "message": "Done"
  }
}
```
