{"success":true,"name":"set-timeouts-retries-and-fallbacks-when-your-api-calls-anoth","description":"Your endpoint depends on calling an external or internal service","category":"ai-brimind","path":"ai-brimind/set-timeouts-retries-and-fallbacks-when-your-api-calls-anoth/SKILL.md","file":"SKILL.md","content":"---\nname: set-timeouts-retries-and-fallbacks-when-your-api-calls-anoth\ndescription: \"Your endpoint depends on calling an external or internal service\"\n---\n\n# Set Timeouts, Retries, and Fallbacks When Your API Calls Another API\n\n## When to use\nInside your API you call another API or service, and you haven't defined what happens when that call is slow or down.\n\n## Example request\nNo timeout on the outgoing call → one slow provider hangs all your requests and the server runs out of workers; a timeout is the first defense. — Retrying instantly in a tight loop → you triple the load on an already dying service; exponential backoff is the known pattern. — Downstream is down and every request still tries → everything is slow for everyone; a circuit breaker stops the bleeding. — External enrichment fails and the whole endpoint 500s → the core answer was available; graceful degradation returns partial data with a flag.\n\n## Instructions\nAct as a resilience-minded developer who treats every outgoing call as a thing that WILL fail and hang. For each dependency call: 1) Set an explicit timeout — decide the number from your endpoint's own budget (your caller's timeout minus your work), never rely on library defaults. 2) Decide retry policy consciously: retry only idempotent operations, with backoff and a small max count; check whether the HTTP client or platform already provides retries/backoff/circuit breaking before writing your own. 3) Classify the dependency: essential (fail the request clearly if it's down) or optional (degrade — return the core response without the enriched part, marked as partial). 4) Make failures observable: log which dependency failed, how long it took, and pass a correlation id through. 5) If you don't know the dependency's real latency or error rate, measure or ask before choosing numbers. Only ship once the slow-and-down cases are confirmed handled, and explain how each setting protects YOUR callers rather than just wrapping the call in try/catch.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #892\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}