Third-party API
Internet via NAT Gateway (or SES / SNS)
Someone else’s service on the internet — payments, email, SMS, maps. You don’t control its latency or uptime.
In a monolith
Called inline
The checkout handler calls the payment and email providers synchronously — the user waits for both.
In a distributed system
Behind timeouts, breakers or queues
Calls get timeouts, retries with backoff and circuit breakers; anything that doesn’t need an immediate answer goes through a queue.
On AWS
Internet via NAT Gateway (or SES / SNS)
From private subnets, outbound calls go through a NAT Gateway. Some externals have AWS equivalents: SES for email, SNS for SMS and push.
- Payment providerfree / externalSend idempotency keys; verify webhook signatures
- Amazon SES (email)$Managed email sending
- Amazon SNS (SMS / push)$SMS and mobile push
- Reach for it when
- Any capability you buy instead of build.
- What it costs you
- Latency you can’t optimise (hundreds of ms)
- Their outage is your outage if you call them synchronously
- Rate limits and per-call pricing
- When it dies
- Calls hang or fail. Without timeouts, waiting threads pile up until your service can’t serve anything — a cascading failure.
Interview follow-ups
The payment provider is slow — what happens to checkout?
With no timeout, threads wait and pile up and the whole app degrades. Use a timeout, a circuit breaker to fail fast, and async processing wherever the user doesn’t need the result immediately.
How do you avoid double-charging when retrying?
Send an idempotency key with each charge so the provider returns the original result for a repeated request.
Connection rules
It talks to
- Load balancer
- API gateway
- App serverOnly when: A single-instance webhook receiver; normally webhooks come in through your LB or gateway.
- ServiceOnly when: A single-instance webhook receiver; normally webhooks come in through your LB or gateway.
Gets traffic from
- NAT gateway
- App server
- Service
- Worker
- Realtime server
- Workflow
- ClientsOnly when: Provider SDKs built for it — e.g. hosted payment fields, where card details go straight to the payment provider and your servers never touch them (smaller PCI scope).
- Pub/sub topicOnly when: Managed delivery to SMS, email or mobile push endpoints (SNS).
Never
- Queue → Third-party APIQueues don’t run code. A consumer reads the message and does the write or call.
- Event stream → Third-party APIStreams don’t run code. A consumer reads the records and does the write or call.