Invoke a deployed Salesforce Agentforce agent from an external system using the Agent API

domain: developer.salesforce.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to developer.salesforce.com, checked against official docs, with linked verified routes.

Steps

  1. Register an external client app in Salesforce Setup with OAuth scopes: chatbot_api, sfap_api, api, and refresh_token; configure the Client Credentials flow for server-to-server calls.
  2. Obtain an access token via the OAuth 2.0 client credentials flow: POST to https://<instance>.salesforce.com/services/oauth2/token with grant_type=client_credentials.
  3. Start an agent session: POST https://api.salesforce.com/einstein/ai-agent/v1/agents/<agentId>/sessions with a JSON body containing externalSessionKey (a UUID), instanceConfig.endpoint (your org URL), and streamingCapabilities.
  4. Send a message to the agent within the session: POST https://api.salesforce.com/einstein/ai-agent/v1/sessions/<sessionId>/messages with body {"message": {"role": "user", "content": [{"type": "text", "text": "<user input>"}]}.
  5. Parse the streaming or synchronous response to extract the agent's reply text and any action outputs; handle the sequenceId to maintain conversation order.
  6. End the session when the conversation is complete: DELETE https://api.salesforce.com/einstein/ai-agent/v1/sessions/<sessionId>.

Known gotchas

Related routes

Call a custom Salesforce Apex REST endpoint from an external system
salesforce.com · 6 steps · unrated
Register an external REST API as a Salesforce External Service and invoke it from Apex
developer.salesforce.com · 6 steps · unrated
Publish a Salesforce Platform Event from an external system and handle the subscriber response
salesforce.com · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans