Integration / API
APIExternalIntegration Pattern

Int-API-External

Problem

An internal application must synchronously exchange data or services with an external user, partner, or system across a trust boundary in real time. Without a governed edge, inbound and outbound traffic bypasses perimeter controls, exposing internal systems to untrusted networks and leaving connections unsecured, unfiltered, and unlogged.

Solution

For inbound requests, utilize an External API Gateway deployed at the Public Subnet (Perimeter) to secure, proxy, and govern connections from external systems to the internal application. For outbound requests (internal to external), route traffic through a designated secure egress point (such as a Forward Proxy or Egress Gateway) to control, filter, and log outbound connectivity.

Cloud Paradigm

  • API-First Design
  • API-Led Connectivity
  • Edge Security (Ingress/Egress control)
  • Zero Trust Architecture

Solution Flow

Inbound Flow (External Consumption):

  1. External Caller: A third-party client initiates an HTTPS request over the public internet.
  2. Edge Protection (WAF): The traffic hits a public-facing cloud edge where a Web Application Firewall inspects for malicious signatures (e.g., OWASP Top 10) and enforces rate limits.
  3. API Gateway: The sanitized request reaches the API Gateway, which authenticates the caller (e.g., OAuth 2.0 / OIDC), terminates TLS, and routes the traffic to the private subnet.
  4. Backend Workload: The internal microservice receives the request, processes the business logic, and returns the response.

Outbound Flow (Internal Egress):

  1. Backend Workload: The internal service initiates a secure HTTPS request to a partner API.
  2. Egress Gateway / NAT: Because the workload sits in a private subnet with no direct Public Internet access, the traffic routes through a Managed NAT/Egress Gateway. This gateway enforces outbound FQDN whitelisting and performs network address translation.
  3. External Target: The partner system receives the request originating from a static, whitelisted cloud egress IP.

When to Use

  • An external partner or customer needs real-time, synchronous access to an internal service over the public internet.
  • You must expose a stable, versioned API contract to third parties while keeping backend workloads in private subnets.
  • Internal services need to call partner APIs and you require static egress IPs plus FQDN whitelisting for the partner's allowlist.
  • Regulatory or security mandates require centralized authentication, WAF inspection, rate limiting, and audit logging at the perimeter.

When NOT to Use

  • The exchange is asynchronous or event-driven — use a message queue or event-streaming pattern instead.
  • Requests demand heavy data transformation, protocol translation, or multi-step orchestration — delegate to the Middleware-External pattern.
  • Communication is strictly internal (service-to-service within the trust boundary), where a service mesh or internal gateway is more appropriate.
  • Bulk or batch file transfer is required — a Managed File Transfer or B2B gateway pattern fits better.
  • The integration is a one-off, low-volume connection where a full gateway stack adds disproportionate operational overhead.

Trade-offs

  • Strong perimeter security and centralized governance vs the added latency and single-point-of-failure risk of routing all traffic through gateway hops.
  • Static, whitelistable egress IPs and outbound filtering vs the operational cost of maintaining highly available NAT/Egress infrastructure.
  • Decoupled, versioned API contracts vs the discipline required to manage lifecycle, deprecation, and backward compatibility for external consumers.
  • Backend workloads shielded in private subnets vs increased network complexity and more components to configure, monitor, and secure.

Real-World Example

Consider a global hotel group that exposes a room-availability and booking API to online travel agencies and metasearch partners. Their inbound HTTPS calls strike a Web Application Firewall that screens for OWASP Top 10 signatures and throttles abusive traffic before the API Gateway validates each partner via OAuth 2.0, terminates TLS, and routes the request to a reservations microservice locked inside a private subnet. When that same service confirms a corporate rate against an airline's loyalty API, it egresses through a managed NAT gateway enforcing FQDN whitelisting, so the airline sees a single static, pre-approved IP. Versioned URI contracts shield agency integrations from breaking changes, gateway configs ship via GitOps pipelines, and OpenTelemetry traces on both hops give the group end-to-end visibility across the perimeter.

Additional Details

  • Protocol & Format: The backend workload providing the API endpoint should use modern synchronous protocols (REST, GraphQL, or gRPC) or legacy protocols (SOAP) over HTTPS. Use standard data formats such as JSON, XML, or Protobuf.

  • API Design & Documentation: Describe the API using standard machine-readable specifications (e.g., OpenAPI Specification/Swagger, WSDL). Information objects exchanged must be based on a common vocabulary or industry-standard data models.

  • API Management & Lifecycle: Implement a strict versioning strategy (e.g., URI or Header-based) for inbound APIs to avoid breaking changes for external consumers. Treat API Gateway configurations as code (IaC/GitOps) deployed via CI/CD pipelines.

  • Pattern Delegation: If the APIs exposed by the provider system require complex data transformations, protocol translation, or multi-step orchestration, delegate these responsibilities to the Middleware-External pattern rather than building complex logic into the API Gateway.

  • Outbound Rules: If the internal application initiates the connection, it must not possess direct Public Internet access. The outbound connection must be routed through a highly available Egress Gateway or NAT gateway for centralized egress filtering.

  • Observability: Enable centralized logging, metrics (latency, error rates, traffic), and distributed tracing (e.g., OpenTelemetry) on both the API Gateway and Egress Gateway to track cross-boundary request lifecycles.

Security Controls

  • Perimeter Security: Inbound connections must terminate at an Edge API Gateway within a public subnet or dedicated ingress VPC. Protect the Gateway with a Web Application Firewall (WAF) to mitigate common vulnerabilities (e.g., OWASP Top 10) and malicious bot traffic.

  • Transport Security: Enforce strict Transport Layer Security (TLS 1.2 or higher) on all inbound and outbound endpoints.

  • Authentication & Authorisation:

    • For system-to-system (B2B) integrations, authenticate consumers using OAuth 2.0 (Client Credentials Grant) or Mutual TLS (mTLS).

    • For external user connections, use OAuth 2.0/OpenID Connect (OIDC).

    • Note: API Keys should only be used for basic identification or quota management, not as a primary authentication mechanism.

  • Traffic Management: Use API Management policies to enforce rate limiting, throttling, and burst quotas to protect the backend workloads from DDoS attacks or accidental traffic spikes.

  • Outbound Controls: Configure the Egress Gateway and egress firewalls to allow outbound connections only to explicitly whitelisted external IP addresses or fully qualified domain names (FQDNs). Inspect outbound traffic for Data Loss Prevention (DLP) if required by compliance.

Related Patterns