---
schema_version: "1"
id: fe8ffefd44c5644f9508e0130b7ce2e6ed2ea0f3f252ffcb7dcdc7b133c2a76f
title: Get Predictions
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/bi_dev_guide_rest_sdd/bi_edd_prediction_service_predict.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest_sdd.meta/bi_dev_guide_rest_sdd/bi_edd_prediction_service_predict.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: d8e781d824ff6c91894bbcf544eedd2a082bf174554d28b7743a89ae7c477586
description: The Einstein Prediction Service provides a REST API endpoint to request a prediction.
---
# Get Predictions

The Einstein Prediction Service provides a REST API endpoint to request a prediction.

## Prediction Request

POST ​/smartdatadiscovery​/predict

## POST Request Body

Use one of the following to create your request body, [Smart Data Discovery Predict Input](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest_sdd.meta/bi_dev_guide_rest_sdd/bi_sdd_requests_smart_data_discovery_predict_input.htm "The predict input for Einstein Discovery."), [Smart Data Discovery Predict Raw Data Input](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest_sdd.meta/bi_dev_guide_rest_sdd/bi_sdd_requests_smart_data_discovery_predict_raw_data_input.htm "The predict raw data input for Einstein Discovery."), [Smart Data Discovery Predict Record Overrides Input](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest_sdd.meta/bi_dev_guide_rest_sdd/bi_sdd_requests_smart_data_discovery_predict_record_overrides_input.htm "The predict record overrides input for Einstein Discovery."), or [Smart Data Discovery Predict Record Input](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest_sdd.meta/bi_dev_guide_rest_sdd/bi_sdd_requests_smart_data_discovery_predict_record_input.htm "The predict record input for Einstein Discovery.").

In the request body, you specify the prediction definition to use and the rows of data that you want to score. You can specify rows in one of three available formats:

| Format | Description |
| --- | --- |
| Records | Salesforce record Ids associated with the subscribedEntity of the prediction definition (retrieved using a SOQL query). |
| RawData | A two-dimensional array of row values in which each row is a comma-separated list of values. |
| RecordOverrides | Array of objects containing the Salesforce record Ids. Optionally, override or append values in individual records with an array of row values (in which each row is a comma-separated list of values). |

When you run a prediction, Salesforce applies the model specified in the prediction definition to the set of records and returns a prediction score for each record. If you specify 3 records, for example, you get 3 predictions in the order in which the records were specified in the request.

Sample Request when type is Records

The following example shows a request body in which type is Records. The records attribute provides a comma-separated list of Salesforce record Ids associated with the subscribedEntity of the prediction definition. You can retrieve a list of available prediction definition Ids using the following API request:

GET ​/smartdatadiscovery​/predictiondefinitions

You can specify up to 200 Salesforce record Ids. Two records are specified in the following example:

{
   "predictionDefinition": "1ORRM00000000304AA",
   "type": "Records",
   "records": \["006RM000002bEfiYAE", "006RM000002bEflYAE" \]
}

Sample Request when type is RawData

The following example shows a request body in which type is RawData. It names five columns and specifies two records with five data values each. The columns were selected during the story setup process. For more information, see [Create a Story](https://help.salesforce.com/s/articleView?id=analytics.bi_edd_create.htm&type=5&language=en_US).

{
  "predictionDefinition": "0OR1H000000Gma9WAC",
  "type": "RawData",
  "columnNames": \["StageName","CloseDate","Account.BillingCountry","IsClosed","IsWon"\],
  "rows": \[
    \["Prospecting","2020-06-30","USA","false","false"\],
    \["Qualification","2020-08-30","EMEA", "false","false"\]
  \]
}

Sample Request when type is RecordOverrides

The following example shows a request body in which type is RecordOverrides. When specifying row data:

- Each Salesforce record Id represents a record in the subscribedEntity associated with the prediction definition.
- (Optional) Each row, where specified, contains the values to override or append to the data specified in the associated record.

You can specify up to 200 entries (record entries plus row entries) in a request. For example, if you have 120 record entries, you can override up to 80 record entries with row entries. The following example specifies two columns with two record entries and two overrides.

{
  "predictionDefinition": "0OR1H000000Gma9WAC",
  "type": "RecordOverrides",
  "columnNames": \["StageName", "CloseDate"\],
  "rows": \[
          
      {
         "record": "0061H00000dnhQEQAY",
          "row": \["Prospecting", "2020-06-30"\]
      },
          
      {
          "record": "0061H00000dnhPzQAI",
          "row": \["Qualification", "2020-08-30"\]
      }
          
  \]
}

Sample Request for Predictive Factors and Improvements

Starting in 50.0, this API returns a single prediction value by default. To request prediction factors and improvements, you must ask for them explicitly in the request body. The following code snippet specifies settings to request prediction factors and improvements.

{
    "predictionDefinition": "1ORB0000000TNYIOA4",
    "type": "Records",
    "records": \["006B0000002wvCtIAI"\],
    "settings": {"maxPrescriptions": 3, 
        "maxMiddleValues": 3,
        "prescriptionImpactPercentage": 87 
    }
}

In this example:

- maxPrescriptions specifies the maximum number of improvements (1-3) to return in the response
- maxMiddleValues specifies the number of top predictors (1-3) to return in the response
- prescriptionImpactPercentage specifies the threshold filter (minimum % improvement for the outcome, which in this example is 87%) needed for the improvement to be returned in the response

To learn more about these settings and see these elements on an example Lightning page, see [Add Einstein Predictions to a Lightning Page](https://help.salesforce.com/s/articleView?id=analytics.bi_edd_einstein_predictions_lightning.htm&type=5&language=en_US).

## POST Response

The POST response is a [Smart Data Discovery Predict List](https://developer.salesforce.com/docs/atlas.en-us.bi_dev_guide_rest_sdd.meta/bi_dev_guide_rest_sdd/bi_sdd_responses_smart_data_discovery_predict_list.htm "A list of Einstein Discovery predictions.") response.

Example POST Response

{
  "predictionDefinition" : "1ORRM0000000030",
  "predictions" : \[ {
    "model" : {
      "id" : "1OtRM000000002b0AA"
    },
    "prediction" : {
      "baseLine" : 799315.4282959097,
      "importWarnings" : {
        "mismatchedColumns" : \[ \],
        "missingColumns" : \[ "OpportunityAge", "Account.Owner.UniqueUserName", "Account.Industry", "Account.AccountSource", "Account.Owner.Name", "Account.BillingCountry", "Name" \],
        "outOfBoundsColumns" : \[ \]
      },
      "middleValues" : \[ {
        "columns" : \[ {
          "columnName" : "Has Line Item",
          "columnValue" : "true"
        } \],
        "value" : 543763.66105859
      } \],
      "other" : 0.0,
      "smallTermCount" : 0,
      "total" : 1343079.0893544997
    },
    "prescriptions" : \[ \],
    "status" : "Success"
  }, {
    "model" : {
      "id" : "1OtRM000000002b0AA"
    },
    "prediction" : {
      "baseLine" : 799315.4282959097,
      "importWarnings" : {
        "mismatchedColumns" : \[ \],
        "missingColumns" : \[ "OpportunityAge", "Account.Owner.UniqueUserName", "Account.Industry", "Account.AccountSource", "Account.Owner.Name", "Account.BillingCountry", "Name" \],
        "outOfBoundsColumns" : \[ \]
      },
      "middleValues" : \[ {
        "columns" : \[ {
          "columnName" : "Has Line Item",
          "columnValue" : "true"
        } \],
        "value" : 543763.66105859
      } \],
      "other" : 0.0,
      "smallTermCount" : 0,
      "total" : 1343079.0893544997
    },
    "prescriptions" : \[ \],
    "status" : "Success"
  } \],
  "settings" : {
    "maxPrescriptions" : 0,
    "maxMiddleValues" : 0,
    "prescriptionImpactPercentage" : 0
  }
}