Loading

Salesforce Apex Error: System.CalloutException: Callout Loop Not Allowed

Fecha de publicación: Jun 11, 2026
Descripción

The Salesforce Apex error System.CalloutException: Callout loop not allowed occurs when a web service callout is initiated from within another active inbound callout. In Salesforce, you can make a callout from one Salesforce org (Org A) to another Salesforce org (Org B) or to an external web service. However, if Org B then makes its own outbound callout (for example, to a third-party web service) while still processing the inbound callout from Org A, Salesforce throws this error.
In plain terms: Org A sends a callout to Org B. Org B tries to call an external web service as part of handling that request. This chaining of callouts is not allowed. Salesforce does not permit a callout that is itself triggered by an active inbound callout.

Solución

Root Cause

Salesforce enforces a restriction that prevents a callout from originating within the context of another active inbound callout. This is a platform-level limitation designed to prevent infinite callout loops and to manage governor limit consumption.

Workaround Option 1: Direct Integration from Org A

Have Org A make both callouts independently rather than chaining through Org B. Org A calls the external web service directly as a separate callout, and then calls Org B as another separate callout. This avoids the nested callout scenario entirely.

Workaround Option 2: Asynchronous Processing in Org B

When Org B receives the callout from Org A, process the request asynchronously using a Queueable Apex class or a Platform Event. The asynchronous context in a Queueable job is not considered an active callout context, so Org B can then make its own outbound callout to the external web service without triggering the "Callout loop not allowed" error.

Workaround Option 3: Use a Middleware Layer

Route both callouts through an integration middleware platform (such as MuleSoft Anypoint) that handles the orchestration between Org A, Org B, and the external web service. This decouples the org-to-org and org-to-external communication entirely.

@RestResource(urlMapping='/createAccountPlan/*')
global with sharing class CallAccountPlan{
    
    @HttpGet
    global static String doGet(){
        soapSforceComSchemasClassAccplan.AccountPlan stub = new soapSforceComSchemasClassAccplan.AccountPlan();
        stub.SessionHeader = new soapSforceComSchemasClassAccplan.SessionHeader_element();
        stub.SessionHeader.sessionId = Session Id;
        return stub.createAccountPlan();
        }
}

Confirming the Error Source

To confirm that this error is caused by a callout loop and not another issue, check the Apex debug logs. The full exception message reads: System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: System.CalloutException: Callout loop not allowed. This confirms that the exception originated in Org B's callout attempt and was returned to Org A as a SOAP fault.

Número del artículo de conocimiento

000387966

 
Cargando
Salesforce Help | Article