API Management
BTP & Integrationintermediate

Configuring API Proxies, Policies, and Security Enforcement

Covers hands-on configuration of API proxies, common policy types (security, traffic management, mediation), and how to design a secure, resilient API exposure for backend systems.

Explanation

Once the fundamental concepts of API Management are understood, the practical work is building and configuring API proxies that safely expose backend services. This lesson focuses on the implementation details a consultant will actually perform in a project: creating a proxy, wiring it to a backend provider, and layering policies to enforce security and stability. Creating an API proxy typically starts by importing or defining an OpenAPI specification (Swagger) or by manually defining resource paths. The proxy is bound to a target endpoint, which references a previously configured API Provider. For on-premise SAP systems (ECC or S/4HANA on-premise), the provider connection typically routes through the Cloud Connector using a configured virtual host, ensuring the on-premise system is never directly internet-facing. For SAP S/4HANA Cloud or other cloud-native backends, the provider may be reached via a direct HTTPS endpoint, often still requiring destination configuration for credential management. Security policies are the first line of defense. Common options include API Key verification (simplest, suitable for low-sensitivity or internal APIs), OAuth 2.0 token validation (recommended for most production external APIs, often integrating with SAP BTP's identity services or an external OAuth provider), and mutual TLS/client certificate validation for high-assurance B2B scenarios. A critical implementation decision is where security is enforced: at the proxy level (recommended, centralizes control) versus relying solely on backend-level authentication (fragile, harder to audit). Traffic management policies protect backend systems from overload and enforce fair usage. Spike Arrest smooths sudden traffic bursts by limiting requests per second/minute at a granular level. Quota policies enforce a maximum number of calls per consumer app over a longer window (e.g., 1000 calls per day), which is essential when APIs are monetized or offered under a tiered service agreement. These policies must be tuned against actual backend capacity—setting them too loosely defeats their purpose, and too strictly causes legitimate consumer failures. Mediation policies transform request or response payloads: XML-to-JSON conversion, header injection or removal, query parameter mapping, and conditional routing based on request attributes. These are used when the API contract exposed to consumers must differ from the backend's native format, a common requirement when backend systems are legacy ECC OData services with verbose XML structures being consumed by modern JSON-first client applications. Testing and troubleshooting configured proxies involves using the API Management trace tool, which captures the full request/response flow including every policy execution step, headers, and payloads. This is the primary tool for diagnosing why a policy is rejecting a request or why a backend call is timing out. Analytics dashboards additionally show call volumes, latency, and error rate trends over time, informing both operational monitoring and capacity planning discussions. A nuanced production consideration is fault handling: policies can fail (e.g., invalid API key), and the proxy should return a clear, consistent error response rather than exposing raw backend error details, which could leak internal system information. Custom fault rules are configured to standardize these error responses across all proxies in an organization for a consistent consumer experience.

Code example

ABAP Code
<!-- Conceptual policy XML illustrating layered security and traffic control (not a literal export) --><PreFlow name="PreFlow">  <Request>    <Step>      <Name>OAuthV2-VerifyAccessToken</Name>    </Step>    <Step>      <Name>SpikeArrest-50ps</Name>    </Step>    <Step>      <Name>Quota-1000PerDay</Name>    </Step>  </Request>  <Response>    <Step>      <Name>RemoveInternalHeaders</Name>    </Step>  </Response></PreFlow><FaultRules>  <FaultRule name="AuthFailure">    <Step><Name>AssignMessage-GenericAuthError</Name></Step>    <Condition>fault.name = "InvalidAccessToken"</Condition>  </FaultRule></FaultRules>

Real project scenario

An integration consultant is tasked with exposing an ECC-based inventory lookup service to a mobile app team. The backend returns verbose XML SOAP responses. The consultant builds an API proxy that accepts JSON requests, applies an OAuth 2.0 verification policy, adds a spike arrest tuned to the ECC system's known concurrency limits, and inserts a mediation policy converting the SOAP/XML backend response into clean JSON for the mobile app. During UAT, the mobile team reports intermittent 429 errors, and the consultant uses the trace tool to confirm the spike arrest threshold was too conservative, then adjusts it after confirming backend capacity with the basis team.

Common mistakes

• Setting spike arrest or quota values arbitrarily without validating actual backend capacity, causing either backend overload or unnecessary consumer throttling. • Relying only on API key verification for sensitive production APIs instead of OAuth 2.0 or certificate-based security. • Exposing raw backend fault messages to external consumers, leaking internal system details. • Forgetting to remove or mask internal headers (like backend hostnames) in the response policy. • Not testing proxy changes with the trace tool before promoting to production, leading to undiagnosed policy execution order issues.

Best practices

• Always validate rate-limiting thresholds against actual backend load-testing data, not assumptions. • Use OAuth 2.0 or mutual TLS for externally facing production APIs; reserve API keys for low-risk or internal use cases. • Centralize fault handling with reusable fault rule templates to ensure consistent, non-leaky error responses across proxies. • Use the trace tool during every proxy change before promoting to production. • Keep mediation logic in the proxy minimal; push complex transformation to Cloud Integration flows when logic grows beyond simple format conversion.

Interview angle

Expect scenario-based questions such as 'a consumer reports intermittent failures, how do you diagnose it' — the expected answer involves using the trace tool to inspect policy execution order and identify whether the failure is at the security, traffic, mediation, or backend layer. Also be ready to justify choosing OAuth over API keys for production-grade external APIs.