02Chapter 2: Preparing the agent: activate it and find its IDThis chapter assumes you know basic REST and JSON, have a Salesforce org with Agentforce enabled, and have built at least one agent. Before any code can call your agent, the agent must be active and you must know its ID. Both steps are quick, and skipping either one is a common cause of failed sessi2 min read
03Chapter 3: Creating an External Client App with the right scopesThis chapter assumes you are a Salesforce admin or have one nearby. It also assumes you know what an OAuth 2.0 access token is, and that your org has Agentforce enabled with an activated agent. Here you set up the identity your external system uses to call the Agent API.2 min read
04Chapter 4: How the client credentials flow and run-as user workThis chapter assumes you know what an OAuth 2.0 access token is, can read short Python and curl examples, and have an External Client App with scopes configured. Here you will see what the client credentials flow does, which Salesforce user the agent acts as, and why that matters.2 min read
05Chapter 5: Requesting an access token from your My DomainThis chapter shows how to request an access token for the Agent API. It assumes you can read short Python and curl examples, know what an OAuth 2.0 access token is, and have already created an External Client App with the client credentials flow enabled. You will also need its consumer key and consu2 min read
06Chapter 6: Understanding the session lifecycleThis chapter assumes you know basic REST and HTTP methods, can read JSON, and understand what an OAuth 2.0 access token is. It also assumes you have an Agentforce agent built in your org. Here you learn how an Agent API conversation is structured before you write the calls in the next chapters.3 min read
07Chapter 7: Creating a sessionThis chapter covers the request that opens a conversation with an Agentforce agent. It assumes you can already get an access token (see the previous chapter), that your agent is activated, and that you have its agent ID. You should also be comfortable reading short Python examples and JSON bodies.2 min read
08Chapter 8: Sending a message and getting a replyThis chapter covers the synchronous message call. You send one message to an open session and wait for the full reply. It assumes you can already get an access token and create a session, and that you know basic REST and JSON.2 min read
09Chapter 9: Reading the response and message typesThis chapter assumes you can already create a session and send a message, as shown in the previous chapters. Here you will look at what comes back and how to handle it in code.2 min read
10Chapter 10: Ending the sessionThis chapter assumes you can already get an access token, create a session, and send a message, as covered in the earlier chapters. It covers how to close a session and why you should always do so.2 min read
11Chapter 11: Streaming replies as they are generatedThis chapter assumes you can already create a session and send a synchronous message, as shown in the earlier chapters. You also need a valid access token and an open session ID.3 min read
12Chapter 12: Passing variables and context to the agentThis chapter assumes you can already create a session and send a message with the Agent API, as shown in the earlier chapters. It also assumes you know what a JSON array of objects looks like.2 min read
13Chapter 13: Handling expired tokens, errors and retriesThis chapter assumes you can already request a token, create a session, and send a message with the earlier examples. Here you wrap those calls so a short outage or an expired token does not end the conversation.2 min read
14Chapter 14: Protecting secrets and limiting accessThis chapter covers how to keep the credentials and access of your Agent API integration small and safe. It assumes you can already request an access token with the client credentials flow and create a session, as covered in earlier chapters.3 min read
15Chapter 15: Testing and troubleshooting the integrationThis chapter assumes you have built the full flow from the earlier chapters: an External Client App, a token request, a session, a message, and session end. It shows how to test each stage separately and how to read the failures you are most likely to see.1 min read