All Reference

Agent API

Agent API (v1.0.0)

Download OpenAPI specification:Download

Use Agent API to communicate with AI agents in your org. Get access to your topics and actions in Agentforce by sending messages to AI agents. Create a Salesforce app in your org, generate a token, and then start using the API. To onboard to this API, see Get Started with the Agent API and Agent API Examples.

Postman Collection

The quickest way to get started with the Agent API is with our Postman collection.

Endpoints

Start a session

Begin an agent session. The endpoint contains the ID of the Salesforce agent. You can find this ID in the URL of the agent details page. When you select the agent from Setup, use the ID at the end of the URL.

path Parameters
id
required
string

The ID of the Salesforce agent. You can find this ID in the URL of the agent details page. When you select the agent from Setup, use the ID at the end of the URL.

header Parameters
Authorization
required
string
Example: Bearer •••••

Authorization information that contains the JWT.

Request Body schema: application/json
required

Request payload to initiate a session.

externalSessionKey
required
string (ExternalSessionKey)

UUID that you provide for the conversation. You can use this parameter to trace the conversation in your agent's event logs.

required
object (InstanceConfig)

API configuration parameters.

tz
string

Client timezone where the customer starts the chat. Uses the tz database timezone format. Can be null.

Array of objects (Variables)

Array of custom and context agent variables passed to the agent during a session. See Agent Variables. Many variables are read-only and can only be set during the start session call. By default, context variables (which have the $Context prefix) aren't editable after the session has started, except for the $Context.EndUserLanguage variable. You can only modify editable variables during a send message call. When specifying variables that are derived from custom fields, omit the __c suffix. For instance, Conversation_Key__c becomes $Context.Conversation_Key. This array can be null.

featureSupport
string (SessionFeature)
Enum: "Sync" "Streaming"

Defines how the session supports message processing.

object (StreamingCapability)

Describes the streaming capabilities.

bypassUser
boolean

Indicates whether to use the agent-assigned user instead of the logged in user. If set to true, the API uses the user associated with the agent. If set to false, the API uses the user associated with the token. Set this value to true when using the client credentials flow. Defaults to false.

Responses

Request samples

Content type
application/json
{
  • "externalSessionKey": "57904eb6-5352-4c5e-adf6-5f100572cf5d",
  • "instanceConfig": {},
  • "tz": "America/Los_Angeles",
  • "variables": [
    ],
  • "featureSupport": "Sync",
  • "streamingCapabilities": {
    },
  • "bypassUser": "true"
}

Response samples

Content type
application/json
{}

Send a message (synchronous)

Send a synchronous message to the agent on an active session. The endpoint contains the ID of the active session, which was returned in the response of the Start Session call.

path Parameters
session-id
required
string

The ID of the active session, which is the sessionId value returned from the Start Session call.

header Parameters
Authorization
required
string
Example: Bearer •••••

Authorization information that contains the JWT.

Request Body schema: application/json
required

Request payload to continue the chat.

required
object (AbstractRequestMessage)

Represents the message to be sent. Can be one of the following request message types: Text, Reply, Cancel, TransferFailed, TransferSucceeded, PlanTemplate.

Array of objects (Variables)

Array of custom and context agent variables passed to the agent during a session. See Agent Variables. Many variables are read-only and can only be set during the start session call. By default, context variables (which have the $Context prefix) aren't editable after the session has started, except for the $Context.EndUserLanguage variable. You can only modify editable variables during a send message call. When specifying variables that are derived from custom fields, omit the __c suffix. For instance, Conversation_Key__c becomes $Context.Conversation_Key. This array can be null.

Responses

Request samples

Content type
application/json
{
  • "message": {
    },
  • "variables": [
    ]
}

Response samples

Content type
application/json
{}

Send a message (streaming)

Send a streaming message to the agent on an active session. Returns an SSE stream in the response. The endpoint contains the ID of the active session, which was returned in the response of the Start Session call.

path Parameters
session-id
required
string

The ID of the active session, which is the sessionId value returned from the Start Session call.

header Parameters
Authorization
required
string
Example: Bearer •••••

Authorization information that contains the JWT.

Accept
required
string
Example: text/event-stream

Indicates which content type the sender is able to understand. For this endpoint, specify text/event-stream.

Request Body schema: application/json
required

Request payload to continue the chat.

required
object (AbstractRequestMessage)

Represents the message to be sent. Can be one of the following request message types: Text, Reply, Cancel, TransferFailed, TransferSucceeded, PlanTemplate.

Array of objects (Variables)

Array of custom and context agent variables passed to the agent during a session. See Agent Variables. Many variables are read-only and can only be set during the start session call. By default, context variables (which have the $Context prefix) aren't editable after the session has started, except for the $Context.EndUserLanguage variable. You can only modify editable variables during a send message call. When specifying variables that are derived from custom fields, omit the __c suffix. For instance, Conversation_Key__c becomes $Context.Conversation_Key. This array can be null.

Responses

Request samples

Content type
application/json
{
  • "message": {
    },
  • "variables": [
    ]
}

Response samples

Content type
application/json
{
  • "status": 400,
  • "path": "/v6/00DRM00000067To/sessions/HelloWorldBot/messages",
  • "requestId": "19c056ab-d909-49df-b976-65e56b6ab214",
  • "error": "BadRequestError",
  • "message": "Bad Request",
  • "timestamp": 1531245973799
}

End an active session

Send a message to the agent to end a session. The endpoint contains the ID of the active session, which was returned in the response of the Start Session call.

path Parameters
session-id
required
string

The ID of the active session, which is the sessionId value returned from the Start Session call.

header Parameters
Authorization
required
string
Example: Bearer •••••

Authorization information that contains the JWT.

x-session-end-reason
required
string (EndSessionReason)
Enum: "UserRequest" "Transfer" "Expiration" "Error" "Other"
Example: UserRequest

The reason the session ended.

Responses

Response samples

Content type
application/json
{}

Submit feedback

Submit feedback for a message. Feedback data is stored in Data 360.

path Parameters
session-id
required
string

The ID of the session, which is the sessionId value returned from the Start Session call.

header Parameters
Authorization
required
string
Example: Bearer •••••

Authorization information that contains the JWT.

Request Body schema: application/json
required

The feedback payload.

feedbackId
required
string (FeedbackId)

Unique ID to identify the generation. Used to submit feedback.

feedback
required
string (FeedbackRating)
Enum: "GOOD" "BAD"

Feedback rating, suggesting a thumbs up or thumbs down.

text
string

Textual representation of user feedback.

object <= 10 properties

Additional details to provide as key value pairs.

Responses

Request samples

Content type
application/json
{
  • "feedbackId": "9247bbd8-5ed9-11ee-8c99-0242ac120002",
  • "feedback": "GOOD",
  • "text": "Email looks great.",
  • "details": {
    }
}

Response samples

Content type
application/json
{
  • "status": 400,
  • "path": "/v6/00DRM00000067To/sessions/HelloWorldBot/messages",
  • "requestId": "19c056ab-d909-49df-b976-65e56b6ab214",
  • "error": "BadRequestError",
  • "message": "Bad Request",
  • "timestamp": 1531245973799
}