Trigger and scope
CRITICAL: many subcommands have unintuitive paths (e.g. fastly domain create fails with 403, correct is fastly service domain create; logging is under fastly service logging; alerts under fastly service alert; rate limits under fastly service rate-limit).
Covers: services, backends, domains, VCL snippets, cache purging, Compute/WASM deploys, log streaming (S3/Datadog/Splunk/Kafka/25+ providers), NGWAF/WAF, TLS/mTLS, KV/config/secret stores, stats, alerts, rate limiting, ACLs, and auth tokens.
Fastly CLI Overview
References
| Topic |
File |
Use when... |
| Authentication |
auth.md |
Login, stored tokens, service auth, CI/CD auth setup |
| Compute |
compute.md |
Building/deploying edge applications, local dev server |
| Services |
services.md |
Service CRUD, backends, domains, ACLs, dictionaries, VCL, purging, rate limiting |
| Logging |
logging.md |
Log streaming to S3, GCS, Datadog, Splunk, Kafka, 25+ providers |
| NGWAF |
ngwaf.md |
Next-Gen WAF workspaces, IP/country lists, rules, signals, thresholds, alerts |
| Notifications |
notifications.md |
Slack/PagerDuty/webhook integrations, audit log event mappings |
| Stats |
stats.md |
Which fastly stats subcommand takes which flag, and where the two flag sets diverge |
| Stores |
stores.md |
KV Stores, Config Stores, Secret Stores, resource links |
| TLS |
tls.md |
Platform TLS, Let's Encrypt subscriptions, custom certs, mutual TLS |
For endpoint choice, unit and window conventions and worked queries, use the fastly-stats skill.
Command Structure
fastly <command> <subcommand> [flags]
Top-Level Commands
| Category |
Commands |
| Compute |
compute - Build and deploy edge applications |
| Services |
service - Manage CDN services, logging, backends, VCL, ACLs, purging |
| Security |
ngwaf - Web application firewall |
| TLS |
tls-subscription, tls-custom, tls-platform, tls-config - Certificate management |
| Storage |
kv-store, config-store, secret-store - Edge data stores |
| Auth |
auth - Login, stored tokens, active token output, revocation; auth-token (deprecated) |
| Info |
stats, ip-list, pops, whoami - Information queries |
| Notify |
integration - Notification destinations; audit-log event-mapping - Event triggers |
| Other |
dashboard, domain, dns, apisecurity, products, object-storage, tools |
Global Flags
Available on most commands:
# Service targeting
--service-id SERVICE_ID # Target service by ID
--service-name NAME # Target service by name
-s SERVICE_ID # Short form
# Version targeting (version-scoped commands like `fastly service domain/backend/...`)
# NOTE: `fastly domain create` does NOT accept --version (it uses a different API)
--version VERSION # Specific version number
--version active # Currently active version
--version latest # Most recent version
--version staged # Currently staged version
# Authentication
--token TOKEN # API token or stored token name (use 'default' for default)
# Output (--json is per-command, not global)
--verbose # Detailed output
--quiet # Minimal output
# Automation
--accept-defaults # Accept default values
--auto-yes # Skip confirmations
--non-interactive # No prompts
Key Patterns
- Target by ID (
-s SERVICE_ID) or name (--service-name NAME)
- Version targeting:
--version active, --version latest, --version staged, or --version N
- Use
--autoclone to auto-clone locked versions
- Use
--json for scripted output, --non-interactive --accept-defaults for CI/CD
- JSON output uses PascalCase fields (
.Name, .ServiceID, .ActiveVersion), not lowercase
ActiveVersion shape varies; prefer --version active, or parse with jq -r '.ActiveVersion.Number // .ActiveVersion'
- CLI version is
fastly version (not fastly --version)
- POP/shield lookup is
fastly pops; it has no list subcommand and no --json; use the SHIELD column value (not POP CODE) for --shield
- Auth:
fastly auth login --sso to login, or set FASTLY_API_TOKEN env var
- For shell substitutions or pipes that need the active API token, prefer
fastly auth token; it prints the token only to non-terminal stdout and refuses to write it directly to a terminal
- In AI contexts, never run
fastly auth show --reveal bare. If you specifically need a stored token by name rather than the currently active token, use fastly auth show TOKEN_NAME --reveal --quiet | awk '/^Token:/ {print $2}' only inside a shell substitution
- Logging is under
service logging (e.g. fastly service logging s3 create)
- Config: use
fastly config --location to find the platform-specific CLI config file; fastly.toml is the project manifest
Common Flag Examples
These are the flags that cause the most confusion. Copy-paste these patterns directly.
Autocloning (use this every time you modify a service)
# --autoclone automatically clones a locked version before making changes.
# Without it, you get "version is locked" errors and waste time cloning manually.
fastly service backend create --service-id $SID --version active --autoclone \
--name my-origin --address origin.example.com --port 443 --use-ssl
fastly service domain create --service-id $SID --version active --autoclone \
--name cdn.example.com
Always pass --autoclone when creating, updating, or deleting backends, domains, snippets, VCL, conditions, headers, or any other version-scoped resource. It is safe to use even on unlocked versions (it simply does nothing if the version is already editable).
Boolean flags (--use-ssl, --use-ssl is NOT --use-ssl true)
# CORRECT - boolean flags are bare, no value
fastly service backend create --name origin --address example.com --port 443 --use-ssl
# WRONG - do not pass a value to boolean flags
fastly service backend create --name origin --address example.com --port 443 --use-ssl true
Other boolean flags that work the same way: --auto-yes, --non-interactive, --verbose, --quiet, --autoclone.
Domain creation (requires --name flag)
# CORRECT
fastly service domain create --service-id $SID --version active --autoclone --name cdn.example.com
# WRONG - domain is not a positional argument
fastly service domain create --service-id $SID --version active cdn.example.com
# WRONG - there is no -d flag
fastly service domain create --service-id $SID --version active -d cdn.example.com
Stats (historical and real-time)
# Historical stats by day for a date range (JSON output)
fastly stats historical --service-id $SID --by day \
--from "2026-02-01" --to "2026-03-01" --json
# Real-time stats (last second)
fastly stats realtime --service-id $SID --json
The --by flag accepts: day, hour, minute. The --from and --to flags use quoted date strings. Use --json for JSON output on stats commands.
Propagation Delays
Changes propagate across Fastly's network in seconds to minutes (up to 10 min for version activations, up to 5 min for TLS). Cache purges are 1-2 seconds. Retry with backoff when verifying changes.
New service activation sequence: After activating a brand new service, expect 500 "Domain Not Found" for 10-60 seconds while the domain propagates to edge POPs. This is normal — do not change configuration. Wait and retry. After version updates (e.g., fixing backend settings), allow 15-30 seconds for the new version to propagate.
KV Store Gotchas
- Link before use: A KV store must be linked to a service version before Compute code can access it. Use
fastly kv-store create then fastly service resource-link create --resource-id STORE_ID --service-id $SID --version active --autoclone.
- Eventual consistency: Read-after-write is eventually consistent. A key you just wrote may not be readable for a few seconds. Do not rely on immediate read-back in scripts; add a short delay or retry loop.
- Entry size limit: Individual KV store entries are limited to 25 MB. Plan accordingly for large values.
- Listing stores:
fastly kv-store list lists all stores on the account, not per-service. Use fastly service resource-link list to see which stores are linked to a given service.
Host Header Override Pattern
When the origin hostname differs from the desired Host header (e.g., origin is example.com but you want to send Host: download.example.com), use --override-host on the backend:
fastly service backend create --service-id $SID --version 1 \
--name my-origin --address example.com --port 443 --use-ssl \
--override-host download.example.com \
--ssl-cert-hostname example.com --ssl-sni-hostname example.com
The --override-host value is the Host header sent to the origin. The --ssl-cert-hostname and --ssl-sni-hostname must match the origin's TLS certificate (usually the --address value). Getting these backwards causes 503 errors.
Service List Completeness
When enumerating services (e.g., for bandwidth stats), use fastly service list --json.
The command follows API pagination internally and returns all pages unless you explicitly start from a later --page.
Services with zero traffic still appear in the list, so loop over every returned service ID instead of relying on stats APIs that omit zero-traffic services.
New VCL Service Setup Workflow
Use this sequence to stand up a new VCL caching service end-to-end. Each step includes a validation checkpoint.
Pre-flight — verify the origin responds and check its TLS certificate SANs:
curl -sI -H "Host: DESIRED_HOST" https://ORIGIN_ADDRESS/
echo | openssl s_client -connect ORIGIN_ADDRESS:443 -servername ORIGIN_ADDRESS 2>/dev/null | \
openssl x509 -noout -text | grep -A1 "Subject Alternative Name"
Checkpoint: origin returns 200 and the backend ssl-cert-hostname matches the served cert. If no HTTPS SNI/cert combination validates but HTTP with that Host works, use --port 80 or fix the origin cert; do not disable verification.
Create service — note the service ID from the output:
fastly service create --name "my-service" --non-interactive
Add domain + backend on version 1 (do NOT use --autoclone or --version latest on a new service):
fastly service domain create --service-id $SID --version 1 \
--name my-service.global.ssl.fastly.net
fastly service backend create --service-id $SID --version 1 \
--name origin --address ORIGIN_ADDRESS --port 443 --use-ssl \
--override-host ORIGIN_ADDRESS \
--ssl-cert-hostname ORIGIN_ADDRESS --ssl-sni-hostname ORIGIN_ADDRESS
Validate version before activating:
fastly service version validate --service-id $SID --version 1
Checkpoint: validation returns success (no missing domain/backend errors).
Activate:
fastly service version activate --service-id $SID --version 1
Verify propagation — wait 15-30s, then test with GET (not HEAD):
curl -sS -D - -o /dev/null https://my-service.global.ssl.fastly.net/ | head -1
Checkpoint: 200 OK. If 500 "Domain Not Found", wait and retry (normal for 10-60s). If 503, check backend SSL settings.
See services.md for advanced workflows (custom domains with TLS, host header overrides, live service updates).
Troubleshooting
See troubleshooting.md for the full list. Key pitfalls are covered inline above: SSL hostname flags (see Host Header Override Pattern), boolean flags and domain --name (see Common Flag Examples), --autoclone (see Key Patterns), and token safety (see Key Patterns).
1---2name: fastly-cli3description: Executes Fastly CLI commands for managing CDN services, Compute deploys, and edge infrastructure. Use when running `fastly` CLI commands, creating or managing Fastly services from the terminal, deploying Fastly Compute applications, managing backends/domains/VCL snippets via command line, purging cache, configuring log streaming, setting up TLS certificates, managing KV/config/secret stores, checking service stats, authenticating with Fastly SSO, or working with fastly.toml. Also applies when working with Fastly service IDs in CLI context, or with `fastly service`, `fastly compute`, `fastly auth`, or any Fastly CLI subcommand. Covers service CRUD, version management, autocloning, and troubleshooting common CLI errors.4---56## Trigger and scope78CRITICAL: many subcommands have unintuitive paths (e.g. `fastly domain create` fails with 403, correct is `fastly service domain create`; logging is under `fastly service logging`; alerts under `fastly service alert`; rate limits under `fastly service rate-limit`).910Covers: services, backends, domains, VCL snippets, cache purging, Compute/WASM deploys, log streaming (S3/Datadog/Splunk/Kafka/25+ providers), NGWAF/WAF, TLS/mTLS, KV/config/secret stores, stats, alerts, rate limiting, ACLs, and auth tokens.1112# Fastly CLI Overview1314## References1516| Topic | File | Use when... |17| -------------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------- |18| Authentication | [auth.md](references/auth.md) | Login, stored tokens, service auth, CI/CD auth setup |19| Compute | [compute.md](references/compute.md) | Building/deploying edge applications, local dev server |20| Services | [services.md](references/services.md) | Service CRUD, backends, domains, ACLs, dictionaries, VCL, purging, rate limiting |21| Logging | [logging.md](references/logging.md) | Log streaming to S3, GCS, Datadog, Splunk, Kafka, 25+ providers |22| NGWAF | [ngwaf.md](references/ngwaf.md) | Next-Gen WAF workspaces, IP/country lists, rules, signals, thresholds, alerts |23| Notifications | [notifications.md](references/notifications.md) | Slack/PagerDuty/webhook integrations, audit log event mappings |24| Stats | [stats.md](references/stats.md) | Which `fastly stats` subcommand takes which flag, and where the two flag sets diverge |25| Stores | [stores.md](references/stores.md) | KV Stores, Config Stores, Secret Stores, resource links |26| TLS | [tls.md](references/tls.md) | Platform TLS, Let's Encrypt subscriptions, custom certs, mutual TLS |2728For endpoint choice, unit and window conventions and worked queries, use the **fastly-stats** skill.2930## Command Structure3132```33fastly <command> <subcommand> [flags]34```3536### Top-Level Commands3738| Category | Commands |39| ------------ | --------------------------------------------------------------------------------------- |40| **Compute** | `compute` - Build and deploy edge applications |41| **Services** | `service` - Manage CDN services, logging, backends, VCL, ACLs, purging |42| **Security** | `ngwaf` - Web application firewall |43| **TLS** | `tls-subscription`, `tls-custom`, `tls-platform`, `tls-config` - Certificate management |44| **Storage** | `kv-store`, `config-store`, `secret-store` - Edge data stores |45| **Auth** | `auth` - Login, stored tokens, active token output, revocation; `auth-token` (deprecated) |46| **Info** | `stats`, `ip-list`, `pops`, `whoami` - Information queries |47| **Notify** | `integration` - Notification destinations; `audit-log event-mapping` - Event triggers |48| **Other** | `dashboard`, `domain`, `dns`, `apisecurity`, `products`, `object-storage`, `tools` |4950## Global Flags5152Available on most commands:5354```bash55# Service targeting56--service-id SERVICE_ID # Target service by ID57--service-name NAME # Target service by name58-s SERVICE_ID # Short form5960# Version targeting (version-scoped commands like `fastly service domain/backend/...`)61# NOTE: `fastly domain create` does NOT accept --version (it uses a different API)62--version VERSION # Specific version number63--version active # Currently active version64--version latest # Most recent version65--version staged # Currently staged version6667# Authentication68--token TOKEN # API token or stored token name (use 'default' for default)6970# Output (--json is per-command, not global)71--verbose # Detailed output72--quiet # Minimal output7374# Automation75--accept-defaults # Accept default values76--auto-yes # Skip confirmations77--non-interactive # No prompts78```7980## Key Patterns8182- Target by ID (`-s SERVICE_ID`) or name (`--service-name NAME`)83- Version targeting: `--version active`, `--version latest`, `--version staged`, or `--version N`84- Use `--autoclone` to auto-clone locked versions85- Use `--json` for scripted output, `--non-interactive --accept-defaults` for CI/CD86- **JSON output uses PascalCase fields** (`.Name`, `.ServiceID`, `.ActiveVersion`), not lowercase87- `ActiveVersion` shape varies; prefer `--version active`, or parse with `jq -r '.ActiveVersion.Number // .ActiveVersion'`88- CLI version is `fastly version` (not `fastly --version`)89- POP/shield lookup is `fastly pops`; it has no `list` subcommand and no `--json`; use the `SHIELD` column value (not POP `CODE`) for `--shield`90- Auth: `fastly auth login --sso` to login, or set `FASTLY_API_TOKEN` env var91- For shell substitutions or pipes that need the active API token, prefer `fastly auth token`; it prints the token only to non-terminal stdout and refuses to write it directly to a terminal92- In AI contexts, never run `fastly auth show --reveal` bare. If you specifically need a stored token by name rather than the currently active token, use `fastly auth show TOKEN_NAME --reveal --quiet | awk '/^Token:/ {print $2}'` only inside a shell substitution93- Logging is under `service logging` (e.g. `fastly service logging s3 create`)94- Config: use `fastly config --location` to find the platform-specific CLI config file; `fastly.toml` is the project manifest9596## Common Flag Examples9798These are the flags that cause the most confusion. Copy-paste these patterns directly.99100### Autocloning (use this every time you modify a service)101102```bash103# --autoclone automatically clones a locked version before making changes.104# Without it, you get "version is locked" errors and waste time cloning manually.105fastly service backend create --service-id $SID --version active --autoclone \106 --name my-origin --address origin.example.com --port 443 --use-ssl107108fastly service domain create --service-id $SID --version active --autoclone \109 --name cdn.example.com110```111112Always pass `--autoclone` when creating, updating, or deleting backends, domains, snippets, VCL, conditions, headers, or any other version-scoped resource. It is safe to use even on unlocked versions (it simply does nothing if the version is already editable).113114### Boolean flags (--use-ssl, --use-ssl is NOT --use-ssl true)115116```bash117# CORRECT - boolean flags are bare, no value118fastly service backend create --name origin --address example.com --port 443 --use-ssl119120# WRONG - do not pass a value to boolean flags121fastly service backend create --name origin --address example.com --port 443 --use-ssl true122```123124Other boolean flags that work the same way: `--auto-yes`, `--non-interactive`, `--verbose`, `--quiet`, `--autoclone`.125126### Domain creation (requires --name flag)127128```bash129# CORRECT130fastly service domain create --service-id $SID --version active --autoclone --name cdn.example.com131132# WRONG - domain is not a positional argument133fastly service domain create --service-id $SID --version active cdn.example.com134135# WRONG - there is no -d flag136fastly service domain create --service-id $SID --version active -d cdn.example.com137```138139### Stats (historical and real-time)140141```bash142# Historical stats by day for a date range (JSON output)143fastly stats historical --service-id $SID --by day \144 --from "2026-02-01" --to "2026-03-01" --json145146# Real-time stats (last second)147fastly stats realtime --service-id $SID --json148```149150The `--by` flag accepts: `day`, `hour`, `minute`. The `--from` and `--to` flags use quoted date strings. Use `--json` for JSON output on stats commands.151152## Propagation Delays153154Changes propagate across Fastly's network in seconds to minutes (up to 10 min for version activations, up to 5 min for TLS). Cache purges are 1-2 seconds. Retry with backoff when verifying changes.155156**New service activation sequence**: After activating a brand new service, expect 500 "Domain Not Found" for 10-60 seconds while the domain propagates to edge POPs. This is normal — do not change configuration. Wait and retry. After version updates (e.g., fixing backend settings), allow 15-30 seconds for the new version to propagate.157158## KV Store Gotchas159160- **Link before use**: A KV store must be linked to a service version before Compute code can access it. Use `fastly kv-store create` then `fastly service resource-link create --resource-id STORE_ID --service-id $SID --version active --autoclone`.161- **Eventual consistency**: Read-after-write is eventually consistent. A key you just wrote may not be readable for a few seconds. Do not rely on immediate read-back in scripts; add a short delay or retry loop.162- **Entry size limit**: Individual KV store entries are limited to 25 MB. Plan accordingly for large values.163- **Listing stores**: `fastly kv-store list` lists all stores on the account, not per-service. Use `fastly service resource-link list` to see which stores are linked to a given service.164165## Host Header Override Pattern166167When the origin hostname differs from the desired Host header (e.g., origin is `example.com` but you want to send `Host: download.example.com`), use `--override-host` on the backend:168169```bash170fastly service backend create --service-id $SID --version 1 \171 --name my-origin --address example.com --port 443 --use-ssl \172 --override-host download.example.com \173 --ssl-cert-hostname example.com --ssl-sni-hostname example.com174```175176The `--override-host` value is the Host header sent to the origin. The `--ssl-cert-hostname` and `--ssl-sni-hostname` must match the origin's TLS certificate (usually the `--address` value). Getting these backwards causes 503 errors.177178## Service List Completeness179180When enumerating services (e.g., for bandwidth stats), use `fastly service list --json`.181The command follows API pagination internally and returns all pages unless you explicitly start from a later `--page`.182Services with zero traffic still appear in the list, so loop over every returned service ID instead of relying on stats APIs that omit zero-traffic services.183184## New VCL Service Setup Workflow185186Use this sequence to stand up a new VCL caching service end-to-end. Each step includes a validation checkpoint.1871881. **Pre-flight** — verify the origin responds and check its TLS certificate SANs:189190 ```bash191 curl -sI -H "Host: DESIRED_HOST" https://ORIGIN_ADDRESS/192 echo | openssl s_client -connect ORIGIN_ADDRESS:443 -servername ORIGIN_ADDRESS 2>/dev/null | \193 openssl x509 -noout -text | grep -A1 "Subject Alternative Name"194 ```195196 _Checkpoint: origin returns 200 and the backend `ssl-cert-hostname` matches the served cert. If no HTTPS SNI/cert combination validates but HTTP with that Host works, use `--port 80` or fix the origin cert; do not disable verification._1971982. **Create service** — note the service ID from the output:199200 ```bash201 fastly service create --name "my-service" --non-interactive202 ```2032043. **Add domain + backend on version 1** (do NOT use `--autoclone` or `--version latest` on a new service):205206 ```bash207 fastly service domain create --service-id $SID --version 1 \208 --name my-service.global.ssl.fastly.net209210 fastly service backend create --service-id $SID --version 1 \211 --name origin --address ORIGIN_ADDRESS --port 443 --use-ssl \212 --override-host ORIGIN_ADDRESS \213 --ssl-cert-hostname ORIGIN_ADDRESS --ssl-sni-hostname ORIGIN_ADDRESS214 ```2152164. **Validate version** before activating:217218 ```bash219 fastly service version validate --service-id $SID --version 1220 ```221222 _Checkpoint: validation returns success (no missing domain/backend errors)._2232245. **Activate**:225226 ```bash227 fastly service version activate --service-id $SID --version 1228 ```2292306. **Verify propagation** — wait 15-30s, then test with GET (not HEAD):231232 ```bash233 curl -sS -D - -o /dev/null https://my-service.global.ssl.fastly.net/ | head -1234 ```235236 _Checkpoint: 200 OK. If 500 "Domain Not Found", wait and retry (normal for 10-60s). If 503, check backend SSL settings._237238See [services.md](references/services.md) for advanced workflows (custom domains with TLS, host header overrides, live service updates).239240## Troubleshooting241242See [troubleshooting.md](references/troubleshooting.md) for the full list. Key pitfalls are covered inline above: SSL hostname flags (see Host Header Override Pattern), boolean flags and domain `--name` (see Common Flag Examples), `--autoclone` (see Key Patterns), and token safety (see Key Patterns).