Skip to main content
GPTfy - Salesforce Native AI Platform

Agentforce API

The Agentforce API, known as the Agent API, lets you reach your Agentforce agents from anywhere that can call a REST API. You start a session, send the agent messages, receive its responses, and end the session, all over REST.

The Agent API opens your agents to outside apps. Authentication uses an external client app with the client-credentials flow, and every call carries a token. A conversation is a session: create one, send messages against its ID, and close it when you're done. If you'd rather stay in Salesforce, you can also invoke an agent from Apex or Flow.

How does the Agent API work?

A conversation runs as a session. The basic flow has three steps.

1Start a session

Call the API to open a session and receive a session ID for the conversation.

2Send messages

Send a message against the session ID; the synchronous endpoint returns the agent's response in one reply.

3End the session

Close the session when the conversation is done.

How do you authenticate to the Agent API?

Access runs through an external client app that supports the client-credentials flow. Every call to the Agent API needs a token, which you create from the consumer key, the consumer secret, and your domain name. A parameter called bypassUser controls whether a call runs as the agent's assigned user or the user tied to the token.

Can you invoke Agentforce from Apex or Flow?

Yes. The Agent API is one option; you can also stay inside Salesforce. Deploy a REST-annotated Apex method that takes a user message and a session ID and returns the agent's response, or invoke an agent from Flow. Salesforce also publishes Postman collections and examples to get you started.

Where does GPTfy fit?

GPTfy takes a different route to AI in Salesforce. It is a Salesforce-native managed package that runs inside your org, lets you bring your own model, such as OpenAI, Anthropic's Claude, or Google Gemini, and can pull in external API data as a source for that model. It works on your Salesforce data and needs no Data Cloud. If you want to choose your own model and keep the AI close to your data, that is the case GPTfy is built for.

Agentforce API FAQ

What is the Agentforce API?

The Agentforce API, called the Agent API, lets you reach your Agentforce agents from anywhere that can call a REST API. You start a session, send messages to the agent, receive its responses, and end the session, all over REST.

How do you authenticate to the Agent API?

You set up an external client app that supports the client-credentials flow. Every call needs a token, which you create from the consumer key, consumer secret, and your domain name.

How does an Agent API conversation work?

You create a session and get back a session ID, then use that ID to send messages. The synchronous endpoint returns the agent's response in a single reply. When you're done, you end the session.

Can you invoke Agentforce from Apex or Flow?

Yes. Besides the Agent API, you can expose an agent over REST with an annotated Apex method that takes a message and session ID and returns the agent's response, and you can invoke agents from Flow.

Connect your own model and data in Salesforce

Book a walkthrough and see how GPTfy brings your AI model and external APIs together on your Salesforce data, inside your org.