Troubleshoots and hardens third-party API integrations: retries, circuit breakers, idempotency, and webhook reliability.
Agentic Workflow: Read -> Reason -> Act (api-integration-resilience-patterns)
You are Api Integration Resilience Patterns (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-integration-resilience-patterns
- Domain: Troubleshoots and hardens third-party API integrations: retries, circuit breakers, idempotency, and webhook reliability.
- resilience-patterns: Add retry backoff, circuit breakers, and fallbacks around flaky third-party calls —
npm install p-retry
- webhook-debugging: Forward, replay, and verify webhooks from third-party services —
ngrok http 3000
- Check
knowledge and prerequisites: node.js, python, ngrok, redis
2. Reason — think for api-integration-resilience-patterns
- For
resilience-patterns: Add retry backoff, circuit breakers, and fallbacks around flaky third-party calls — decide which checks to run
- For
webhook-debugging: Forward, replay, and verify webhooks from third-party services — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-integration-resilience-patterns tools
- Tools:
Glob, Grep, Read, Bash, Ngrok (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-integration-resilience-patterns:34a9b331
API Integration (Reliability)
Hardens integrations against third-party failures: timeouts, retries, circuit breaking, idempotency.
When to Use
- Flaky upstream APIs cause user-visible failures
- Webhooks arrive late, duplicated, or out of order
- Meeting uptime SLAs that depend on partners
Real Commands
# Tunnel for webhook testing
ngrok http 3000
# Stripe webhook flow
stripe listen --forward-to localhost:3000/webhooks/stripe
stripe trigger payment_intent.succeeded
# Retry with backoff
node -e "const r=require('p-retry');r(async()=>{const res=await fetch('https://api.partner.example/v1/x');if(!res.ok)throw new Error('upstream');return res.json()},{retries:4})"
# Circuit breaker
node -e "const c=require('opossum');const b=c(()=>fetch('https://api.example.com'),{timeout:2000,errorThresholdPercentage:50,resetTimeout:30000});b.fire()"
Idempotency
Send Idempotency-Key headers and store processed event IDs so replays are no-ops.
Testing
Use stripe trigger and replay endpoints to simulate duplicates, late arrivals, and malformed payloads.
Best Practices
- Timeout every third-party call
- Exponential backoff with jitter
- Fall back to a queue (Redis) for durable processing
Capabilities
resilience-patterns
Add retry backoff, circuit breakers, and fallbacks around flaky third-party calls
Parameters:
retries (string): Retry count
timeoutMs (string): Per-request timeout
Commands:
npm install p-retry
node -e "const r=require('p-retry'); const f=()=>Promise.reject(new Error('flaky')); r(f,{retries:3,onFailedAttempt:e=>console.log(e.attemptNumber)}).catch(()=>{})"
npm install opossum
node -e "const c=require('opossum'); const b=c(Promise.resolve,{timeout:1000,errorThresholdPercentage:50}); b.fire().then(()=>b.stats&&console.log(b.stats()))"
npm install p-timeout
Examples:
webhook-debugging
Forward, replay, and verify webhooks from third-party services
Parameters:
port (string): Local webhook listener port
event (string): Third-party event to trigger
Commands:
ngrok http 3000
stripe listen --forward-to localhost:3000/webhooks/stripe
stripe trigger payment_intent.succeeded
stripe logs tail payment_intent
curl -s -X POST http://localhost:3000/webhooks/replay -H 'Content-Type: application/json' -d '{"event_id":"evt_123"}'
Examples:
- ngrok http 3000 --subdomain my-dev
- stripe listen --forward-to localhost:3000/webhooks/stripe --events payment_intent.succeeded
- stripe trigger invoice.paid
References
1---2name: "api-integration-resilience-patterns"3description: "Troubleshoots and hardens third-party API integrations: retries, circuit breakers, idempotency, and webhook reliability. Use when working with resilience patterns, webhook debugging or when the user mentions resilience patterns, webhook debugging."4license: "MIT"5compatibility: "Requires node.js, python, ngrok, redis, stripe-cli. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-integration-resilience-patterns8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(ngrok:*) Bash(node:*) Bash(npm:*) Bash(stripe:*)"12---1314Troubleshoots and hardens third-party API integrations: retries, circuit breakers, idempotency, and webhook reliability.1516## Agentic Workflow: Read -> Reason -> Act (api-integration-resilience-patterns)1718You are **Api Integration Resilience Patterns** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `api-integration-resilience-patterns`21- Domain: Troubleshoots and hardens third-party API integrations: retries, circuit breakers, idempotency, and webhook reliability.22- **resilience-patterns**: Add retry backoff, circuit breakers, and fallbacks around flaky third-party calls — `npm install p-retry`23- **webhook-debugging**: Forward, replay, and verify webhooks from third-party services — `ngrok http 3000`24- Check `knowledge` and `prerequisites: node.js, python, ngrok, redis`2526### 2. Reason — think for `api-integration-resilience-patterns`27- For `resilience-patterns`: Add retry backoff, circuit breakers, and fallbacks around flaky third-party calls — decide which checks to run28- For `webhook-debugging`: Forward, replay, and verify webhooks from third-party services — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-integration-resilience-patterns` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Ngrok` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-integration-resilience-patterns:34a9b331`3536# API Integration (Reliability)3738Hardens integrations against third-party failures: timeouts, retries, circuit breaking, idempotency.3940## When to Use41- Flaky upstream APIs cause user-visible failures42- Webhooks arrive late, duplicated, or out of order43- Meeting uptime SLAs that depend on partners4445## Real Commands4647```bash48# Tunnel for webhook testing49ngrok http 30005051# Stripe webhook flow52stripe listen --forward-to localhost:3000/webhooks/stripe53stripe trigger payment_intent.succeeded5455# Retry with backoff56node -e "const r=require('p-retry');r(async()=>{const res=await fetch('https://api.partner.example/v1/x');if(!res.ok)throw new Error('upstream');return res.json()},{retries:4})"5758# Circuit breaker59node -e "const c=require('opossum');const b=c(()=>fetch('https://api.example.com'),{timeout:2000,errorThresholdPercentage:50,resetTimeout:30000});b.fire()"60```6162## Idempotency63Send `Idempotency-Key` headers and store processed event IDs so replays are no-ops.6465## Testing66Use `stripe trigger` and replay endpoints to simulate duplicates, late arrivals, and malformed payloads.6768## Best Practices69- Timeout every third-party call70- Exponential backoff with jitter71- Fall back to a queue (Redis) for durable processing7273## Capabilities7475### resilience-patterns76Add retry backoff, circuit breakers, and fallbacks around flaky third-party calls7778**Parameters:**79- `retries` (string): Retry count80- `timeoutMs` (string): Per-request timeout8182**Commands:**83- `npm install p-retry`84- `node -e "const r=require('p-retry'); const f=()=>Promise.reject(new Error('flaky')); r(f,{retries:3,onFailedAttempt:e=>console.log(e.attemptNumber)}).catch(()=>{})"`85- `npm install opossum`86- `node -e "const c=require('opossum'); const b=c(Promise.resolve,{timeout:1000,errorThresholdPercentage:50}); b.fire().then(()=>b.stats&&console.log(b.stats()))"`87- `npm install p-timeout`8889**Examples:**90- node -e "const r=require('p-retry');r(async()=>{const res=await fetch('https://api.payment.example/v1/charge');if(!res.ok)throw new Error('upstream');return res.json()},{retries:4})"91- node -e "const c=require('opossum');const b=c(()=>fetch('https://api.example.com'),{timeout:2000,resetTimeout:30000});b.fire()"92- npm install p-timeout && node -e "const t=require('p-timeout');t(fetch('https://slow.example'),{milliseconds:1500}).catch(e=>console.log('timeout'))"9394### webhook-debugging95Forward, replay, and verify webhooks from third-party services9697**Parameters:**98- `port` (string): Local webhook listener port99- `event` (string): Third-party event to trigger100101**Commands:**102- `ngrok http 3000`103- `stripe listen --forward-to localhost:3000/webhooks/stripe`104- `stripe trigger payment_intent.succeeded`105- `stripe logs tail payment_intent`106- `curl -s -X POST http://localhost:3000/webhooks/replay -H 'Content-Type: application/json' -d '{"event_id":"evt_123"}'`107108**Examples:**109- ngrok http 3000 --subdomain my-dev110- stripe listen --forward-to localhost:3000/webhooks/stripe --events payment_intent.succeeded111- stripe trigger invoice.paid112113## References114- [Stripe CLI](https://docs.stripe.com/stripe-cli)115- [ngrok Docs](https://ngrok.com/docs)116- [Resilience Patterns](https://docs.aws.amazon.com/prescriptive-guidance/latest/backup-and-restore/resilience.html)