---
title: Condition
summary: Conditions are used to control whether logic defined in configured VCL objects is applied for a particular client request. A condition contains a VCL conditional expression that evaluates to either true or false and is used to determine whether the condition is met. The type of the condition determines where it is executed and the VCL variables that can be evaluated as part of the conditional logic.
url: https://www.fastly.com/documentation/reference/api/vcl-services/condition
---

Conditions are used to control whether logic defined in configured VCL objects is applied for a particular client request. A condition contains a VCL conditional expression that evaluates to either true or false and is used to determine whether the condition is met. The type of the condition determines where it is executed and the VCL variables that can be evaluated as part of the conditional logic.

## Data model

| Field | Type | Description |
|-------|------|-------------|
| `comment` | string | A freeform descriptive note. |
| `name` | string | Name of the condition. Required. |
| `priority` | string | A numeric string. Priority determines execution order. Lower numbers execute first. |
| `service_id` | string | Alphanumeric string identifying the service. (Read-only) |
| `statement` | string | A conditional expression in VCL used to determine if the condition is met. |
| `type` | string | Type of the condition.  |
| `version` | string | A numeric string that represents the service version. |
| `created_at` | string | Date and time in ISO 8601 format. (Read-only) |
| `deleted_at` | string | Date and time in ISO 8601 format. (Read-only) |
| `updated_at` | string | Date and time in ISO 8601 format. (Read-only) |

## API endpoints

### List conditions

**GET** `/service/{service_id}/version/{version_id}/condition`

Gets all conditions for a particular service and version.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |
| `version_id` | integer | path | Yes | Integer identifying a service version. |

### Create a condition

**POST** `/service/{service_id}/version/{version_id}/condition`

Creates a new condition.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |
| `version_id` | integer | path | Yes | Integer identifying a service version. |

### Describe a condition

**GET** `/service/{service_id}/version/{version_id}/condition/{condition_name}`

Gets the specified condition.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `condition_name` | string | path | Yes | Name of the condition. Required. |
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |
| `version_id` | integer | path | Yes | Integer identifying a service version. |

### Update a condition

**PUT** `/service/{service_id}/version/{version_id}/condition/{condition_name}`

Updates the specified condition.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `condition_name` | string | path | Yes | Name of the condition. Required. |
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |
| `version_id` | integer | path | Yes | Integer identifying a service version. |

### Delete a condition

**DELETE** `/service/{service_id}/version/{version_id}/condition/{condition_name}`

Deletes the specified condition.

**Parameters:**

| Name | Type | In | Required | Description |
|------|------|----|---------|--------------|
| `condition_name` | string | path | Yes | Name of the condition. Required. |
| `service_id` | string | path | Yes | Alphanumeric string identifying the service. |
| `version_id` | integer | path | Yes | Integer identifying a service version. |

