---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, Workday AI Gateway, AI Gateway]
nav: wcp_docs
parent_url: /wcp_docs/
title: Sentiment Analysis REST API
layout: subsection
---

The Sentiment Analysis REST API uses machine learning and language models to rate the sentiment within text as negative, positive, or neutral. This API can identify the sentiments within the text as "aspects" of the text, evaluate each aspect separately, and associate a sentiment with it. Note that you can have text containing different sentiments. Example: You can rate a restaurant as neutral, with the food being positive but the service being negative. Food and service would be aspects, with the restaurant being the sum total.

You can also use the Sentiment Analysis REST API to analyze Anytime Feedback comments or survey narratives.



## <a id="section_1"></a>URL Base Path

The Sentiment Analysis Forecaster API endpoint uses this base URL:

```
https://api.workday.com/ml/sentiment-analysis/{version}
```

For regional URL base paths, see [Reference: Workday Extend API Gateways and Authorization Base URLs](/wcp_docs/dlh1653340161856.html)

## <a id="section_2"></a>Security Considerations

For client tools such as Postman, use the Bearer token for your tenant API access.

For Extend apps, see [Concept: Extend App Security](/wcp_docs/vel1628698852360.html).

## <a id="section_9"></a>Rating Sentiment

To associate a sentiment to a body of text, call this endpoint:

```
POST {baseURL}/predict
```

In the request body, specify these required fields:

-   `input_queries` - A list of strings containing the text to analyze. Each text string should have between 1 and 512 words.
-   `return_aspects` - A string containing either `"True"` or `"False"`. If `"True"`, the endpoint also returns the aspects in the input text that resulted the sentiment.


The POST endpoint returns an overall sentiment and confidence scores for each possible sentiment:

-   Negative
-   Neutral
-   Positive


Sample request:

```
POST https://api.workday.com/ml/sentiment-analysis/v1/predict
```

Sample request body:

```
{
  "input_queries": ["The class was great. The activities and quizzes were too challenging for what they taught us."],
  "return_aspects": "True"
}
```

Sample response:

```
[
  {
      "sentence": "The class was great. The activities and quizzes were too challenging for what they taught us.",
      "sentiment": "Positive",
      "confidence": {
          "Negative": 0.0061,
          "Neutral": 0.0318,
          "Positive": 0.9621
      },
      "aspects": {
          "all_sentences": "The class was great. The activities and quizzes were too challenging for what they taught us.",
          "all_aspects": [
              "activities",
              "quizzes"
          ],
          "all_sentiments": [
              "negative",
              "negative"
          ],
          "aspect_sentiment_specifics": [
              {
                  "sentence": "The activities and quizzes were too challenging for what they taught us.",
                  "aspect": "activities",
                  "sentiment": "negative"
              },
              {
                  "sentence": "The activities and quizzes were too challenging for what they taught us.",
                  "aspect": "quizzes",
                  "sentiment": "negative"
              }
          ]
      }
  }
]
```

## <a id="section_4"></a>Limitations

The Sentiment Analysis REST API accepts input text with a limit of 512 words, and returns an error if the input text exceeds the limit.

## <a id="section_15"></a>Common Errors

<table><thead><tr><th>Error</th><th>Cause and Solution</th></tr></thead><tbody><tr><td>400</td><td><ul><li>Exceeded input text maximum.
</li><li>Incorrect text type.
</li><li>Incorrect API parameters.
</li></ul></td></tr><tr><td>403</td><td><ul><li>Innovation Services not opted in. See <i>Tenant Availability and Setup</i> in <a href="/wcp_docs/GUID-6a9a5c40-42e1-4b9b-911d-ba5457fc61ce.html">Concept: Workday AI Gateway</a>.
</li><li>Insufficient permissions. Note that AI Gateway is available in:

<ul><li>Development tenants for all Extend customers.
</li><li>Non-Development tenants for Extend Professional customers <i>only</i>.
</li></ul></li></ul></td></tr><tr><td>500</td><td>The Sentiment Analysis service might be unavailable. If you repeatedly encounter this error, contact Customer Support to open a support case.</td></tr></tbody></table><br/>

