How can I access error responses from an HTTP Callout Action in Flow?

When you build an HTTP Callout Action in Salesforce Flow and you only define a successful response schema such as 2XX, Flow only maps fields for responses that match that code range. When your external service responds with a 400 or any other non-2XX status code, Flow technically receives the body, and the debug screen even shows it, but the response body is not mapped into the normal output variables. Instead, Flow puts the payload in a hidden structure called defaultExc, which you can’t reference directly in Flow resources. This creates the confusing behavior in which you can see the payload during debugging but cannot access the values inside the flow for your decision logic.

In your example, the external system always returns a JSON object that has success, message, and error, but if the status code is outside the defined 2XX, the object you expected is null and the real payload is trapped in defaultExc. The problem happens because Flow only generates typed outputs for the response groups that the external service definition declares.

The clean solution is to update the External Service definition so that it includes response schemas for the non-2XX codes. In the OpenAPI (Swagger) JSON, you will see a section called responses where only "2XX" is listed. You need to copy that structure and add "4XX" and "5XX" so that Flow knows that those codes also return JSON with the same structure. After you extend the responses section, Flow will generate proper output variables that can be used in your decisions and assignments, even when the call returns a 400 or 500. A minimal example looks like this:

"responses": {
  "2XX": {
    "description": "",
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "success": { "type": "boolean" },
            "message": { "type": "string" },
            "error": {
              "type": "object",
              "properties": {
                "message": { "type": "string" },
                "id": { "type": "string" }
              }
            }
          }
        }
      }
    }
  },
  "4XX": {
    "description": "",
    "content": {
      "application/json": {
        "schema": { "$ref": "#/components/schemas/YourResponseSchema" }
      }
    }
  },
  "5XX": {
    "description": "",
    "content": {
      "application/json": {
        "schema": { "$ref": "#/components/schemas/YourResponseSchema" }
      }
    }
  }
}

You can either duplicate the schema block from 2XX, or reference a shared schema definition. The important idea is that for each status code family you expect, you must declare a response so Flow can map it to variables.

There are two main approaches to fix this. The first and recommended approach is to modify the External Service definition (OpenAPI spec) to include the 4XX and 5XX responses and then reimport it. This ensures that the same change applies across all environments without having to rebuild your flow logic. The second approach, which is more of a workaround, is to catch the callout failure using a Fault path in Flow and treat the response as a raw string. However, this only gives you the raw body or an error message and takes you away from the typed JSON mapping that External Services provides, so it is less convenient and more brittle.

Therefore, the proper way to access the error payload is to expand the External Services definition by adding the 4XX and 5XX entries. Once those responses are defined, the error JSON will be available inside the normal Flow variables rather than hidden in defaultExc, and you can branch your logic based on the returned fields exactly as you do with successful responses.

Kick Start Your Journey with Real-Time Project-Based Salesforce Learning

Our Salesforce Course is designed to offer a complete understanding of the Salesforce platform, providing you with the necessary skills to excel in the CRM industry. The program covers essential modules such as Salesforce Admin, Developer, and AI, combining theoretical knowledge with practical experience. Through real-world projects and assignments, you’ll develop the expertise needed to solve complex business challenges using Salesforce solutions. Our expert instructors ensure you gain both technical skills and valuable industry insights to succeed in the Salesforce environment.

Along with technical expertise, our Salesforce training in Chennai offers personalized mentoring, certification preparation, and interview coaching to improve your career prospects. You’ll have access to comprehensive study resources, practical project experience, and continuous support throughout your learning journey. By the time you complete the course, you’ll be well-equipped for certification exams and capable of applying your problem-solving skills in real-world scenarios. Begin your Salesforce career with us and unlock limitless career opportunities. Enroll for a Free Demo today!

0
Would love your thoughts, please comment.x
()
x