Get the Agent ID
Session Lifecycle
Examples
Variables
Considerations
Troubleshooting
Export Agentforce Session Tracing Data
Before you can use the Agent API, you need the agent ID. The method for obtaining this ID depends on which builder you used to create your agent.
Salesforce provides two different agent builders. To determine which one you’re using:
Depending on which Agentforce Builder you’re using, the method for acquiring the agent ID is different.
If you created your agent with the Legacy Agentforce Builder, you can find the agent ID directly in the URL of the Agent Overview Page.
For example, using this URL, https://mydomain.salesforce-setup.com/lightning/setup/EinsteinCopilot/0XxSB000000IPCr0AO/edit, the agent ID is 0XxSB000000IPCr0AO.
If you created your agent with the new Agentforce Builder, you need the bot ID from the Bot metadata type or the BotDefinition standard object. The bot ID represents the agent ID in this case. In this example, we get the BotDefinition standard object in a SOQL query using the agent’s developer name:
1SELECT Id, DeveloperName
2FROM BotDefinition
3WHERE DeveloperName = 'Agentforce_Service_Agent'The Id field in the query result is your agent ID.