Skip to content

quant rules

Deploy rules that run an edge function, an auth function or a filter function. The rules live in a JSON file in your repository.

Terminal window
quant rules <file> [--functions <manifest>] [--dry-run] [--force]

quant rules calls the platform API, not the content API. It does not use the project token that other commands use.

Setting Value
QUANT_API_TOKEN (or --api-token) A separate project-scoped token with projects:read, rules:read and rules:write.
QUANT_BASE_URL (or --api-base-url) {dashboard}/api/v2: https://dashboard.quantcdn.io/api/v2 on QuantCDN, https://dash.quantgov.cloud/api/v2 on QuantGov. HTTPS only.
Customer and project -c and -p, QUANT_CLIENT_ID and QUANT_PROJECT, or quant.json.

The command ignores QUANT_TOKEN, -t and the token in quant.json.

{
"version": 1,
"namespace": "orbit",
"rules": [
{ "id": "api", "type": "function", "urls": ["/api/*"], "weight": 10, "function_ref": "orbit-api-v1" }
]
}
  • version is 1. namespace is a stable name for your set of rules (^[a-z][a-z0-9-]{0,47}$). A file holds at most 100 rules and 64 KiB.
  • Each rule has a unique lowercase id, a type (function, auth or filter), urls, a numeric weight and either function_ref or function_uuid.
  • weight runs lowest first, from -100000 to 100000. A negative weight runs before any rule added in the dashboard or API. Give authentication rules a lower weight than the functions they protect.
  • function_ref is the id of an entry in the functions manifest (--functions) with the same type. Use function_uuid only for a function the manifest does not define. The function needs a version 1 to 5 UUID.
  • Optional: name, domains, methods, disabled.

A deploy changes only rules with the same namespace and id. It keeps all other rules. To turn a rule off, set disabled: true.

Rules deployed this way show as read-only in the dashboard and the rules API. If someone changed one outside code, the deploy writes nothing, exits non-zero and lists the changed fields. Use --force to overwrite them. --force never takes over a rule that this file did not create.

Terminal window
export QUANT_API_TOKEN=...
export QUANT_BASE_URL=https://dashboard.quantcdn.io/api/v2
quant rules quant/edge-rules.json --functions quant/edge-functions.json -c ORG -p PROJECT --dry-run
quant functions quant/edge-functions.json -c ORG -p PROJECT
quant rules quant/edge-rules.json --functions quant/edge-functions.json -c ORG -p PROJECT

--dry-run checks permissions and previews the changes without writing. Deploy the functions first so their UUIDs exist.