# Match Conditions

Match conditions determine when a delivery rule fires. Use them to target
requests by path, header, IP, geography, query parameters, and more.

## Logical Operators

| Operator | Behavior |
|----------|----------|
| `matchAll` | ALL conditions must match for the rule to apply |
| `matchAny` | ANY condition must match for the rule to apply |
| `matchNone` | NO conditions must match for the rule to apply |

### Match All

ALL conditions must match for the rule to apply

*Match POST requests to /api/* paths*

```json
{
  "matchAll": {
    "paths": ["/api/*"],
    "method": ["POST"]
  }
}
```

### Match Any

ANY condition must match for the rule to apply

*Match POST or PUT to /api/* or /v2/* paths*

```json
{
  "matchAny": {
    "paths": ["/api/*", "/v2/*"],
    "method": ["POST", "PUT"]
  }
}
```

### Match None

NO conditions must match for the rule to apply

*Match requests not from internal IPs to non-admin paths*

```json
{
  "matchNone": {
    "paths": ["/admin/*"],
    "ipv4": ["198.51.100.0/24"]
  }
}
```

## Path Matching

### `paths` — Basic Path Matching

Match exact paths for specific endpoints.

**Value type:** `string-array`

*Match exact API paths*

```json
{
  "paths": ["/api/*", "/v2/users/*"]
}
```

### `paths_startswith` — Path Prefix Matching

Match all paths that start with specific prefixes.

**Value type:** `string-array`

*Match paths starting with /api/ or /admin/*

```json
{
  "paths_startswith": ["/api/", "/admin/"]
}
```

### `paths_full` — Exact Path Matching

Match only the exact full path.

**Value type:** `string-array`

*Match exact health and status paths*

```json
{
  "paths_full": ["/health", "/status"]
}
```

### `paths_wildcard` — Wildcard Path Matching

Use wildcards for pattern-based path matching.

**Value type:** `string-array`

*Match paths with wildcards like /api/*/users*

```json
{
  "paths_wildcard": ["/api/*/users", "/files/*.jpg"]
}
```

---

## Header Matching

### `reqheader` — Basic Header Matching

Match specific header values exactly.

**Value type:** `key-array-object`

*Match User-Agent and Accept-Language headers*

```json
{
  "reqheader": {
    "User-Agent": [
      "mobile-app",
      "desktop-app"
    ],
    "Accept-Language": [
      "en-US",
      "en-GB"
    ]
  }
}
```

### `reqheader_values` — Header Value Matching

Alternative syntax for header value matching.

**Value type:** `key-array-object`

*Match Authorization and API key headers*

```json
{
  "reqheader_values": {
    "Authorization": [
      "Bearer abc123"
    ],
    "X-API-Key": [
      "key1",
      "key2"
    ]
  }
}
```

### `reqheader_startswith_values` — Header Prefix Matching

Match headers that start with specific values.

**Value type:** `key-array-object`

*Match headers starting with Mozilla/ or Chrome/*

```json
{
  "reqheader_startswith_values": {
    "User-Agent": [
      "Mozilla/",
      "Chrome/"
    ],
    "X-Forwarded-For": [
      "192.168."
    ]
  }
}
```

### `reqheader_wildcard_values` — Header Wildcard Matching

Use wildcards for flexible header pattern matching.

**Value type:** `key-array-object`

*Match headers with wildcard patterns*

```json
{
  "reqheader_wildcard_values": {
    "User-Agent": [
      "*mobile*",
      "*tablet*"
    ],
    "Accept": [
      "image/*"
    ]
  }
}
```

### `reqheader_full_values` — Exact Header Matching

Match headers with exact full values.

**Value type:** `key-array-object`

*Match exact Content-Type values*

```json
{
  "reqheader_full_values": {
    "Content-Type": [
      "application/json"
    ],
    "X-Requested-With": [
      "XMLHttpRequest"
    ]
  }
}
```

### `respheader` — Basic Response Header Matching

Match specific response header values exactly.

**Value type:** `key-array-object`

*Match Content-Encoding and Server headers*

```json
{
  "respheader": {
    "Content-Encoding": [
      "gzip"
    ],
    "Server": [
      "AkamaiNetstorage"
    ]
  }
}
```

### `respheader_values` — Response Header Value Matching

Alternative syntax for response header value matching.

**Value type:** `key-array-object`

*Match Server and Content-Type response headers*

```json
{
  "respheader_values": {
    "Server": [
      "AkamaiNetstorage"
    ],
    "Content-Type": [
      "text/html"
    ]
  }
}
```

### `respheader_startswith_values` — Response Header Prefix Matching

Match response headers that start with specific values.

**Value type:** `key-array-object`

*Match Content-Type starting with text/*

```json
{
  "respheader_startswith_values": {
    "content-type": [
      "text/"
    ]
  }
}
```

### `respheader_wildcard_values` — Response Header Wildcard Matching

Use wildcards for flexible response header pattern matching.

**Value type:** `key-array-object`

*Match Server headers with wildcard patterns*

```json
{
  "respheader_wildcard_values": {
    "Server": [
      "*aws*"
    ]
  }
}
```

### `respheader_full_values` — Exact Response Header Matching

Match response headers with exact full values.

**Value type:** `key-array-object`

*Match exact response header values*

```json
{
  "respheader_full_values": {
    "Content-Type": [
      "application/json"
    ],
    "X-Requested-With": [
      "XMLHttpRequest"
    ]
  }
}
```

---

## Query Parameter Matching

### `query_exists` — Query Parameter Existence

Check if specific query parameters are present.

**Value type:** `string-array`

*Check for debug or preview parameters*

```json
{
  "query_exists": [
    "debug",
    "preview"
  ]
}
```

### `query_values` — Query Parameter Values

Match specific values of query parameters.

**Value type:** `key-array-object`

*Match version and format query parameters*

```json
{
  "query_values": {
    "version": [
      "v1",
      "v2"
    ],
    "format": [
      "json",
      "xml"
    ]
  }
}
```

### `query_wildcard_values` — Query Wildcard Matching

Use wildcards for flexible query parameter matching.

**Value type:** `key-array-object`

*Match query parameters with wildcard patterns*

```json
{
  "query_wildcard_values": {
    "search": [
      "*product*"
    ],
    "category": [
      "electronics*"
    ]
  }
}
```

### `query_full_values` — Exact Query Parameter Matching

Match requests with exact query parameter values.

**Value type:** `key-array-object`

*Match exact version and format values*

```json
{
  "query_full_values": {
    "version": [
      "v1.0"
    ],
    "format": [
      "json",
      "xml"
    ]
  }
}
```

### `query_startswith_values` — Query Parameter Prefix Matching

Match requests where query value starts with a value.

**Value type:** `key-array-object`

*Match query parameters starting with specific values*

```json
{
  "query_startswith_values": {
    "category": [
      "tech",
      "news"
    ],
    "tag": [
      "featured"
    ]
  }
}
```

### `query` — Query Parameter Map Matching

Match query parameters using key-value maps for complex query string patterns.

**Value type:** `key-array-object`

*Match multiple query parameter key-value pairs*

```json
{ "query": { "action": ["view", "edit"], "format": ["json"] } }
```

---

## Geographic Matching

### `geo` — Geographic Country Matching

Match requests based on client country codes using ISO 3166-1 alpha-2 format (e.g., US, GB, JP). [Property Reference](https://techdocs.akamai.com/edgeworkers/docs/user-location-object) | [Download Country Codes](https://control.akamai.com/apps/download-center/#/products/3;name=EdgeScape)

**Value type:** `string-array`

*Match requests from specific countries*

```json
{ "geo": ["US", "CA", "GB"] }
```

### `region` — Geographic Region-Based Matching

Match requests from specific regions using ISO 3166-2 two-letter codes (e.g., MA, CA, TX). [Property Reference](https://techdocs.akamai.com/edgeworkers/docs/user-location-object) | [Download Region Codes](https://control.akamai.com/apps/download-center/#/products/3;name=EdgeScape)

**Value type:** `string-array`

*Match requests from specific regions*

```json
{
  "region": ["BY", "IL", "NY"]
}
```

### `continent` — Geographic Continent-Based Matching

Match requests from specific continents using two-letter codes (e.g., NA, EU, AS). [Property Reference](https://techdocs.akamai.com/edgeworkers/docs/user-location-object) | [Download Continent Codes](https://control.akamai.com/apps/download-center/#/products/3;name=EdgeScape)

**Value type:** `string-array`

*Match requests from specific continents*

```json
{
  "continent": ["NA", "EU"]
}
```

### `city` — Geographic City-Based Matching

Match requests from specific cities. City names are uppercase (e.g., LONDON, NEW YORK). [Property Reference](https://techdocs.akamai.com/edgeworkers/docs/user-location-object) | [Download City Codes](https://control.akamai.com/apps/download-center/#/products/3;name=EdgeScape)

**Value type:** `string-array`

*Match requests from specific cities*

```json
{
  "city": ["MUNICH", "CHICAGO"]
}
```

---

## IP & ASN Matching

### `asn` — ASN Matching

Matches requests based on the Autonomous System Number (ASN) of the client's IP address.

**Value type:** `string-array`

*Match AWS, Google, and Facebook ASNs*

```json
{
  "asn": [
    16509,
    8075,
    13335
  ]
}
```

### `asn_equals` — ASN Exact Matching

Match requests based on exact Autonomous System Number equality.

**Value type:** `string-array`

*Match exact ASN values*

```json
{ "asn_equals": ["16509", "15169", "32934"] }
```

### `ipv4` — IPv4 Matching

Match specific IPv4 addresses or CIDR blocks.

**Value type:** `string-array`

*Match IPv4 addresses and CIDR blocks*

```json
{
  "ipv4": [
    "192.0.2.100",
    "198.51.100.0/24",
    "203.0.113.0/24"
  ]
}
```

### `ipv6` — IPv6 Matching

Match IPv6 addresses with full address or CIDR notation.

**Value type:** `string-array`

*Match IPv6 addresses and ranges*

```json
{
  "ipv6": [
    "2001:db8::1",
    "2001:db8::/32"
  ]
}
```

---

## Cookie Matching

### `cookie_name` — Cookie Name Matching

Match specific cookie names exactly.

**Value type:** `string-array`

*Match session_id and user_pref cookies*

```json
{
  "cookie_name": [
    "session_id",
    "user_pref"
  ]
}
```

### `cookie_name_startswith` — Cookie Name Prefix

Match cookies whose names start with specific prefixes.

**Value type:** `string-array`

*Match cookies starting with sess_ or temp_*

```json
{
  "cookie_name_startswith": [
    "sess_",
    "temp_"
  ]
}
```

### `cookie_name_wildcard` — Cookie Name Wildcards

Use wildcards for flexible cookie name matching.

**Value type:** `string-array`

*Match cookies with wildcard patterns*

```json
{
  "cookie_name_wildcard": [
    "*_session",
    "user_*"
  ]
}
```

---

## Request Properties

### `method` — HTTP Method Matching

Target specific HTTP methods.

**Value type:** `string-array`

*Match GET, POST, and PUT methods*

```json
{
  "method": [
    "GET",
    "POST",
    "PUT"
  ]
}
```

### `protocol` — Protocol/Scheme Matching

Match requests based on protocol (HTTP/HTTPS).

**Value type:** `string-array`

*Match HTTPS protocol*

```json
{
  "protocol": [
    "https"
  ]
}
```

### `scheme` — URL Scheme Matching

Match requests based on URL scheme (http, https, or other protocols).

**Value type:** `string-array`

*Match HTTPS scheme*

```json
{ "scheme": ["https"] }
```

### `extension` — File Extension Matching

Match requests based on file extensions.

**Value type:** `string-array`

*Match image file extensions*

```json
{
  "extension": [
    "jpg",
    "png",
    "gif",
    "webp"
  ]
}
```

---

## Response Matching

### `origin_timeout` — Origin Timeout Matching

Match responses based on whether the origin connection has timed out. Available in response match conditions only (onClientResponse, onOriginResponse).

**Value type:** `boolean`

*Match when origin connection has timed out*

```json
{
  "origin_timeout": true
}
```

### `status` — Response Status Code Matching

Match responses based on HTTP status codes. Supports exact codes (500), ranges (502-504), and classes (5xx). Available in response match conditions only (onClientResponse, onOriginResponse).

**Value type:** `string-array`

*Match server error status codes*

```json
{
  "status": [500, "502-504", "5xx"]
}
```

---

