Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/api-shield/api.md
1# API Reference23Base: `/zones/{zone_id}/api_gateway`45## Endpoints67```bash8GET /operations # List9GET /operations/{op_id} # Get single10POST /operations/item # Create: {endpoint,host,method}11POST /operations # Bulk: {operations:[{endpoint,host,method}]}12DELETE /operations/{op_id} # Delete13DELETE /operations # Bulk delete: {operation_ids:[...]}14```1516## Discovery1718```bash19GET /discovery/operations # List discovered20PATCH /discovery/operations/{op_id} # Update: {state:"saved"|"ignored"}21PATCH /discovery/operations # Bulk: {operation_ids:{id:{state}}}22GET /discovery # OpenAPI export23```2425## Config2627```bash28GET /configuration # Get session ID config29PUT /configuration # Update: {auth_id_characteristics:[{name,type:"header"|"cookie"}]}30```3132## Token Validation3334```bash35GET /token_validation # List36POST /token_validation # Create: {name,location:{header:"..."},jwks:"..."}37POST /jwt_validation_rules # Rule: {name,hostname,token_validation_id,action:"block"}38```3940## Workers Integration4142### Access JWT Claims43```js44export default {45async fetch(req, env) {46// Access validated JWT payload47const jwt = req.cf?.jwt?.payload?.[env.JWT_CONFIG_ID]?.[0];48if (jwt) {49const userId = jwt.sub;50const role = jwt.role;51}52}53}54```5556### Access mTLS Info57```js58export default {59async fetch(req, env) {60const tls = req.cf?.tlsClientAuth;61if (tls?.certVerified === 'SUCCESS') {62const fingerprint = tls.certFingerprintSHA256;63// Authenticated client64}65}66}67```6869### Dynamic JWKS Update70```js71export default {72async scheduled(event, env) {73const jwks = await (await fetch('https://auth.example.com/.well-known/jwks.json')).json();74await fetch(`https://api.cloudflare.com/client/v4/zones/${env.ZONE_ID}/api_gateway/token_validation/${env.CONFIG_ID}`, {75method: 'PATCH',76headers: {'Authorization': `Bearer ${env.CF_API_TOKEN}`, 'Content-Type': 'application/json'},77body: JSON.stringify({jwks: JSON.stringify(jwks)})78});79}80}81```8283## Firewall Fields8485### Core Fields86```js87cf.api_gateway.auth_id_present // Session ID present88cf.api_gateway.request_violates_schema // Schema violation89cf.api_gateway.fallthrough_triggered // No endpoint match90cf.tls_client_auth.cert_verified // mTLS cert valid91cf.tls_client_auth.cert_fingerprint_sha25692```9394### JWT Validation (2026)95```js96// Modern validation syntax97is_jwt_valid(http.request.jwt.payload["{config_id}"][0])9899// Legacy (still supported)100cf.api_gateway.jwt_claims_valid101102// Extract claims103lookup_json_string(http.request.jwt.payload["{config_id}"][0], "claim_name")104```105106### Risk Labels (2026)107```js108// BOLA detection109cf.api_gateway.cf-risk-bola-enumeration // Sequential resource access detected110cf.api_gateway.cf-risk-bola-pollution // Parameter pollution detected111112// Authentication posture113cf.api_gateway.cf-risk-missing-auth // Endpoint lacks authentication114cf.api_gateway.cf-risk-mixed-auth // Inconsistent auth patterns115```116117## BOLA Detection118119```bash120GET /user_schemas/{schema_id}/bola # Get BOLA config121PATCH /user_schemas/{schema_id}/bola # Update: {enabled:true}122```123124## Auth Posture125126```bash127GET /discovery/authentication_posture # List unprotected endpoints128```129130## GraphQL Protection131132```bash133GET /settings/graphql_protection # Get limits134PUT /settings/graphql_protection # Set: {max_depth,max_size}135```136137## See Also138139- [configuration.md](configuration.md) - Setup guides for all features140- [patterns.md](patterns.md) - Firewall rules and common patterns141- [API Gateway API Docs](https://developers.cloudflare.com/api/resources/api_gateway/)142