Get the Agent ID for an Agent
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:
- New Agentforce Builder: This newer builder features a configurable interface that allows you to switch between Canvas view and Script view. It includes built-in AI assistance and Agent Script support. You access this builder through Agentforce Studio in the App Launcher. See Explore Agentforce Builder (Beta).
- Legacy Agentforce Builder: This original builder features a visual topic editor and dialog-based configuration. You access this builder through Setup > Agentforce Agents. See Explore the Legacy Agentforce Builder.
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.
- From Setup, navigate to your agent.
- When viewing the Agent Overview Page, look at the URL in your browser.
- Copy the 18-character ID at the end of the URL.
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:
The Id field in the query result is your agent ID.
- Agentforce Developer Guide: Get Started with the Agent API
- Metadata API Developer Guide: Bot
- Standard Object Reference: BotDefinition
- Salesforce Help: Explore Agentforce Builder (Beta)
- Salesforce Help: Explore the Legacy Agentforce Builder