---
title: "Decide what happens when a provider is · Agent Wranglers"
url: https://agentwranglers.se/playbook/api-design/using-other-companies-apis/provider-outages
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Decide what happens when a provider is down

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Using other companies' APIs](https://agentwranglers.se/playbook/api-design/using-other-companies-apis.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

- ID: API-78
- Level: Recommended
- Chapter: [Using other companies' APIs](https://agentwranglers.se/playbook/api-design/using-other-companies-apis)
- Rule: For each call to an outside API, choose one of three paths for when it fails. Show a clear message, serve a saved answer, or queue the work and send it later.
- How: Reads, such as exchange rates or shipping prices, can use the last good answer with its age shown. Writes that can wait, such as a shipment booking, go to a queue and are sent when the provider is back. Writes that cannot wait show a message and keep the order in a state you can resume. After a run of failures, stop calling for a pause, so a dead provider does not hold up every request. The same switch for models is in [keep working when the provider fails](https://agentwranglers.se/playbook/ai-features/latency-cost-and-fallbacks/provider-fallback). Jobs that keep failing go to a [dead letter queue](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/dead-letter-queue). Test every path as [test how your code handles each outside service failing](https://agentwranglers.se/playbook/testing/integration-and-contract-tests/outside-service-failures) says.
- Check: The adapter's settings name the path for each call. Block the provider's host in staging for 10 minutes. Pages that do not need it load as fast as before, and queued work is sent within 10 minutes of unblocking.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
async function shippingPrice(parcel) {
  try {
    const price = await carrier.quote(parcel);
    await priceCache.set(parcel.zone, price);
    return { price, fresh: true };
  } catch (error) {
    const saved = await priceCache.get(parcel.zone);
    if (!saved) throw error;
    return { price: saved, fresh: false };
  }
}
```

### Python example

```python
async def shipping_price(parcel):
    try:
        price = await carrier.quote(parcel)
        await price_cache.set(parcel.zone, price)
        return price, True
    except CarrierError:
        saved = await price_cache.get(parcel.zone)
        if saved is None:
            raise
        return saved, False
```

## Related rules

- [Keep working when the provider fails](https://agentwranglers.se/playbook/ai-features/latency-cost-and-fallbacks/provider-fallback) in AI features
- [Set aside messages that keep failing](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues/dead-letter-queue) in Scaling
- [Test how your code handles each outside service failing](https://agentwranglers.se/playbook/testing/integration-and-contract-tests/outside-service-failures) in Testing

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/api-design/using-other-companies-apis/provider-outages">Agent Wranglers API design playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Stay under their rate limits](https://agentwranglers.se/playbook/api-design/using-other-companies-apis/respect-their-limits)
- Next: [Pin their API version and watch for its end](https://agentwranglers.se/playbook/api-design/using-other-companies-apis/pin-and-watch-versions)
- [Using other companies' APIs](https://agentwranglers.se/playbook/api-design/using-other-companies-apis)
