QuestionQ171

VerifiedAI Agents

A company created a custom Apex action that an Employee Agent invokes to retrieve data from an external API. The callout method authenticates the callout by using the current user’s Salesforce session ID. The external callout works correctly in the UI but fails silently when the agent invokes it.

What architectural best practice resolves this issue?

Explanation

Apex callouts should use a Named Credential, with an associated External Credential as needed, to manage the endpoint and authentication outside Apex code. This avoids depending on an interactive user’s Salesforce session ID, which is not a dependable credential in an agent execution context, and provides a supported authentication configuration for the external API.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!