Salesforce Einstein Sessions API

Manage bot conversation sessions

Documentation

Specifications

Other Resources

OpenAPI Specification

salesforce-einstein-sessions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Salesforce Einstein Bots AI Record Insights Sessions API
  description: Conversational AI API for building intelligent chatbots and virtual assistants. Einstein Bots provides REST endpoints to create, manage, and interact with AI-powered bots that can handle customer service conversations across channels.
  version: 58.0.0
  contact:
    name: Salesforce Developer Support
    url: https://developer.salesforce.com/
  license:
    name: Salesforce Master Subscription Agreement
    url: https://www.salesforce.com/company/legal/agreements/
  termsOfService: https://www.salesforce.com/company/legal/agreements/
servers:
- url: https://{instance}.salesforce.com/services/data/v58.0
  description: Salesforce Instance
  variables:
    instance:
      default: login
      description: Your Salesforce instance domain.
security:
- oauth2: []
tags:
- name: Sessions
  description: Manage bot conversation sessions
paths:
  /einstein/bots/{botId}/sessions:
    post:
      operationId: createSession
      summary: Salesforce Einstein Create a bot session
      description: Creates a new conversation session with an Einstein Bot. Returns a session ID to use for sending and receiving messages.
      tags:
      - Sessions
      parameters:
      - $ref: '#/components/parameters/BotId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionInput'
      responses:
        '201':
          description: Bot session created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /einstein/bots/{botId}/sessions/{sessionId}:
    get:
      operationId: getSession
      summary: Salesforce Einstein Get session details
      description: Returns the current status and details of a bot session.
      tags:
      - Sessions
      parameters:
      - $ref: '#/components/parameters/BotId'
      - $ref: '#/components/parameters/SessionId'
      responses:
        '200':
          description: Successful response with session details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      operationId: endSession
      summary: Salesforce Einstein End a bot session
      description: Ends an active bot conversation session.
      tags:
      - Sessions
      parameters:
      - $ref: '#/components/parameters/BotId'
      - $ref: '#/components/parameters/SessionId'
      responses:
        '204':
          description: Session ended successfully.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    Error:
      type: object
      properties:
        message:
          type: string
        errorCode:
          type: string
        fields:
          type: array
          items:
            type: string
    Session:
      type: object
      properties:
        sessionId:
          type: string
          description: Unique session identifier.
        botId:
          type: string
          description: Bot associated with the session.
        status:
          type: string
          enum:
          - Active
          - Ended
          - Transferred
          description: Current status of the session.
        createdDate:
          type: string
          format: date-time
        lastActiveDate:
          type: string
          format: date-time
    SessionInput:
      type: object
      properties:
        forceConfig:
          type: object
          description: Configuration settings for the session.
          properties:
            endpoint:
              type: string
              description: Messaging endpoint for the bot.
        externalSessionKey:
          type: string
          description: External key to associate with the session.
      required:
      - forceConfig
  parameters:
    SessionId:
      name: sessionId
      in: path
      required: true
      description: Unique identifier for the bot session.
      schema:
        type: string
    BotId:
      name: botId
      in: path
      required: true
      description: Unique identifier for the Einstein Bot.
      schema:
        type: string
  responses:
    Unauthorized:
      description: Unauthorized.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadRequest:
      description: Bad request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    oauth2:
      type: oauth2
      description: Salesforce OAuth 2.0 authentication.
      flows:
        authorizationCode:
          authorizationUrl: https://login.salesforce.com/services/oauth2/authorize
          tokenUrl: https://login.salesforce.com/services/oauth2/token
          scopes:
            api: Full access to Salesforce APIs
            einstein_gpt: Access to Einstein AI features