All services / Security / API Shield
πŸ”Œ
Security

API Shield

Discover, validate, and lock down every API endpoint with schemaschemaA definition of exactly what a valid request looks like; validation rejects anything that doesn't match. enforcement and mTLSmTLSMutual TLS β€” both the client and the server present certificates to prove who they are; strong two-way authentication. β€” because APIsAPIApplication Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server. are today's #1 attack surface.

What it is

API Shield secures your APIsAPIApplication Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server. specifically. It automatically discovers every API endpoint from live traffic, enforces that requests match your OpenAPI schemaOpenAPIA standard file format that describes an API's structure, so tools can automatically validate requests against it., requires client certificates (mTLSmTLSMutual TLS β€” both the client and the server present certificates to prove who they are; strong two-way authentication.) for sensitive calls, and detects abnormal usage β€” closing the gaps that traditional web security misses.

Why it helps the client

  • Full visibility β€” automatically discovers and inventories all API endpoints, including shadow APIs.
  • Positive security β€” schema validation rejects malformed or malicious calls before they hit origin.
  • Strong auth β€” mTLS ensures only trusted clients (mobile apps, partners) can call sensitive APIs.
  • Stops API-specific abuse: broken object-level authorization, scraping, and volumetric attacks.

Why they'd want it

  • APIs are now the #1 attack vector β€” this protects the crown jewels.
  • Zero-trust and compliance for machine-to-machine traffic.
  • Surface shadow and undocumented APIs they didn't know were exposed.

πŸ”¬ How it actually works

  • API Shield is positive security for APIsAPIApplication Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server.: it discovers endpoints from live traffic (including undocumented 'shadow' APIs), inventories them with request volume and auth status, and enforces that requests conform to your OpenAPI schemaOpenAPIA standard file format that describes an API's structure, so tools can automatically validate requests against it. β€” rejecting wrong types, extra fields, or bad methods before originoriginYour own web server or host where your website actually lives. Cloudflare sits in front of it..
  • mTLSmTLSMutual TLS β€” both the client and the server present certificates to prove who they are; strong two-way authentication. issues and validates client certificates so only trusted clients β€” your mobile app, named partners β€” can call sensitive endpoints, giving strong machine-to-machine authentication a generic WAFWAFWeb Application Firewall β€” inspects web requests and blocks malicious ones (like SQL injection and XSS) before they reach your site. can't.
  • Additional layers include JWT/token validation, Sequence Analytics for abuse and business-logic attacks, GraphQL malicious-query protection, and APIAPIApplication Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server.-specific rate limiting.
  • It complements the WAFWAFWeb Application Firewall β€” inspects web requests and blocks malicious ones (like SQL injection and XSS) before they reach your site.: the WAF blocks known-bad patterns (negative security); APIAPIApplication Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server. Shield only allows known-good, schemaschemaA definition of exactly what a valid request looks like; validation rejects anything that doesn't match.-valid, authenticated calls (positive security).

πŸ“– Key terms on this page hover any underlined term anywhere on the site for its definition

mTLS
Mutual TLS β€” both the client and the server present certificates to prove who they are; strong two-way authentication.
API
Application Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server.
OpenAPI
A standard file format that describes an API's structure, so tools can automatically validate requests against it.
schema
A definition of exactly what a valid request looks like; validation rejects anything that doesn't match.
origin
Your own web server or host where your website actually lives. Cloudflare sits in front of it.
WAF
Web Application Firewall β€” inspects web requests and blocks malicious ones (like SQL injection and XSS) before they reach your site.

Live demo walkthrough

5 steps

Screens below are annotated recreations of the Cloudflare dashboard. The numbered orange pin marks exactly where to click.

1

Select the website

πŸ‘† Account Home β†’ example.com
πŸ”’dash.cloudflare.com
example.com β–Ύ
Test Account NickN

πŸ‘‰ Do this

Open the site that serves your APIs.

πŸ’¬ Say this

β€œMost modern traffic is API traffic β€” let's secure it specifically, beyond the general WAF.”

2

Open Security β†’ API Shield

πŸ‘† Left nav β†’ Security β†’ API Shield
πŸ”’dash.cloudflare.com/example.com/security/api-shield
example.com β–Ύ
Test Account NickN

Security

API Shield

Endpoint ManagementSchema ValidationSettings
Managed endpoints 37 discovered
MethodEndpointRequests (24h)Schema
GET/api/v1/users/{id}1.2MValid
POST/api/v1/orders420KEnforced
POST/api/v1/login96KmTLS
Schema validationReject requests that don't match your OpenAPI schema before they hit origin.

πŸ‘‰ Do this

Expand Security and click API Shield.

πŸ’¬ Say this

β€œAPI Shield is purpose-built for APIs. The general WAF stops generic attacks; this understands your API's structure.”

3

Show endpoint discovery

πŸ‘† API Shield β†’ Endpoint Management
πŸ”’dash.cloudflare.com/example.com/security/api-shield
example.com β–Ύ
Test Account NickN

Security

API Shield

Endpoint ManagementSchema ValidationSettings
Managed endpoints 37 discovered
MethodEndpointRequests (24h)Schema
GET/api/v1/users/{id}1.2MValid
POST/api/v1/orders420KEnforced
POST/api/v1/login96KmTLS
3
Schema validationReject requests that don't match your OpenAPI schema before they hit origin.

πŸ‘‰ Do this

Point to the discovered endpoints inventory with per-endpoint traffic.

πŸ’¬ Say this

β€œAPI Shield automatically discovers every endpoint from real traffic β€” including shadow APIs teams forgot were live. Here's the inventory with request volume, so we can see exactly what's exposed.”

4

Enforce schema & mTLS

πŸ‘† API Shield β†’ Schema Validation β†’ Upload schema
πŸ”’dash.cloudflare.com/example.com/security/api-shield?tab=schema
example.com β–Ύ
Test Account NickN

Security

API Shield

Endpoint ManagementSchema ValidationSettings
Managed endpoints 37 discovered
MethodEndpointRequests (24h)Schema
GET/api/v1/users/{id}1.2MValid
POST/api/v1/orders420KEnforced
POST/api/v1/login96KmTLS
Schema validationReject requests that don't match your OpenAPI schema before they hit origin.

πŸ‘‰ Do this

Upload the OpenAPI schema; add mTLS on the most sensitive endpoints.

πŸ’¬ Say this

β€œWe upload the OpenAPI schema and Cloudflare rejects anything that doesn't match β€” wrong types, extra fields, bad methods. For the crown-jewel endpoints we add mTLS, so only our mobile app's client certificate can even call them.”

5

Catch violations in Events

πŸ‘† Left nav β†’ Security β†’ Events
πŸ”’dash.cloudflare.com/example.com/security/events
example.com β–Ύ
Test Account NickN

Security

Events

Add filter β–Ύ5
Sampled logs
ActionServiceHostSource IPRule
BlockWAFexample.com203.0.113.9SQLi – Managed
BlockRate limitingapi.example.com198.51.100.2Login throttle
Managed challengeBot Managementexample.com192.0.2.44Score < 30
BlockAPI Shieldapi.example.com203.0.113.5Schema violation
BlockWAFexample.com203.0.113.77XSS – Managed

πŸ‘‰ Do this

Open Events and point to the API Shield schema-violation block.

πŸ’¬ Say this

β€œThe instant a request breaks the contract, it shows up here as an API Shield schema violation β€” blocked before it ever reached the origin. This is positive security in action: we don't guess what's malicious, we allow only what's valid.”

Questions clients ask

Tap a question to reveal the answer to say
Why do we need this if we already have a WAF?β€Ί
A WAFWAFWeb Application Firewall β€” inspects web requests and blocks malicious ones (like SQL injection and XSS) before they reach your site. blocks known attacks β€” negative security. APIsAPIApplication Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server. need positive security: only allow requests that match your schema and come from authenticated clients. API Shield adds discovery, schema validationschemaA definition of exactly what a valid request looks like; validation rejects anything that doesn't match., and mTLSmTLSMutual TLS β€” both the client and the server present certificates to prove who they are; strong two-way authentication. that a generic WAF doesn't provide.
How does discovery find 'shadow' APIs?β€Ί
It learns endpoints from real traffic, surfacing ones nobody documented or forgot to decommission β€” often the riskiest endpoints you have.
Is mTLS painful to roll out?β€Ί
Cloudflare can issue and manage the client certificates, and you enforce mTLSmTLSMutual TLS β€” both the client and the server present certificates to prove who they are; strong two-way authentication. only on the sensitive endpoints (say, mobile-only APIsAPIApplication Programming Interface β€” how software talks to other software, e.g. a mobile app calling a server.), so rollout stays scoped and manageable.
What about GraphQL or non-REST APIs?β€Ί
There's malicious-query protection for GraphQL, and schema validationschemaA definition of exactly what a valid request looks like; validation rejects anything that doesn't match. covers REST via OpenAPIOpenAPIA standard file format that describes an API's structure, so tools can automatically validate requests against it. β€” so it's not REST-only.
APIs are our biggest worry β€” where do we start?β€Ί
Turn on discovery to get the inventory, enforce schemaschemaA definition of exactly what a valid request looks like; validation rejects anything that doesn't match. on your highest-value endpoints, then add mTLSmTLSMutual TLS β€” both the client and the server present certificates to prove who they are; strong two-way authentication. and rate limits on the crown-jewel calls.