Calling the Default Agentforce from Outside Salesforce Using the API
- Saurabh Singh
- 1 day ago
- 3 min read
Currently, the Salesforce Agentforce Agent API supports only the Agentforce Service Agent (ASA) type. It does not support agents of type “Agentforce (Default)” via the API. This means you cannot directly call the default Agentforce agent from outside Salesforce using the Agent API at this time.
The Agent API is presently compatible only with the Agentforce Service Agent (ASA) type. It does not support agents categorized as 'Agentforce (Default)'.
What Can You Do Instead?
Activating the Default Agent (Einstein Co-Pilot) via Flow - You can initiate your default agent directly from a flow, which can subsequently be invoked through a web service exposed by a Connected App. Here are the steps to achieve this. Begin by enabling your Default Agent.
Step 1: Develop a connected app, generate the client ID and secret, and assign the appropriate scope. Refer to Salesforce documentation or other resources for guidance.
Step 2: Develop a web service as described below. For testing purposes, this API can be called using Postman.
To test this API, it can be called from Postman using the following format:
{
"query": "how to enable agentforce",
"sessionId" : ""
}
At the beginning of a conversation, do not include anything in the sessionId, as it will initially be empty. Once the conversation is forwarded to Agentforce, a sessionId will be generated and returned in the response. You must then include this sessionId in the subsequent API call to ensure that the agent retains the context.
Step 3: Create an Autolaunched flow as described below. Add an action and search for "Copilot for Salesforce," which serves as your default agent. This default agent can perform tasks related to your system, such as creating custom fields, objects, and validation rules. Other agents do not have access to metadata.

For this flow create 3 variables.
Name - AgentSessionId
Type - Text
Enable this for Input & Output
Name - UserInput
Type - Text
Enable this for Input only
Name - Response
Type - Text
Enable this for Output only
Place these variables as mentioned in flow screenshot.
How to Test it - I am giving you the steps to test it using postman.
Step 1: Get the access token using client id, client secret.
POST /services/oauth2/token HTTP/1.1
Host: xyz--xyzorg.sandbox.my.salesforce.com
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&client_id=<your client id here>&client_secret=<your client secret here>
This will give you response like this. Copy the access token from this
{
"access_token": "<copy this token>",
"signature": "MGfqmQW8cxk1Te8Vm0=",
"token_format": "jwt",
"scope": "sfap_api chatbot_api api",
"instance_url": "https://xyz--xyzorg.sandbox.my.salesforce.com",
"id": "https://test.salesforce.com/id/00D7e00000/005f400000",
"token_type": "Bearer",
"issued_at": "1747139796",
"api_instance_url": "https://api.salesforce.com"
}
Step 2: Call the above "SetupHelper" like below
POST /services/apexrest/SetupHelper HTTP/1.1
Host: xyz--xyzorg.sandbox.my.salesforce.com
Content-Type: application/json
Authorization: Bearer <Paste access Token>
{
"query": "is there a custom object error log",
"sessionId" : ""
}
This will give response like this
"{\"sessionId\":\"9e431309-4f4c-4d3a-80bd-0e453e79d755\",\"response\":\"Yes, there is a custom object named \"Error_Log__c\". How can I assist you with it?\"}"
Now if you want to continue this context, then copy the sessionId from response and add to http request.
Conclusion:
The Salesforce Agentforce Agent API currently supports only the Agentforce Service Agent (ASA) type and does not support the default Agentforce agent via the API. To activate the default agent, known as Einstein Co-Pilot, you can use a flow and a web service exposed by a Connected App. Start by creating a connected app to generate a client ID and secret, then develop a web service to test the API using tools like Postman. Initially, the sessionId will be empty, but once the conversation is forwarded to Agentforce, a sessionId is generated for subsequent calls.
Create an Autolaunched flow with variables for AgentSessionId, UserInput, and Response. The default agent, Copilot for Salesforce, can handle tasks like creating custom fields and objects. To test, obtain an access token using the client ID and secret, and make API calls to interact with the default agent. This process allows you to maintain context in conversations by including the sessionId in subsequent requests.