How-to: Handle unreliable APIs
This guide shows you how to make flows resilient against flaky upstream APIs: what Publicus retries for you automatically, how to bound slow requests with a timeout, and how to keep a flow running (and branch on the failure) instead of hard-failing when an upstream call errors.
The behaviour below applies to outbound HTTP calls made by Rest / Operation, OpenApi / Operation, and the OpenAPI operation pack.
What Publicus retries automatically
Section titled “What Publicus retries automatically”Every outbound API call gets a bounded retry, with no configuration needed on your part:
- Connection failures (DNS errors, refused connections, dropped sockets) are always retried.
- 5xx responses are retried only for
GET,HEAD, andOPTIONSrequests. APOSTorPUTthat returned a 5xx may already have had side effects upstream, so it is never retried automatically.
By default a failed request is retried 2 times with a short, linearly increasing delay between attempts.
The circuit breaker
Section titled “The circuit breaker”When an upstream host keeps failing, Publicus stops hammering it. Each host has its own circuit breaker:
- 5 failures within 120 seconds open the circuit for that host.
- While open, requests to that host fail fast for 60 seconds without touching the upstream at all.
- After the cooldown, a single probe request decides whether the circuit closes again or re-opens for another cooldown.
You don’t configure the breaker per node; it protects every flow that calls the same host. If you see a node fail almost instantly with a circuit-open error, the host recently failed repeatedly, wait out the cooldown or fix the upstream.
Bound slow requests with a timeout
Section titled “Bound slow requests with a timeout”Requests time out after 30 seconds by default. If your upstream is
slower (a long-running report endpoint) or you want to fail faster,
set Timeout (seconds) (timeoutSeconds), under More settings,
on a Rest / Operation or OpenApi / Operation node:
timeoutSeconds: 120The value covers both connecting and reading the response, and is
capped at 300 seconds. Leaving the field blank (or setting 0) uses
the 30-second default.
Continue instead of failing: the onError policy
Section titled “Continue instead of failing: the onError policy”By default an upstream error (4xx, 5xx, connection failure, or open circuit) fails the node and stops the flow. If you want the flow to keep going, open More settings on a Rest / Operation or OpenApi / Operation node and set its On error field to Continue with an error envelope.
With that policy, the node completes and its output becomes a structured error envelope instead of the API response:
{ "error": true, "upstreamStatus": 503, "circuitOpen": false, "message": "Server error: 503 Service Unavailable ..."}upstreamStatusis the HTTP status, ornullfor connection failures.circuitOpenistruewhen the request failed fast because the host’s circuit breaker was open.messageis a truncated description of what went wrong.
A node that continues past a refused credential (HTTP 401) is still noticed: its connection reads Failing on the Connections page, and the people who can fix it are told once.


Branch on the envelope
Section titled “Branch on the envelope”Downstream nodes can check for the envelope and react. A common
pattern is a ConditionalExit guard right after the API node:
condition: $prev->error ?? falsemessage: Upstream returned {{ $prev->upstreamStatus }}, skipping this run.The flow continues only when the call succeeded. Or invert it to build a dedicated error-handling branch (log the failure, notify a channel, write a fallback record). See How-to: Conditional logic for the guard patterns. To send a failed node down a path of its own instead, see Handling errors.
What counts as success
Section titled “What counts as success”-
Any 2xx response succeeds, and the node outputs the raw response body (which may be empty, for example on a
204). -
A 3xx response is never followed. The node succeeds with a structured result instead:
{ "redirect": 302, "location": "https://example.com/new-url" }If you need the redirected resource, call the
locationURL with a second API node. -
A 4xx/5xx response is an error: retried where safe (see above), then handled per your onError policy. The response body is included in the error message so you can see what the upstream said.
Verify it works
Section titled “Verify it works”Point a Rest / Operation node at an endpoint that returns a 500
(most HTTP testing services offer one), set On error, under
More settings, to Continue with an error envelope, and run the flow. In
Runs, the node completes instead of failing, and its output
shows the envelope with upstreamStatus: 500. Run it a few more times
in quick succession and you will see the circuit open:
runs complete almost instantly with circuitOpen: true.
Related
Section titled “Related”- Handling errors: error ports, the flow’s error branch, watcher flows and rehearsing a failure.
- Rest / Operation — node reference.
- OpenApi / Operation — node reference.
- How-to: Conditional logic — branching on the error envelope.
- Runs — inspecting per-node inputs, outputs, and errors.