Salesforce Einstein Predictions API

Make predictions using Discovery models

Documentation

Specifications

Other Resources

OpenAPI Specification

salesforce-einstein-predictions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Salesforce Einstein Bots AI Record Insights Predictions 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: Predictions
  description: Make predictions using Discovery models
paths:
  /wave/prediction:
    post:
      operationId: predict
      summary: Salesforce Einstein Make a prediction
      description: Makes a prediction using an Einstein Discovery model. Provide the model ID and input field values to receive a prediction with explanatory factors.
      tags:
      - Predictions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PredictionInput'
      responses:
        '200':
          description: Successful prediction response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictionOutput'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /sentiment:
    post:
      operationId: analyzeSentiment
      summary: Salesforce Einstein Analyze sentiment
      description: Analyzes the sentiment of the given text. Use the pre-built CommunitySentiment model or a custom-trained sentiment model.
      tags:
      - Predictions
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                modelId:
                  type: string
                  description: ID of the model to use. Use 'CommunitySentiment' for the pre-built model.
                document:
                  type: string
                  description: Text to analyze.
                numResults:
                  type: integer
                  description: Maximum number of results to return.
                  default: 3
              required:
              - modelId
              - document
      responses:
        '200':
          description: Successful sentiment analysis response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictionResponse'
        '400':
          $ref: '#/components/responses/BadRequest_2'
        '401':
          $ref: '#/components/responses/Unauthorized_2'
  /intent:
    post:
      operationId: detectIntent
      summary: Salesforce Einstein Detect intent
      description: Detects the intent of the given text. Requires a custom-trained intent model.
      tags:
      - Predictions
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                modelId:
                  type: string
                  description: ID of the custom intent model to use.
                document:
                  type: string
                  description: Text to classify.
                numResults:
                  type: integer
                  description: Maximum number of results to return.
                  default: 3
              required:
              - modelId
              - document
      responses:
        '200':
          description: Successful intent detection response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictionResponse'
        '400':
          $ref: '#/components/responses/BadRequest_2'
        '401':
          $ref: '#/components/responses/Unauthorized_2'
  /einstein/prediction-definitions/{predictionDefinitionId}/predictions:
    get:
      operationId: listPredictions
      summary: Salesforce Einstein List predictions for a definition
      description: Returns prediction results for a given prediction definition.
      tags:
      - Predictions
      parameters:
      - $ref: '#/components/parameters/PredictionDefinitionId'
      - name: recordId
        in: query
        description: Filter predictions by Salesforce record ID.
        schema:
          type: string
      - name: limit
        in: query
        description: Maximum number of predictions to return.
        schema:
          type: integer
          default: 25
      - name: offset
        in: query
        description: Offset for pagination.
        schema:
          type: integer
          default: 0
      responses:
        '200':
          description: Successful response with predictions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictionResultList'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /predict:
    post:
      operationId: predictImage
      summary: Salesforce Einstein Make a prediction
      description: Classifies an image using a trained model. Submit either an image file or a URL to an image.
      tags:
      - Predictions
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                modelId:
                  type: string
                  description: ID of the model to use for prediction.
                sampleLocation:
                  type: string
                  description: URL of the image to classify.
                sampleContent:
                  type: string
                  format: binary
                  description: Binary content of the image to classify.
                sampleBase64Content:
                  type: string
                  description: Base64-encoded image content.
                numResults:
                  type: integer
                  description: Maximum number of prediction results to return.
                  default: 3
              required:
              - modelId
      responses:
        '200':
          description: Successful prediction response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PredictionResponse'
        '400':
          $ref: '#/components/responses/BadRequest_3'
        '401':
          $ref: '#/components/responses/Unauthorized_3'
  /detect:
    post:
      operationId: detectObjects
      summary: Salesforce Einstein Detect objects in an image
      description: Detects objects and their bounding boxes in an image.
      tags:
      - Predictions
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                modelId:
                  type: string
                  description: ID of the object detection model to use.
                sampleLocation:
                  type: string
                  description: URL of the image.
                sampleContent:
                  type: string
                  format: binary
                  description: Binary content of the image.
                sampleBase64Content:
                  type: string
                  description: Base64-encoded image content.
              required:
              - modelId
      responses:
        '200':
          description: Successful detection response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetectionResponse'
        '400':
          $ref: '#/components/responses/BadRequest_3'
        '401':
          $ref: '#/components/responses/Unauthorized_3'
components:
  parameters:
    PredictionDefinitionId:
      name: predictionDefinitionId
      in: path
      required: true
      description: Unique identifier for the prediction definition.
      schema:
        type: string
  schemas:
    PredictionFactor:
      type: object
      properties:
        featureName:
          type: string
          description: Name of the feature contributing to the prediction.
        featureValue:
          type: string
          description: Value of the feature.
        importance:
          type: number
          description: Importance weight of the factor.
        direction:
          type: string
          enum:
          - Positive
          - Negative
          description: Whether the factor positively or negatively affects the prediction.
    DetectionResponse:
      type: object
      properties:
        probabilities:
          type: array
          items:
            $ref: '#/components/schemas/DetectionResult'
        object:
          type: string
    PredictionResultList:
      type: object
      properties:
        predictions:
          type: array
          items:
            $ref: '#/components/schemas/PredictionResult'
        totalSize:
          type: integer
    Error_2:
      type: object
      properties:
        message:
          type: string
          description: Human-readable error message.
        errorCode:
          type: string
          description: Machine-readable error code.
    PredictionResponse:
      type: object
      properties:
        probabilities:
          type: array
          items:
            $ref: '#/components/schemas/Probability'
        object:
          type: string
    PredictionInput:
      type: object
      properties:
        predictionDefinition:
          type: string
          description: ID of the prediction definition or model.
        columnNames:
          type: array
          description: Names of the input columns.
          items:
            type: string
        rows:
          type: array
          description: Input data rows for prediction.
          items:
            type: array
            items:
              type: string
      required:
      - predictionDefinition
      - columnNames
      - rows
    Error:
      type: object
      properties:
        message:
          type: string
        errorCode:
          type: string
        fields:
          type: array
          items:
            type: string
    DetectionResult:
      type: object
      properties:
        label:
          type: string
          description: Detected object label.
        probability:
          type: number
          description: Confidence score.
        boundingBox:
          $ref: '#/components/schemas/BoundingBox'
    BoundingBox:
      type: object
      properties:
        minX:
          type: integer
          description: Minimum X coordinate.
        minY:
          type: integer
          description: Minimum Y coordinate.
        maxX:
          type: integer
          description: Maximum X coordinate.
        maxY:
          type: integer
          description: Maximum Y coordinate.
    PredictionResult:
      type: object
      properties:
        recordId:
          type: string
          description: Salesforce record ID.
        prediction:
          type: object
          properties:
            score:
              type: number
              description: Prediction score.
            label:
              type: string
              description: Predicted label (for categorical predictions).
            factors:
              type: array
              description: Top factors influencing the prediction.
              items:
                $ref: '#/components/schemas/PredictionFactor'
        predictionDefinitionId:
          type: string
    Error_3:
      type: object
      properties:
        message:
          type: string
          description: Human-readable error message.
        errorCode:
          type: string
          description: Machine-readable error code.
    Probability:
      type: object
      properties:
        label:
          type: string
          description: Predicted label.
        probability:
          type: number
          description: Confidence score (0.0 to 1.0).
    PredictionOutput:
      type: object
      properties:
        predictionResults:
          type: array
          items:
            type: object
            properties:
              prediction:
                type: object
                properties:
                  total:
                    type: number
                    description: Predicted value.
                  baseLine:
                    type: number
                    description: Baseline prediction value.
              prescriptions:
                type: array
                items:
                  type: object
                  properties:
                    action:
                      type: string
                    description:
                      type: string
                    impact:
                      type: number
              middleValues:
                type: array
                items:
                  type: object
                  properties:
                    columnName:
                      type: string
                    value:
                      type: string
                    impact:
                      type: number
  responses:
    Unauthorized_2:
      description: Unauthorized. Invalid or missing bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error_2'
    BadRequest_3:
      description: Bad request. Invalid parameters or missing required fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error_3'
    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'
    BadRequest_2:
      description: Bad request. Invalid parameters or missing required fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error_2'
    Unauthorized_3:
      description: Unauthorized. Invalid or missing bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error_3'
    Unauthorized:
      description: Unauthorized.
      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