Third-Party Integrations
Purpose
Integrate external services (payments, messaging, AI, CRM, etc.) so their failures, quirks, and API changes stay contained: one isolated client per provider, resilient calls, mapped errors, and testability without hitting live services.
When to Use
- When the backend calls any external API.
- Not for inbound events (
webhooks) or file/object storage specifics (file-storage) — though their provider clients follow these rules.
Inputs
- Provider list with the operations used, criticality, and cost per call.
- Failure tolerance per operation (blocking a user vs degradable).
Discovery Questions
- Per provider: what operations, what rate limits/quotas, what does an outage do to your product?
- Sandbox/test environment available? How do dev/staging avoid production side effects (real emails, real charges)?
- Which calls belong in the request path vs
background-jobs?
Responsibilities
- Isolate each provider behind your own interface (a service/port the domain calls); provider SDK types never leak into domain code — swapping or mocking stays possible.
- Handle credentials per
backend-security: env/secret-store, per-environment keys, rotation story, never logged.
- Make every call bounded: explicit timeouts, retries with backoff + jitter only on idempotent/retryable operations, and circuit-breaking/degradation for critical-path providers — an external 30s hang must not become your 30s hang.
- Map provider errors into your taxonomy (
backend-error-handling); respect provider rate limits (client-side throttling where needed).
- Separate environments: sandbox keys + fake/sink modes in dev/staging so tests never charge cards or email customers.
- Plan testing: contract-level mocks/stubs of your interface, plus a thin recorded/sandbox integration test per provider (
backend-integration-testing).
- Track usage/cost where metered (AI, SMS) — alert on anomalies (
backend-observability, ties to captcha-abuse-prevention for abuse-driven cost).
Required Workflow
- Inventory providers, operations, criticality, quotas.
- Define the interface per provider; place calls (request path vs background).
- Set timeout/retry/breaker policy per operation class.
- Define error mapping + degradation behavior.
- Set environment separation + test strategy.
- Specify tests: timeout honored, retry only on retryable, outage degrades as designed, sandbox isolation verified.
Decision Rules
- Non-idempotent external calls (charges, sends) retry only with provider idempotency keys — otherwise never blind-retry.
- Slow-but-optional providers leave the request path (
background-jobs).
- Critical-path providers need a recorded outage behavior (fail closed, degrade, queue) — "we go down too" is a decision to make consciously, not discover.
- New providers are stack/vendor decisions — user approval (
../../stack-recommendation), including data-sharing implications (../../../system/SECURITY_RULES.md).
Rules
- One client module per provider; no SDK calls scattered through services.
- Every external call has a timeout — no unbounded awaits.
- Provider responses are inputs: validate shape (
backend-validation) before trusting.
Anti-Patterns
- Provider SDK objects passed around the domain.
- Retrying a charge without an idempotency key.
- No timeout — thread-pool/event-loop starvation during provider brownouts.
- Production keys in dev; test runs sending real emails.
- Catching provider errors and rethrowing their raw bodies to clients.
Validation Checklist
Definition of Done
A recorded integration design — isolated interfaces, bounded resilient calls, mapped errors, environment separation, and a test strategy that never hits production providers from CI.
Related Skills
webhooks, background-jobs, backend-error-handling, backend-security, backend-observability, backend-integration-testing, email-notifications, ../../dependency-audit (SDK health).
Related Knowledge
../../../knowledge/ (vendor contracts, quotas, data-sharing constraints).
Related References
../../../references/backend/integrations/ (provider notes, when populated).
Context Loading Guidance
- Requires: provider/operation inventory, criticality, environment model.
- Does not require: full SDK docs, unrelated domains.
- May load:
backend-error-handling (mapping), background-jobs (placement).
- Stop when: per-provider interface + resilience + test design is recorded.
Token Efficiency Guidance
One table row per provider (operations, criticality, timeout/retry, outage behavior, sandbox); link vendor docs instead of summarizing them.
1---2name: third-party-integrations3description: Use to plan integrations with external APIs — client isolation behind an interface, credential handling, timeouts/retries/circuit breaking, error mapping, sandbox vs production, and testing without live calls.4---56# Third-Party Integrations78## Purpose910Integrate external services (payments, messaging, AI, CRM, etc.) so their failures, quirks, and API changes stay contained: one isolated client per provider, resilient calls, mapped errors, and testability without hitting live services.1112## When to Use1314- When the backend calls any external API.15- **Not** for inbound events (`webhooks`) or file/object storage specifics (`file-storage`) — though their provider clients follow these rules.1617## Inputs1819- Provider list with the operations used, criticality, and cost per call.20- Failure tolerance per operation (blocking a user vs degradable).2122## Discovery Questions2324- Per provider: what operations, what rate limits/quotas, what does an outage do to your product?25- Sandbox/test environment available? How do dev/staging avoid production side effects (real emails, real charges)?26- Which calls belong in the request path vs `background-jobs`?2728## Responsibilities2930- Isolate each provider behind **your own interface** (a service/port the domain calls); provider SDK types never leak into domain code — swapping or mocking stays possible.31- Handle credentials per `backend-security`: env/secret-store, per-environment keys, rotation story, never logged.32- Make every call bounded: explicit **timeouts**, **retries with backoff + jitter only on idempotent/retryable operations**, and circuit-breaking/degradation for critical-path providers — an external 30s hang must not become your 30s hang.33- Map provider errors into your taxonomy (`backend-error-handling`); respect provider rate limits (client-side throttling where needed).34- Separate environments: sandbox keys + fake/sink modes in dev/staging so tests never charge cards or email customers.35- Plan testing: contract-level mocks/stubs of *your interface*, plus a thin recorded/sandbox integration test per provider (`backend-integration-testing`).36- Track usage/cost where metered (AI, SMS) — alert on anomalies (`backend-observability`, ties to `captcha-abuse-prevention` for abuse-driven cost).3738## Required Workflow39401. Inventory providers, operations, criticality, quotas.412. Define the interface per provider; place calls (request path vs background).423. Set timeout/retry/breaker policy per operation class.434. Define error mapping + degradation behavior.445. Set environment separation + test strategy.456. Specify tests: timeout honored, retry only on retryable, outage degrades as designed, sandbox isolation verified.4647## Decision Rules4849- Non-idempotent external calls (charges, sends) retry only with provider idempotency keys — otherwise never blind-retry.50- Slow-but-optional providers leave the request path (`background-jobs`).51- Critical-path providers need a recorded outage behavior (fail closed, degrade, queue) — "we go down too" is a decision to make consciously, not discover.52- New providers are stack/vendor decisions — user approval (`../../stack-recommendation`), including data-sharing implications (`../../../system/SECURITY_RULES.md`).5354## Rules5556- One client module per provider; no SDK calls scattered through services.57- Every external call has a timeout — no unbounded awaits.58- Provider responses are inputs: validate shape (`backend-validation`) before trusting.5960## Anti-Patterns6162- Provider SDK objects passed around the domain.63- Retrying a charge without an idempotency key.64- No timeout — thread-pool/event-loop starvation during provider brownouts.65- Production keys in dev; test runs sending real emails.66- Catching provider errors and rethrowing their raw bodies to clients.6768## Validation Checklist6970- [ ] Provider inventory with criticality + quotas.71- [ ] Interface isolation per provider.72- [ ] Timeouts, selective retries (+ idempotency keys), breaker/degradation per class.73- [ ] Error mapping into the taxonomy.74- [ ] Environment separation (sandbox/sink) enforced.75- [ ] Tests: timeout, retry policy, outage behavior, no live side effects in CI.7677## Definition of Done7879A recorded integration design — isolated interfaces, bounded resilient calls, mapped errors, environment separation, and a test strategy that never hits production providers from CI.8081## Related Skills8283`webhooks`, `background-jobs`, `backend-error-handling`, `backend-security`, `backend-observability`, `backend-integration-testing`, `email-notifications`, `../../dependency-audit` (SDK health).8485## Related Knowledge8687`../../../knowledge/` (vendor contracts, quotas, data-sharing constraints).8889## Related References9091`../../../references/backend/integrations/` (provider notes, when populated).9293## Context Loading Guidance9495- **Requires:** provider/operation inventory, criticality, environment model.96- **Does not require:** full SDK docs, unrelated domains.97- **May load:** `backend-error-handling` (mapping), `background-jobs` (placement).98- **Stop when:** per-provider interface + resilience + test design is recorded.99100## Token Efficiency Guidance101102One table row per provider (operations, criticality, timeout/retry, outage behavior, sandbox); link vendor docs instead of summarizing them.