Route API errors to token refresh or handler

Recipe ToolsDeveloper ToolAPI Integration

What it does

When a function call is made, this automation sends an HTTP request and monitors for errors. If an Unauthorized error occurs, it calls a token generator; otherwise it routes the error to a handler so the right team responds.

Who it's for

Engineering teams who need to handle API authentication failures separately from other errors.

How teams use this

Refresh tokens on Unauthorized errors

When an HTTP call fails with Unauthorized, the automation immediately calls the token generator to get fresh credentials and the request can succeed on retry. This keeps integrations running without manual intervention.

Escalate non-auth errors to support

Errors that are not authentication failures go to an error handler so the support team can triage and decide next steps. Each error type gets the right response path.

Log errors to a monitoring system

Add a step to send error details to a monitoring or logging service so the team can track failure patterns and improve reliability. Only errors that reach the handler are logged.

Retry failed requests with backoff

Set a condition in the error handler to retry non-Unauthorized errors with increasing delays before escalating. This reduces noise from transient failures.

How it works

  1. Receive the function call. A real-time function call arrives with the parameters needed to make an HTTP request.
  2. Send the HTTP request. The automation sends an HTTP request via Rest and checks the response for errors before proceeding.
  3. Check if error is Unauthorized. If the error message contains Unauthorized, the automation calls the FHIR-Access-Token-Generator to refresh the token and retry the request.
  4. Route other errors to handler. For any other error, the automation calls Error_Handling asynchronously so the team can investigate and decide whether to retry the request.
  5. Return the result. The automation returns the final result or error status back to the caller.