What Is API Security? How Cloudflare API Shield Works
On this page13 items
The last topic in Chapter 2 is API security. The pages so far have mostly been about protecting “websites that humans view in a browser”, but behind modern web services there’s a huge volume of traffic in which programs exchange data directly with each other: APIs. Smartphone apps, integrations with other companies’ services, and the AI agents covered in later chapters are all built on top of APIs.
And APIs need to be protected differently from websites. This page starts with a refresher on what an API is, then looks at why dedicated protection is needed and how Cloudflare’s API Shield provides it. As the finale of Chapter 2, it also sorts out how the work is divided among the features covered so far.
What you’ll learn on this page#
- What an API (Application Programming Interface) is
- Why APIs need different protection from websites
- The main features of API Shield (mTLS, schema validation, API Discovery)
- What’s available on which plan
- Points beginners should watch out for
What is an API?#
An “order window” between programs#
An API (Application Programming Interface) is a set of rules (a window) that lets one program use the functions or data of another. Take a weather app: the app itself doesn’t observe the weather. It sends a request like “tell me today’s weather in Tokyo” to a weather data company’s API and simply displays the data that comes back (sunny, high of 34°C…) on screen.
The difference from a web page for humans is “the shape of what comes back”. A web page returns HTML (a styled document) for humans to read, while an API returns raw data for programs to process (today, a format called JSON is the norm). To use a restaurant analogy: if a website is “meals served in the dining room”, an API is “the wholesale counter for businesses”. Both connect to the same kitchen (servers and databases), but the nature of the window is completely different.
APIs are a “tasty” entry point for attackers#
From an attacker’s point of view, this wholesale counter is an attractive target.
- It’s directly connected to data: APIs return structured data in bulk, so when one is breached, the data leak tends to be large
- Human verification can’t be used: The users of an API are legitimate programs. Inserting browser-based challenge pages or “human checks” like Turnstile would break legitimate apps too. Some of the defenses covered in Chapter 2 can’t be used as is
- They’re easily forgotten: APIs created during development sometimes stay exposed long after even the administrators have forgotten about them (these are called shadow APIs or zombie APIs). You can’t protect what you don’t know exists
For these reasons, “API security” has become a field of its own alongside WAF and bot protection, and Cloudflare’s answer is API Shield (its API Security product suite).
Main features of API Shield#
API Shield’s defenses are easiest to understand when organized into three perspectives: “verify who is connecting”, “verify the contents”, and “know what exists”.

mTLS: verify the “party” connecting with a certificate#
On the SSL/TLS page in Chapter 1, you learned how servers prove their identity with certificates. In normal HTTPS, only the server proves itself; any client (the side connecting) can connect.
mTLS (mutual TLS) makes this two-way. Certificates are also issued to clients and built into devices or apps, and at connection time the server checks “does this client have a valid certificate?” Connections without a certificate are turned away at the door without even looking at the request contents. It’s extremely effective for “APIs with a fixed set of permitted clients”, such as an API used only by your own smartphone app or traffic from IoT devices. Cloudflare provides the certificate authority used to issue client certificates, so mTLS itself can be set up on every plan.
Schema validation: verify the request is “according to spec”#
For APIs, there’s a standard (OpenAPI schemas) for writing specifications like “send data in this format to this URL” in a machine-readable form. Schema Validation is a feature where you upload this specification to Cloudflare and it blocks requests that don’t match it.
If the WAF’s managed rules are a blocklist approach that “rejects anything matching known attack patterns”, schema validation is an allowlist approach that “permits only what matches the spec”. Attacks using unexpected parameters or abnormal values can be rejected simply because they’re “not in the spec”, even if the pattern is unknown. It’s a defense suited to APIs, made possible precisely because APIs can have strictly defined specifications.
API Discovery: “discover” the APIs you need to protect#
API Discovery analyzes the traffic flowing through Cloudflare and automatically identifies the API endpoints (the individual URLs of an API) that are actually in use. Shadow APIs the administrators didn’t know about are surfaced here too. Discovered endpoints are registered in a list (Endpoint Management), where you monitor error rates and response times and apply the Rate Limiting and schema validation covered in earlier pages. You could call it the feature that “builds the inventory of what you protect”.
Beyond these, there are more advanced features for Enterprise, such as validating identity information for logged-in users (tokens called JWTs) and detecting anomalies in the order in which APIs are called (Sequence Analytics).
Which plans include it#
The full API Shield feature set (API Discovery, advanced validation and analytics) mainly comes as an add-on to the Enterprise plan, but the basics are also available on the regular plans (as of August 2026).
- Available on all plans: mTLS (client certificates issued by Cloudflare), manual endpoint registration and monitoring (up to 100 on Free), basic schema validation (with limits on the number of specifications you can upload, among other things)
- Enterprise + API Shield subscription: automatic discovery with API Discovery, JWT validation, Sequence Analytics, much higher registration limits, and more
If you’re just publishing an API as a personal project, the free combination of “Rate Limiting + WAF custom rules + mTLS if needed” already provides solid protection. Think of it this way: once you’re running a business built on APIs, consider a full API Shield deployment.
Points beginners should watch out for#
- First, figure out “which of these are my APIs”: WordPress has an API too (the REST API, the part whose URLs start with /wp-json/). Knowing what you’re protecting is the first step in API security
- Watch out for false positives from bot protection and the WAF: As mentioned on the previous page, bot protection tends to classify API and app traffic as “automation”. API URLs need different handling from human-facing pages, such as using blocks or Rate Limiting instead of challenges, or writing exclusion rules
- Schema validation lives and dies by how current the spec is: If you update an API but forget to update the schema, legitimate requests get blocked. Build “update the schema” into your API development process
- Authentication itself is the API’s responsibility: API Shield validates traffic, but access control, meaning “who may receive which data”, is a matter of application design. If that’s broken, neither the WAF nor schema validation can protect you
- HTTPS is a basic prerequisite: If API keys or tokens travel in plain text, every other defense is meaningless. The SSL/TLS knowledge from Chapter 1 is the foundation here too
Related services#
- Rate Limiting: limits on the number of API calls. The first step in protecting an API (two pages back)
- WAF: content inspection that also applies to APIs. Use it layered with schema validation
- Bot Management: the Enterprise version can also classify bots in API traffic
- Workers: Cloudflare’s serverless runtime for when you’re the one building the API (Chapter 5)
Summary#
- An API is a window through which programs exchange data, and it needs different protection from human-facing web pages
- “Human verification can’t be used”, “directly connected to data”, and “easily forgotten” are risks specific to APIs
- API Shield has three pillars: mTLS to verify the party, schema validation to verify the contents, and API Discovery to know what exists
- mTLS and the basics of endpoint management and schema validation are available on all plans. Automatic discovery and advanced analytics are Enterprise territory
- At a personal scale, the free setup of “Rate Limiting + WAF + mTLS if needed” can provide practical protection
That completes Chapter 2, “Web Security”. DDoS (volume), WAF (contents), bot protection (identity), Rate Limiting (frequency), Turnstile (forms), API Security (program-to-program traffic): I hope it’s now clear that the basic shape of web security is stacking layers of defense for each type of attack. From the next chapter, the perspective shifts to the world of Zero Trust, which is about “protecting internal systems and users”.