Cloud Endpoints in Google Cloud: A Front Door for Your APIs
A complete, plain-English guide to Cloud Endpoints: how the proxy, the service configuration and the control services work together to secure, monitor and manage your APIs, and how to use them well in real projects.
Picture a large office building with one hundred small companies inside. If every visitor could wander in through any door, the building would be chaos. Instead, there is a reception desk at the front. The receptionist checks who you are, looks at your appointment, notes the time you arrived, and only then lets you walk to the right floor. The companies upstairs can focus on their work because someone else handles the entrance.
Cloud Endpoints is that reception desk for your application programming interfaces, usually called APIs. Your backend code does the real work. Cloud Endpoints stands at the front, checking identities, counting visitors, writing the visitor log and keeping a record of how long each visit took. This tutorial explains every part of it, step by step, in simple language, with no prior knowledge needed.
1What Cloud Endpoints Actually Is
An API management service from Google Cloud that protects, monitors and controls access to your APIs.
An API is a set of doors that one piece of software uses to talk to another. A mobile app asks a server for a list of orders. A website asks a server to save a new customer. Each of these requests goes through an API. As soon as an API is used by more than a handful of people or programs, you need answers to hard questions. Who is calling? Are they allowed? How often are they calling? Is anything breaking? Which method is the slowest?
Cloud Endpoints is Google Cloud’s service for answering those questions. It is an API management system that helps you develop, deploy, secure and monitor your APIs. You describe your API in a specification file, you place a small proxy in front of your backend, and Google’s management services take care of checking credentials, collecting logs and metrics, and enforcing the rules you chose.
You can describe an API with an OpenAPI specification or with gRPC. Your backend can run on several Google Cloud compute platforms. The backend itself stays yours, written in the language you like, hosted where you like. Cloud Endpoints never replaces your business logic. It wraps it.
Think of a theatre box office. The actors on stage are your backend code. The box office does not act. It checks tickets, counts how many people came in, and keeps the books. If a rowdy visitor shows up without a ticket, the box office turns them away before they ever see the stage.
What it is not
Cloud Endpoints is not a place to run your code, not a database, and not a full enterprise API marketplace. It does not write your API for you. It manages an API that you have already designed. Keeping that boundary in mind makes it much easier to decide when it is the right tool, a point we return to near the end of this guide.
2Why APIs Need Management at All
An unmanaged API works fine on day one and becomes a headache by month six.
Most teams build their first API in a hurry. It returns data, it works, and everyone is happy. Over time, more clients start using it. Partners ask for access. A mobile team ships a bug that sends ten thousand requests a minute. A former employee still holds a working secret. Nobody can say which endpoint is slowest. This is the moment when API management stops being a luxury.
Who is calling?
Without identity checks, anyone who finds the address can use your API, including attackers and runaway scripts.
How much are they using?
One noisy client can slow the service for everyone. You need counts and limits per consumer.
Is it healthy?
You need request counts, error rates and latency for each method, not just a general feeling that the server is busy.
What does it promise?
Clients need a clear, written contract that says which methods exist, what they accept and what they return.
How do we change it safely?
When methods change, you need a controlled way to roll out the new description without breaking existing users.
Why not just write this inside every backend?
You could add identity checks, counters and logging into every service you write. Many teams start exactly this way. The trouble is repetition and drift. Ten services mean ten slightly different implementations of the same checks, each with its own bugs. Moving the common work into one shared layer in front of the backends means the checks are written once, tested once and kept consistent. Developers then spend their time on what makes the product special.
A good rule of thumb is that anything every API needs, such as authentication checks, request counting and logging, belongs in the front layer. Anything that is specific to your business, such as pricing rules or order validation, belongs in the backend.
3Core Vocabulary You Will Use Every Day
Eight terms unlock almost every sentence in the official documentation.
Every platform has its own language. Learn these terms once, and the rest of this guide reads like everyday English.
Backend
The program that actually does the work behind your API, such as a web service running on Cloud Run, Compute Engine or Kubernetes.
Proxy
A small server that receives every request first, applies the rules, and then forwards allowed requests to the backend. In Endpoints this is ESP or ESPv2.
Endpoints configuration
The file that describes your API: its methods, paths, security needs and settings. It is based on OpenAPI or on gRPC definitions.
Service configuration
The prepared version of that description which the proxy loads when it starts, defining the API surface and its policies.
Service Management
The Google service that stores your API description and deploys the management rules.
Service Control
The Google service that enforces rules while requests flow, using two operations called Check and Report.
API key
A simple credential that identifies the project calling your API. Service Control validates it on each call.
JWT
A JSON Web Token, a signed digital pass that proves who the caller is. The proxy checks its signature and its intended audience.
A few more words appear later. A sidecar is a proxy that runs right next to each backend instance. A remote proxy is a separate proxy service that sits in front of one or more backends. A trace token is a small label added to each request so its timing can be followed.
The backend is the kitchen. The proxy is the waiter at the door of the kitchen. The Endpoints configuration is the menu. Service Control is the manager who checks reservations and writes down every order. Everyone has a clear job.
4Architecture and Components
A proxy that your traffic meets first, and Google services that decide, record and report.
The cleanest way to understand Cloud Endpoints is to split it into two halves. One half sits in your project: the proxy and your backend. The other half is run by Google: the services that store configuration, make decisions and collect data. The proxy is the messenger between the two halves.
flowchart LR
C["API client"] --> P["Proxy: ESP or ESPv2"]
P --> B["Your backend"]
P -->|loads configuration| SM["Service Management"]
P -->|Check and Report| SC["Service Control"]
P -->|trace data| CT["Cloud Trace"]
SC --> CL["Cloud Logging"]
SC --> CM["Cloud Monitoring"]
CL --> CO["Google Cloud console"]
CM --> CO
The main building blocks
The proxy: ESP or ESPv2
ESP, the Extensible Service Proxy, is built on NGINX. ESPv2 is the newer generation built on Envoy, designed for high performance and scale. Either one receives each request, validates it using the loaded configuration, and forwards it to your backend.
Service Management
This service stores the description of your API, written as an OpenAPI or gRPC configuration, and deploys the management rules. It also helps with sharing APIs, enabling them in projects and generating API keys.
Service Control
The runtime decision maker. For every call it performs a Check, which verifies credentials and keys and decides whether the call is allowed, and later a Report, which sends logging and monitoring data onward.
Cloud Trace
Receives timing information. The proxy creates a trace token for each request and sends the final timing data after your backend has responded, so you can see where time is spent.
Cloud Logging and Cloud Monitoring
These are the destinations for the records and numbers Service Control collects. The Google Cloud console shows this data in graphs and searchable logs.
Your backend
The code you write. It can be on App Engine, Cloud Run, Compute Engine, Google Kubernetes Engine or Kubernetes, depending on which proxy you choose.
Cloud Endpoints is not a single server that you install once. It is a combination of a proxy you deploy next to your backend and managed services that Google runs. Forgetting the proxy half is the most common reason a beginner’s API seems to have no protection.
5ESP and ESPv2: Choosing Your Proxy
Two proxy generations, with different engines and different places they can run.
Both ESP and ESPv2 do the same conceptual job. They fetch the service configuration, check each request against it, call Service Control, and pass allowed requests to the backend. They differ in the engine underneath and in the platforms they support.
| Aspect | ESP | ESPv2 |
|---|---|---|
| Engine | Built on NGINX | Built on Envoy |
| Focus | The original proxy for Endpoints | Newer, designed for high performance and scale |
| Where it runs | App Engine flexible environment, Compute Engine, Google Kubernetes Engine and Kubernetes | App Engine standard, Cloud Run functions, Cloud Run, Knative serving, Compute Engine, Google Kubernetes Engine and Kubernetes |
| API styles | Documentation for the original proxy covers OpenAPI and gRPC use | OpenAPI version 2.0 and gRPC |
| Serverless backends | Not the main target | Supported, including through a remote proxy on Cloud Run |
How to choose
For a brand-new project, ESPv2 is generally the natural starting point, because it supports more platforms, including the serverless ones that many teams use today. ESP remains relevant for older deployments that already run it, and you can keep them running while you plan a gradual move. Always check the current documentation for the exact list of supported platforms before you commit, because platform support changes over time.
ESP and ESPv2 are two generations of the same model of reception desk. The newer desk fits in more kinds of buildings and handles bigger crowds. The older desk still works well where it is already installed.
Cloud Endpoints Frameworks: a third option
There is also a different flavour called Cloud Endpoints Frameworks, aimed at the App Engine standard environment. With Frameworks, you build the API using annotations and libraries in the code itself instead of writing a specification file by hand, and the framework generates the description for you. Google’s documentation provides a comparison page that explains how Frameworks differ from using ESP. For teams outside App Engine, or teams that prefer a specification-first approach, the proxy approach is the one to learn.
Decide early whether you are specification-first or code-first. Specification-first, where you write the API description and then build the backend to match, tends to produce clearer contracts and works with every language.
6Deployment Modes: Sidecar and Remote Proxy
The proxy can live next to each backend or stand alone in front of many.
Where you place the proxy changes your network path, your cost and your operations. Google describes two main modes.
flowchart TD
subgraph SIDE["Sidecar mode"]
C1["Client"] --> S1["Proxy container"]
S1 -->|local call| B1["Backend container"]
end
subgraph REMOTE["Remote proxy mode"]
C2["Client"] --> R1["Standalone proxy service"]
R1 --> B2["Backend A"]
R1 --> B3["Backend B"]
end
Sidecar mode
In sidecar mode, the proxy runs in a container alongside each backend instance, for example in the same Kubernetes pod. Because they live together, the hop from proxy to backend is local, so there is no extra network trip. This suits web APIs and microservices where you want each service to carry its own protection. The trade-off is that you deploy and update a proxy with every backend.
Remote proxy mode
In remote proxy mode, ESPv2 runs as its own standalone application, commonly on Cloud Run, and serves as the front for backends elsewhere. This is especially useful for serverless backends that cannot easily host a sidecar. One proxy instance can serve more than one backend, and routing to each backend is configured through a Google-specific extension field in the API description, named x-google-backend. The trade-off is one extra network hop and one more service to run.
Sidecar advantages
- No extra network hop between proxy and backend
- Protection travels with each service
- Scaling follows the backend automatically
- Failure of one proxy affects only its own service
Sidecar trade-offs
- A proxy must be deployed and updated with every backend
- More containers to monitor
- Not possible on every serverless platform
Remote proxy advantages
- Works well in front of serverless backends
- One place to run and update for several backends
- Backends need no changes to their own deployment
Remote proxy trade-offs
- One additional network hop
- The proxy service becomes a shared dependency that must be kept healthy
- You must secure the path between proxy and backend
With a remote proxy, teams sometimes leave the backend publicly reachable. Then clients can skip the front door entirely and call the backend directly. Always restrict the backend so that only the proxy can reach it.
7Describing Your API: OpenAPI and gRPC
The API description is the contract that drives everything else.
In Cloud Endpoints, the description of your API is not documentation that sits on a shelf. It is the working configuration that the proxy actually uses. A change in the description changes how the proxy behaves.
OpenAPI
OpenAPI is a widely used standard for describing web APIs that use ordinary HTTP. A description lists every path, the methods allowed on it, what each one accepts and returns, and which security rules apply. ESPv2 works with OpenAPI version 2.0. Because OpenAPI is a common standard, many tools can read it, which means you can generate client libraries, test tools and documentation from the same file.
gRPC
gRPC is a high-performance way for programs to call each other, often used between internal microservices. Instead of free-form paths and JSON, you define services and messages in a strongly typed format, and both sides generate code from it. Endpoints can place its management layer in front of gRPC services as well, bringing the same authentication, logging and monitoring.
| Question | OpenAPI | gRPC |
|---|---|---|
| Typical client | Browsers, mobile apps, partners | Internal services and performance-sensitive callers |
| Data style | Human-readable HTTP requests and responses | Compact, strongly typed messages |
| Contract | OpenAPI description file | Service and message definitions |
| Best for | Public and partner APIs | Service-to-service communication |
What goes into an Endpoints configuration
Identity of the API
The name and host that identify your API service, so the management services know what they are managing.
Paths and methods
Each operation your API offers, with its inputs and outputs spelled out.
Security rules
Which operations need an API key, which need a signed token, and which identity providers are trusted.
Backend routing
For remote proxy setups, where each operation should be sent after the proxy has approved it.
Limits and extras
Quota definitions and other Google-specific settings that shape how the API is managed.
The API description is the building’s floor plan and security policy combined. The receptionist reads it to know which doors exist, who may use each one, and where to send visitors.
Keep the description in version control next to your backend code, and review changes to it like any other code change. A single wrong line in the description can open or close a door for every client.
8Request Flow: What Happens to One API Call
Follow a single request from the client to the backend and back, step by step.
Understanding the life of one request clears up most confusion about Cloud Endpoints. Everything else, from authentication to monitoring, is a variation on this journey.
sequenceDiagram
participant C as Client
participant P as Proxy
participant SC as Service Control
participant B as Backend
participant L as Logging and Monitoring
C->>P: Send API request with key or token
P->>P: Match request to configured method
P->>P: Validate token signature and audience
P->>SC: Check - is this call allowed?
SC-->>P: Allow or deny decision
alt Allowed
P->>B: Forward request
B-->>P: Response
P-->>C: Return response
else Denied
P-->>C: Return error to client
end
P->>SC: Report - what happened
SC->>L: Write logs and metrics
The journey in plain steps
The client sends a request
The request carries a credential, such as an API key or a signed token, that says who is calling.
The proxy recognises the method
Using the loaded service configuration, the proxy works out which API method the request is aiming at and what rules apply to it.
Tokens are validated locally
When the method requires a signed token, the proxy itself checks the signature and audience, so this step does not need a trip to Google.
Service Control performs a Check
For rules that need Google’s knowledge, such as whether an API key is valid and whether its project has the API enabled, the proxy asks Service Control to Check the call.
The call is forwarded or refused
If the decision is to allow, the proxy forwards the request to your backend. If not, the client receives an error and the backend never sees the request.
A Report is sent
After the response, the proxy reports the outcome to Service Control, which writes logs and metrics to Cloud Logging and Cloud Monitoring. Timing data goes to Cloud Trace.
Why this design is clever
Because the proxy has already loaded the rules, most of the routine work is done close to your backend, so requests stay fast. Only the parts that genuinely need Google’s central knowledge cross over to Service Control. Meanwhile, your backend can assume that anything which reaches it has already been checked, which keeps backend code simple.
Remember that a denied call never reaches your backend. When a client says “my request disappeared”, look first at the proxy’s logs and the Endpoints dashboards, not the backend’s logs.
9Lifecycle: From Description to a Running Protected API
Write the contract, publish it, deploy the proxy, and roll out changes with care.
Putting an API under Endpoints management follows a repeatable path. Knowing the stages helps you plan who does what and where mistakes are most likely to appear.
flowchart TD
A["Design the API contract"] --> B["Write the Endpoints configuration"]
B --> C["Publish it to Service Management"]
C --> D["Deploy backend with proxy"]
D --> E["Proxy loads service configuration"]
E --> F["Clients call the API"]
F --> G["Observe logs, metrics, traces"]
G --> H{"Change needed?"}
H -->|Yes| B
H -->|No| F
Stage by stage
Design
Agree on resources, methods, names and error behaviour before any code. Good design here saves many breaking changes later.
Describe
Write the OpenAPI or gRPC description, including the security and routing details the proxy needs.
Publish
Send the description to Service Management, which stores it as a versioned service configuration.
Deploy
Run your backend together with the proxy on a supported platform, telling the proxy which configuration to use.
Operate
Watch dashboards and logs, handle consumers, and respond to incidents.
Evolve
Change the description, publish a new configuration version, and redeploy the proxy so it loads the update.
An important detail about updates
The proxy loads its configuration when it starts, as the documentation describes it. That means publishing a new configuration in Service Management is not the same as having the running proxies use it. The proxies must be told to pick up the new version, usually by redeploying or restarting them against the new configuration. Many teams are surprised when a published change seems to have no effect, and this is almost always the reason.
Treating publication as deployment. After publishing, confirm which configuration version each running proxy is actually using, and only then announce the change to API consumers.
Roles in the lifecycle
Different people touch different stages. API designers own the contract. Backend developers own the implementation. Platform or operations engineers own the proxy deployment. Security reviewers check the authentication rules. Support teams read the dashboards. Writing this division down early avoids the situation where everyone assumes someone else is watching the controls.
10Authentication: Proving Who the Caller Is
API keys, signed tokens and service accounts each answer the identity question in a different way.
Authentication means proving identity. Cloud Endpoints supports several approaches, and you can use different ones for different methods in the same API. Choosing well is one of the most important decisions in your design.
| Method | What it proves | Best for | Main caution |
|---|---|---|---|
| API key | Which project is calling | Identifying and counting calling applications, simple partner access | Keys are easy to copy, so they do not prove the identity of a person |
| JWT from a trusted provider | Which user or service is calling | User-facing apps that sign in through an identity provider | Audience and issuer must be configured correctly |
| Google ID token | A Google identity, including service accounts | Calls between services running on Google Cloud | The token must be minted for the right audience |
| Service account | A non-human workload identity | Microservice-to-microservice calls | Grant each account only the access it needs |
API keys: simple and limited
An API key is a long string that a client includes with each request. Service Control checks that the key is valid and that the project it belongs to has enabled your API. This gives you a clear picture of which application is calling, which is useful for counting and for quotas. But a key only identifies the project, not a particular person, and anyone who obtains the key can use it. Treat keys as identifiers, not as strong secrets.
JWT validation: stronger identity
A JSON Web Token is a signed pass issued by an identity provider after the user signs in. The proxy checks two things: that the signature is genuine, and that the token was intended for your API, which is called the audience. Tokens can also carry facts about the user, called claims, and expire after a short time, which limits the damage if one leaks.
An API key is like a company name badge that lists the business but not the employee. A JWT is like a passport with a photo, a stamp from an issuing office and an expiry date. Both are useful, but they answer different questions.
Service accounts and Google ID tokens
When one Google Cloud service calls another, a person is not involved. Instead, the calling service runs as a service account and presents an ID token that proves it. The proxy validates this token like any other. This keeps microservice traffic authenticated without sharing long-lived secrets between teams.
Mixing methods
A single API often needs several. For example, public read-only methods might need only an API key so you can count usage, while methods that change data require a signed user token, and internal admin methods require a service account. Because the rules are written per method in the description, you can fine-tune each door.
Use the strongest method each operation needs, and no weaker. Reading a public catalogue and cancelling a customer’s order are not the same risk and should not share the same lock.
11Consumers, Projects and Access Control
Knowing who your consumers are is the base for quotas, billing insight and support.
In Endpoints, a consumer is the project that calls your API. Each consumer has to enable your API in their own project before an API key from that project will be accepted. This simple rule is powerful, because it ties every call to a known project that you can measure, limit and, if necessary, switch off.
How a consumer gets access
You share the API
The API owner makes the service available to the consumer’s project through Service Management sharing.
The consumer enables it
The consumer turns the API on in their own project, which is the step Service Control checks later.
The consumer creates a key
An API key is generated in the consumer’s project, and may be restricted to specific APIs or applications.
Calls are attributed
Each call carrying that key is counted against the consumer’s project in your metrics and logs.
Practical uses of consumer identity
- Support. When a partner reports errors, you can filter logs and graphs to that one consumer.
- Fair use. Limits can be applied per consumer, so a heavy user does not harm others.
- Planning. You can see which consumers are growing and plan capacity for them.
- Offboarding. If a partner relationship ends, disabling the API in their project or deleting their key closes the door cleanly.
Restricting keys
Consumers should restrict their keys to the minimum: only your API, and where possible only certain applications or network addresses. A restricted key that leaks is far less dangerous than an unrestricted one. As an API owner, publish this advice in your onboarding material, because you cannot control how consumers store their keys.
Embedding an unrestricted key inside a public mobile app or web page. Anyone can extract it and reuse it. For anything sensitive, combine keys with signed user tokens so that a stolen key alone is not enough.
12Quotas and Fair Use
Limits protect your backend, your budget and your other customers.
Even honest clients can cause trouble. A bug in a loop, a sudden marketing success or an overeager integration can multiply traffic overnight. Quotas place a ceiling on how much each consumer may use, so one party cannot exhaust capacity that everyone shares.
What a quota is
A quota is a numeric limit on usage over a period, for example a maximum number of calls per minute for each consumer project. You define the limits in your API configuration, assign a cost to each method if some are heavier than others, and the management layer enforces them using the consumer identity from the API key. Details of the exact configuration fields live in Google’s quota documentation, and you should read the current version before designing limits because capabilities are refined over time.
A buffet restaurant lets everyone eat, but each table gets only so many plates per round. The limit is not meant to punish anyone. It keeps the kitchen from being overwhelmed and ensures every table is served.
Designing sensible limits
Start from backend capacity
Measure how many requests your backend can handle comfortably. The total of all consumer limits should relate to that figure, with room for growth.
Weight expensive methods more
A search that scans a large table costs more than a lookup by identifier. Give heavy methods a higher cost so limits reflect real load.
Offer tiers
Casual users, paying customers and strategic partners usually deserve different limits. Define tiers openly so people know what to expect and how to ask for more.
Communicate the limits
Publish the numbers in your documentation and make error responses clear, so clients can slow down gracefully instead of hammering the door.
Compared with dedicated enterprise API platforms, Endpoints offers more modest rate-limiting features. If you need very sophisticated policies, such as complex per-product plans, review the alternatives in chapter 17 before committing.
13Security Practices
The proxy is a strong front door, but it works best inside a well-secured building.
Security is more than turning on authentication. It covers how traffic is encrypted, who may change the configuration, how secrets are handled and whether attackers can skip the proxy altogether.
Encrypt traffic
Serve your API over HTTPS so that credentials and data cannot be read in transit. Cloud platforms such as Cloud Run provide HTTPS by default, while on virtual machines or Kubernetes you must arrange certificates and a secure entry point yourself. Also consider the hop between the proxy and the backend, especially in remote proxy mode.
Protect the backend from direct access
The proxy only protects traffic that goes through it. If your backend has a public address and accepts any caller, attackers will simply go around the proxy. Restrict the backend so that it accepts traffic only from the proxy, using network rules, private connectivity or identity checks between the two.
Control who can change the API
- Give only a small group the right to publish new service configurations.
- Require review of description changes, since they change security behaviour.
- Keep a history so you can see who changed what and when.
- Use separate projects for development, testing and production so experiments cannot touch live APIs.
Handle secrets with care
Never store credentials in source code or in the API description. Use Google Cloud’s secret handling features for anything sensitive, and rotate keys on a schedule. When someone leaves the team, review what they could access.
Validate on the backend too
The proxy checks identity and access, but it does not understand your business rules. Your backend should still validate inputs, enforce ownership rules such as a customer seeing only their own orders, and treat every request as potentially hostile.
Problem
The team deploys Cloud Endpoints in front of a service but leaves the backend open to the internet, assuming the proxy handles all security.
Why It’s Harmful
Anyone who discovers the backend address can bypass authentication, quotas and logging entirely. The proxy gives a false sense of safety while the real service is exposed.
Correct Approach
Make the proxy the only path to the backend. Restrict network access, require identity from the proxy, and test by trying to call the backend directly from outside.
14Monitoring, Logging, Tracing and Troubleshooting
The same front door that protects your API also records everything that passes through it.
Because every request travels through the proxy and Service Control, Cloud Endpoints gets a consistent record of API activity without you writing counting code in every service. Logs and metrics are delivered to Cloud Logging and Cloud Monitoring, and the Google Cloud console shows graphs and searchable records. Cloud Trace shows how long each request spent in each stage.
The numbers worth watching
Request volume
Calls per method and per consumer. Sudden jumps or drops are the earliest warning of problems.
Error rate
The share of requests that fail, split by client errors and server errors, because they point to different causes.
Latency
How long calls take, ideally looked at as typical and slow-end values rather than averages alone.
Rejected calls
How many requests were denied for missing keys, invalid tokens or exceeded limits. Spikes may signal attacks or broken clients.
Traces: where did the time go?
A trace breaks a slow request into pieces: time in the proxy, time waiting for Service Control and time inside your backend. If the proxy’s share is small and the backend’s share is large, you know where to look. Without traces, teams often blame the wrong layer.
Typical troubleshooting scenarios
| Symptom | Likely cause | First thing to check |
|---|---|---|
| Client receives an error about a missing or invalid key | Key not sent, wrong key, or API not enabled in the consumer’s project | Request headers and the consumer’s enabled APIs |
| Valid user token is rejected | Audience or issuer in the configuration does not match the token | Security section of the configuration and token contents |
| New method returns not found | Proxy still running an older configuration | Which configuration version the proxy loaded |
| Requests fail only for one consumer | Quota exhausted or key restricted too tightly | Consumer quota usage and key restrictions |
| High latency | Slow backend, or extra network hop in remote proxy mode | Trace breakdown by stage |
| Backend sees traffic that bypassed the proxy | Backend publicly reachable | Network and ingress rules on the backend |
Create alerts on error rate and latency before the first customer does it for you. A quiet alert policy built in week one is worth many nights of guesswork later.
15Understanding the Costs
Endpoints is billed by API calls, and the proxy and backend have their own compute bills.
Cloud Endpoints pricing is based on the number of API calls handled, reported through Service Control, which shows up as its own line on your bill. According to Google’s pricing page, the first couple of million calls each month are free, calls beyond that are charged at a rate of a few dollars per million, and very high volumes above one billion calls per month fall to a lower per-million rate. Exact numbers and currencies can change, so always check the current pricing page and the Google Cloud pricing calculator.
Costs that scale with the API
- Per-call charges once you pass the free monthly amount
- Growth in traffic from new consumers and features
Costs that sit around the API
- Compute for the backend and for the proxy, whether sidecar or remote
- Network egress and load balancing where used
- Logging and monitoring storage for high-volume APIs
- Engineering time to operate and update configurations
Keeping the bill sensible
- Estimate monthly call volume early, from real client behaviour rather than guesses.
- Use caching on the client side and sensible polling intervals so clients do not make needless calls.
- Apply quotas so a runaway client cannot generate a surprise bill.
- Review log retention and filtering for very chatty APIs.
- Right-size the proxy instances, since an oversized proxy is wasted money.
16Design Patterns and Anti-patterns
Patterns are habits that repeatedly work; anti-patterns are habits that repeatedly hurt.
Teams that run Endpoints for a while tend to converge on the same handful of habits. Here are the useful ones, followed by the traps that catch newcomers.
Patterns that work
Contract first
Write and review the API description before the backend. Reviewers can then argue about names, shapes and security while changes are still cheap.
One front door per API family
Group related services behind one proxy configuration so clients see a single consistent entry point, with the same authentication style and error behaviour.
Layered identity
Use API keys to identify applications for counting and quotas, signed tokens to identify users, and service accounts for internal calls. Each layer answers a different question.
Environments in separate projects
Run development, staging and production in separate projects with separate configurations, so a mistaken change in testing cannot affect live consumers.
Configuration in version control
Store the description beside your code, use pull requests for changes, and tie each published configuration version to a commit.
Observability from day one
Create dashboards and alerts before launch. Include per-method error rate and latency, and watch denied calls.
flowchart LR
D["Design contract"] --> R["Review in version control"]
R --> P["Publish configuration"]
P --> V["Verify proxies use it"]
V --> O["Observe dashboards and alerts"]
O --> I["Improve and iterate"]
I --> D
Anti-patterns to avoid
Problem
Every method is protected only by an API key, including methods that read private user data or change records.
Why It’s Harmful
A key identifies a project, not a person. Anyone who obtains the key, for example from a mobile app, can read or change any user’s data.
Correct Approach
Require signed user tokens for sensitive methods and enforce ownership rules in the backend. Keep keys for identification and quota purposes.
Problem
Teams edit the configuration directly in production without review or testing, then publish and forget to confirm that proxies have loaded it.
Why It’s Harmful
A small typo can open an unprotected path or block valid clients. Without verification, the team may believe a security fix is live when old proxies still run the old rules.
Correct Approach
Review every change, test in a non-production project, then confirm the live configuration version on each proxy after rollout.
Problem
Dozens of unrelated services share one huge configuration that nobody fully understands, with a single team holding the keys.
Why It’s Harmful
Every change becomes risky and slow, and one mistake can affect many unrelated products.
Correct Approach
Split configurations along natural product boundaries, assign clear owners to each, and share common rules through team conventions.
17When to Use Endpoints and When to Choose Something Else
Endpoints is a lightweight, Google-native option; other tools suit other needs.
Google Cloud offers more than one way to manage APIs, and the right choice depends on your backends, your consumers and how much management you need. The comparison below is deliberately high level, and you should confirm the current capabilities in each product’s documentation.
| Need | Good fit | Why |
|---|---|---|
| Simple, Google-native API protection with monitoring | Cloud Endpoints | Proxy-based, quick to set up, integrates with Google Cloud logging, monitoring and tracing |
| A managed gateway in front of serverless backends | API Gateway | A hosted gateway service so you do not run the proxy yourself |
| Full enterprise API program with products, plans, developer portals and advanced policies | Apigee | Positioned for advanced and comprehensive API management across large organisations |
| Internal traffic control between services in a cluster | A service mesh | Designed for service-to-service policy rather than public API management |
| Only HTTPS routing and load balancing | Cloud Load Balancing | Handles routing and scaling without API-level identity and quotas |
Situations where Endpoints shines
- Small to medium API programs on Google Cloud. You need identity checks, usage numbers and logs without a heavy platform.
- Microservices with gRPC. You want consistent authentication and metrics for internal APIs.
- Teams who like specification-first work. Your OpenAPI description is already the centre of your process.
Situations where caution is wise
- Very advanced rate limiting and monetisation. If you need detailed pricing plans, developer onboarding portals with approval flows or analytics products, a dedicated enterprise platform is likely a better fit.
- Backends outside Google Cloud. The proxy and management services are designed around Google Cloud platforms, so check carefully before using them elsewhere.
- Teams that cannot run a proxy. If you do not want to operate any proxy at all, consider a fully hosted gateway instead.
Advantages
- Simple model: description, proxy and Google management services
- Built-in logging, metrics and tracing for every API call
- Supports OpenAPI and gRPC
- Multiple authentication options, including keys, tokens and service accounts
- Sidecar or remote proxy modes for flexible placement
- Generous free monthly allowance and clear per-call pricing
Disadvantages / Trade-offs
- You operate the proxy, including updates and scaling
- ESPv2 works with OpenAPI version 2.0, which may limit newer specification features
- Rate limiting is more modest than in enterprise platforms
- Configuration changes require the proxies to load the new version
- Focused on Google Cloud backends
18Versioning, Documentation and Developer Experience
An API is a product; the people who call it are your customers.
Protection and monitoring keep an API safe, but they do not make it pleasant. Consumers judge your API by how easy it is to learn, how stable it is and how clearly it explains its mistakes. Because Endpoints is built around a written description, you already hold the raw material for good documentation.
Versioning without drama
APIs change. The challenge is changing them without breaking people who depend on today’s behaviour. Two common approaches are putting a version in the path of every method, and publishing a new configuration for a new version while keeping the old one running for a stated period. Whichever you pick, adopt a clear policy: how long old versions live, how you announce retirement, and what counts as a breaking change.
Adding an optional field
Existing clients ignore it, so nothing breaks. Usually fine within the same version.
Adding a new method
Clients that do not know about it are unaffected.
Removing or renaming a field
Clients that rely on it will fail. Needs a new version and a migration period.
Changing the meaning of a value
The hardest kind to notice, because nothing errors but results quietly become wrong.
Documentation from the description
Because OpenAPI is a common standard, many tools can turn the same description into reference pages, example requests and client libraries. Cloud Endpoints also offers developer-portal style documentation features that help consumers explore an API, and third-party reference tools can read the same file. Whatever you choose, keep the description accurate, since stale documentation is worse than none.
Helpful error behaviour
- Return clear messages that say what went wrong and how to fix it.
- Use consistent error shapes across all methods.
- Tell clients when they hit a limit, and when they may try again.
- Never leak internal details such as stack traces or internal addresses.
Give new consumers a working “first call” example that takes under ten minutes. The faster someone succeeds once, the more likely they are to build on your API.
19Real-World Scenarios
Four illustrative situations showing where Endpoints fits.
The scenarios below are illustrative composites, not case studies of specific named companies.
Scenario 1: A mobile app and its backend
A food-delivery start-up has an iOS and Android app talking to a backend on Cloud Run. The team places ESPv2 in front, describes the API with OpenAPI, and requires signed user tokens from its sign-in provider for ordering methods. Menu browsing needs only an API key so usage can be counted per app version. Dashboards show which method is slowest, and the team fixes a slow restaurant search within a day of launch.
Scenario 2: A partner integration programme
A logistics company lets shipping partners query tracking data. Each partner enables the API in their own project and receives a restricted API key. Quotas stop one partner’s overnight batch job from starving others, and logs filtered by project make support conversations short and factual.
Scenario 3: Internal gRPC microservices on Kubernetes
A fintech platform runs dozens of internal services on Google Kubernetes Engine. Each service runs the proxy as a sidecar, with callers presenting Google ID tokens from service accounts. Only services with the right identity can call sensitive methods, and every call appears in logs with consistent fields, which helps the security team during audits.
Scenario 4: Moving from a homemade gateway
A media company has an old, custom-built gateway that nobody wants to maintain. It writes OpenAPI descriptions for its existing services, deploys the proxy in front of them one service at a time, and compares metrics before switching traffic. Within a quarter the homemade gateway is retired, and authentication logic is no longer duplicated in each service.
In every case, the winning moves were a clear written contract, layered identity, per-consumer visibility and a backend that can only be reached through the front door.
20Best Practices and Common Mistakes
A short checklist to keep nearby while you run your API.
Best practices
- Treat the description as code. Version it, review it and test it before it goes live.
- Choose the right proxy for the platform. Check the current supported-platform list before you design your deployment.
- Authenticate by risk. Match the strength of the check to the sensitivity of each method.
- Close the back door. Make the proxy the only way to reach the backend.
- Verify rollouts. After publishing, confirm that each proxy runs the intended configuration version.
- Set quotas early. Protect capacity and budget before traffic grows.
- Monitor and alert. Build dashboards for volume, errors, latency and rejected calls, and test your alerts.
- Document for humans. Provide clear references, examples, limits and a deprecation policy.
Common mistakes
Leaving the backend public
Clients and attackers can call it directly and skip every rule.
Relying on keys alone
Keys identify projects, not people, so they cannot guard user data by themselves.
Confusing publish with deploy
Publishing a configuration does not change proxies that are already running.
Wrong token audience
Valid tokens get rejected because the configured audience does not match.
No limits
A single buggy client can overload the backend and inflate the bill.
No alerts
Problems are discovered by customers instead of by dashboards.
Breaking changes without notice
Renaming or removing fields silently breaks consumers who trusted the contract.
One shared environment
Testing and production share the same configuration, so experiments hit real users.
21Frequently Asked Questions
Quick answers to the questions beginners ask most.
It is Google Cloud’s API management service that places a proxy in front of your backend to check callers, enforce rules and record logs, metrics and traces.
ESP is the original NGINX-based proxy. ESPv2 is the newer Envoy-based one, built for high performance and supporting more platforms, including serverless ones such as Cloud Run.
No. The backend stays as it is. You add an API description and place the proxy in front of it.
OpenAPI, using version 2.0 with ESPv2, and gRPC. There is also Cloud Endpoints Frameworks for App Engine.
ESP supports App Engine flexible, Compute Engine, Google Kubernetes Engine and Kubernetes. ESPv2 adds App Engine standard, Cloud Run functions, Cloud Run and Knative serving.
Check happens before the backend is called and decides whether the request is allowed. Report happens afterwards and sends the logging and monitoring data.
For sensitive data, no. A key identifies a calling project, not a person. Combine keys with signed user tokens and enforce ownership rules in the backend.
No. If the proxy or Service Control refuses the call, the backend never sees it, which is why the proxy logs are the first place to look.
Billing is per API call. The first couple of million calls each month are free, with a modest per-million price beyond that and a lower price at very high volumes. You also pay for the compute that runs your backend and proxy. Check the current pricing page for exact figures.
Proxies load their configuration at startup, so running ones keep using the old version until they are redeployed or restarted against the new one.
If you need advanced enterprise API programmes with detailed plans and portals, consider Apigee. If you want a fully hosted gateway for serverless backends, consider API Gateway.
Yes. Service accounts and Google ID tokens let services authenticate to each other, and the proxy can run as a sidecar next to each service.
22Summary and Key Takeaways
Cloud Endpoints gives your APIs a dependable front door. You describe the API in an OpenAPI or gRPC configuration, publish it to Service Management, and run a proxy, either ESP or ESPv2, in front of your backend. For each request the proxy applies your rules, Service Control decides whether the call is allowed, and logs, metrics and traces flow into Google Cloud’s observability tools. It is simple, economical and well integrated with Google Cloud, with modest rate-limiting compared with large enterprise platforms.
Remember the receptionist in the office building. The desk checks who you are, notes your arrival and sends you to the right floor, but it does not do the work upstairs. Keep the back doors locked, write a clear contract, and watch the visitor log.
Key Takeaways
- A front door for APIs — Endpoints protects, monitors and manages APIs without changing your backend code.
- Two halves — a proxy you deploy next to your backend, and Google services (Service Management, Service Control, Trace, Logging, Monitoring) that store rules, decide and record.
- Pick the proxy for your platform — ESPv2 is the newer Envoy-based choice and covers serverless platforms; ESP is the original NGINX-based proxy.
- The description is the contract — keep OpenAPI or gRPC definitions in version control, review changes, and remember that proxies must load a new configuration before it takes effect.
- Layer your identity — API keys identify projects and drive quotas, signed tokens identify users, and service accounts identify internal workloads.
- Close every back door — the proxy only protects traffic that passes through it, so restrict backends to proxy-only access.
- Watch and budget — dashboards, alerts and quotas protect reliability and cost, and billing is per API call after a generous monthly free allowance.