Skip to content

ApiShieldOperation

Source: src/Cloudflare/ApiShield/Operation.ts

A Cloudflare API Shield operation — a registered API endpoint on a zone, identified by the (method, host, endpoint) tuple. Registered operations are the unit other API Shield features (schema validation, rate limiting recommendations, API Discovery) attach to.

An operation is pure identity: there is no update API, so changing any property triggers a replacement. Cloudflare upserts by identity — creating an already-registered tuple returns the existing operation — which makes reconciliation race-free.

Endpoint paths may contain {placeholder} templates; Cloudflare normalizes the variable names left-to-right to {var1}, {var2}, … and the normalized form is what is stored and diffed.

Register a GET endpoint

const op = yield* Cloudflare.ApiShieldOperation("GetUser", {
zoneId: zone.zoneId,
method: "GET",
host: "api.example.com",
endpoint: "/api/v1/users/{id}",
});
// op.endpoint === "/api/v1/users/{var1}"

Register a POST endpoint

yield* Cloudflare.ApiShieldOperation("CreateUser", {
zoneId: zone.zoneId,
method: "POST",
host: "api.example.com",
endpoint: "/api/v1/users",
});