Integration / API
APICloudIntegration Pattern

Int-API-Cloud

Problem

An internal application must consume or expose synchronous APIs across a public cloud or SaaS boundary, where the counterparty is a managed service outside the organisation's network perimeter and its endpoints, credentials, and rate limits are controlled entirely by the provider. Without a governed egress path and a resilience layer, every SaaS dependency becomes an unmonitored outbound connection and a single point of failure for the calling workload.

Solution

Route all SaaS-bound API traffic through a managed egress gateway with FQDN allow-listing and a stable egress identity the provider can authorise, fronted by an outbound API facade that centralises credential handling, retries, timeouts, and circuit breaking. Inbound callbacks and webhooks from the SaaS platform terminate at a perimeter API gateway that verifies provider signatures and enforces rate limits before routing into private workloads, so neither direction requires a workload to hold provider credentials or address the internet directly.

Cloud Paradigm

  • API Gateway Fronting
  • Managed Egress Control
  • Circuit Breaker Resilience
  • Externalised Secret Management
  • Webhook-Driven Integration
  • Backend for Frontend Facade

Solution Flow

Outbound (workload to SaaS)

  1. The internal workload calls a local endpoint on the outbound API facade instead of the provider's public URL, so it never holds provider credentials or an internet route.
  2. The outbound API facade resolves the provider secret from the credential vault, applies timeouts, retries with backoff, and a circuit breaker, then forwards the request.
  3. The managed egress gateway presents a stable egress identity, enforces FQDN allow-listing, and is the only path permitted to reach the public internet.
  4. The SaaS platform authorises the recognised egress identity, applies its rate limits, and returns the synchronous response back through the same chain.

Inbound (SaaS callbacks and webhooks)

  1. The SaaS platform posts a webhook or callback to a published perimeter address, never to a workload directly.
  2. The perimeter API gateway verifies the provider signature, enforces rate and payload limits, and rejects anything unsigned or replayed.
  3. The webhook handler receives the validated event inside the private subnet and commits it to internal state.

When to Use

  • An internal service depends on a managed SaaS or cloud API whose endpoints, credentials, and quotas are provider-controlled.
  • The provider authorises callers by source identity or IP and requires a stable egress.
  • The SaaS platform sends asynchronous webhooks that must land safely inside the perimeter.
  • You need centralised retry, timeout, and circuit-breaking policy across many SaaS dependencies.

When NOT to Use

  • Purely internal service-to-service calls with no public boundary - use a service mesh instead.
  • High-volume, one-way event ingestion where synchronous coupling is unnecessary - use a Message Broker or event streaming pattern.
  • Bulk file or dataset transfer - use a Managed File Transfer / batch integration pattern.

Trade-offs

  • Governed, monitored egress vs the added latency and operational cost of an extra facade and gateway hop.
  • No credentials in workloads vs a centralised vault and facade that become high-value targets requiring hardening.
  • Resilience against SaaS outages vs the complexity of tuning circuit breakers, timeouts, and fallback behaviour per provider.
  • Stable egress identity for allow-listing vs coordination overhead whenever provider FQDNs or IP ranges change.

Real-World Example

A logistics operator integrates its dispatch application with a third-party route-optimisation SaaS. The dispatch workload calls the local Outbound API Facade, which retrieves the API key from the Credential Vault and forwards requests through the Managed NAT / Egress Gateway, whose fixed egress identity the SaaS has allow-listed. When optimisation completes, the SaaS posts a webhook to the perimeter API Gateway, which verifies the HMAC signature before the Webhook Handler updates delivery routes in the private subnet - so no driver-facing workload ever touches the internet or holds provider secrets.

Additional Details

  • Failure handling: define fallbacks per dependency (cached last-known-good, degraded mode) so a SaaS outage tripping the circuit breaker does not cascade.
  • Versioning: pin provider API versions in the facade and shield workloads from breaking changes behind a stable internal contract.
  • Observability: emit per-provider metrics for latency, error rate, retry count, and breaker state; correlate egress logs with provider request IDs.
  • Cost: monitor provider rate limits and per-call pricing at the facade to prevent runaway retries inflating spend.
  • Idempotency: use idempotency keys on outbound writes and deduplicate inbound webhooks that the provider may deliver more than once.

Security Controls

  • FQDN allow-listing: The egress gateway permits outbound traffic only to explicitly approved provider hostnames, blocking all other internet destinations.
  • Stable egress identity: A fixed source identity is presented to the SaaS so the provider can authorise the organisation without embedding credentials in workloads.
  • Centralised secret custody: Provider credentials live only in a vault accessed by the facade, never in application code or workload environments.
  • Webhook signature verification: The perimeter API gateway validates provider HMAC or mTLS signatures and rejects unsigned or replayed callbacks.
  • Rate and payload enforcement: Inbound limits at the gateway protect private workloads from webhook floods and oversized payloads.
  • Mutual TLS on egress: Outbound connections use TLS with certificate pinning where the provider supports it to prevent interception.

Related Patterns