---
title: fastly routing-config path rule create
summary: Create a rule within a path
url: https://www.fastly.com/documentation/reference/cli/routing-config/path/rule/create
---

Create a rule within a path

## Flags

| Flag | Description | Required | Default |
|------|-------------|----------|----------|
| `--file` | Path to a JSON file describing the rule, e.g. {"action": {"type": "service", "value": "..."}, "conditions": [...]}. Omit "conditions" to create the default (catch-all) rule for the path | Yes | - |
| `--path-id` | The Path Identifier | Yes | - |
| `--routing-config-id` | The Routing Config Identifier | Yes | - |

## Global options

| Flag | Description | Required | Default |
|------|-------------|----------|----------|
| `--help` | Show context-sensitive help. | No | - |
| `--accept-defaults` | Accept default options for all interactive prompts apart from Yes/No confirmations | No | - |
| `--auto-yes` | Answer yes automatically to all Yes/No confirmations. This may suppress security warnings | No | - |
| `--debug-mode` | Print API request and response details (NOTE: can disrupt the normal CLI flow output formatting) | No | - |
| `--non-interactive` | Do not prompt for user input - suitable for CI processes. Equivalent to --accept-defaults and --auto-yes | No | - |
| `--quiet` | Silence all output except direct command output. This won't prevent interactive prompts (see: --accept-defaults, --auto-yes, --non-interactive) | No | - |
| `--token` | Fastly API token, or name of a stored auth token (use 'default' for the default token). Falls back to FASTLY_API_TOKEN env var | No | - |
| `--verbose` | Verbose logging | No | - |

## Examples

### Create the default (catch-all) rule for a path

Where rule.json contains `{"action": {"type": "service", "value": "SU1Z0isxPaozGVKXdv0eY"}}`, with no "conditions" field, to create the default (catch-all) rule for the path.

```bash
fastly routing-config path rule create --routing-config-id 1a2b3c4d --path-id 5e6f7g8h --file rule.json
```

### Create a conditional rule within a path

Where rule.json contains `{"action": {"type": "service", "value": "SU1Z0isxPaozGVKXdv0eY"}, "conditions": [{"type": "header", "key": "X-Test", "operator": "equals", "value": "1"}]}`.

```bash
fastly routing-config path rule create --routing-config-id 1a2b3c4d --path-id 5e6f7g8h --file rule.json
```

