# Sentiment analysis

> Analyze tone, emotions, and sentiment trends from transcribed audio — with Arabic sentiment interpretation that's aware of cultural context. Transcribe first, then point this endpoint at the transcriptionId.

## What you get

Sentiment analysis processes already transcribed audio to extract emotional insights and sentiment patterns, at multiple depth levels.

| Insight | Detail |
| --- | --- |
| **Overall sentiment** | Sentiment and polarity analysis across the full content. |
| **Key emotions** | Detected emotions with confidence scoring. |
| **Speaker breakdowns** | Speaker-level sentiment for each participant. |
| **Temporal trends** | How sentiment shifts across the conversation. |

Typical use cases: call center quality and customer experience monitoring; public speech, media, and interview sentiment tracking; meeting intelligence and post-call emotional analysis.

> This is post-call analysis of an existing transcription. For real-time per-turn sentiment during a live call, use the Sentiment event on WS /api/v1/listen — no extra request needed. Note that confidence_score here is the confidence of the sentiment analysis itself, unrelated to ASR confidence.

## How it works

This endpoint runs **on top of an existing transcription** — it never touches raw audio itself.

| Step | What happens |
| --- | --- |
| **1 · Transcribe first** | Run the audio through [Audio Transcription](/speech-to-text/transcribe). |
| **2 · Use the transcription ID** | Send the returned `transcriptionId` to Sentiment Analysis. |
| **3 · Choose depth** | Pick `light`, `standard`, or `deep` depending on how detailed you want the output. |
| **4 · Review insights** | Receive emotional and sentiment analysis for the full content and individual speakers. |

> Want sentiment per speaker turn, in one call? Diarization + sentiment transcribes, splits speakers and scores sentiment in a single request.

## Endpoint

`POST /api/v1/audio/{transcriptionId}/sentiment-analysis`

Authenticated with the `x-api-key` header.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `transcriptionId` | path | string | **Yes** | ID from the Audio Transcription response. |
| `analysis_depth` | body | string | No | `light`, `standard`, or `deep`. |

## Analyze a transcription

Replace `805059bf-7c3f-4a1e-9d2b-1f0c6ae83b47` with the `transcriptionId` your transcription call returned.

```bash
curl -X POST "https://api.munsit.com/api/v1/audio/805059bf-7c3f-4a1e-9d2b-1f0c6ae83b47/sentiment-analysis" \
  -H "x-api-key: YOUR_MUNSIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "analysis_depth": "standard" }'
```

```python
import requests

transcription_id = "805059bf-7c3f-4a1e-9d2b-1f0c6ae83b47"  # from the Audio Transcription response

response = requests.post(
    f"https://api.munsit.com/api/v1/audio/{transcription_id}/sentiment-analysis",
    headers={"x-api-key": "YOUR_MUNSIT_API_KEY"},
    json={"analysis_depth": "standard"},
)

analysis = response.json()
print(analysis["data"]["overall_sentiment"])
```

```javascript
const transcriptionId = "805059bf-7c3f-4a1e-9d2b-1f0c6ae83b47"; // from the Audio Transcription response

const response = await fetch(
  `https://api.munsit.com/api/v1/audio/${transcriptionId}/sentiment-analysis`,
  {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_MUNSIT_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ analysis_depth: 'standard' }),
  }
);

const analysis = await response.json();
console.log(analysis.data.overall_sentiment);
```

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
    "os"
)

func main() {
    transcriptionID := "805059bf-7c3f-4a1e-9d2b-1f0c6ae83b47" // from the Audio Transcription response
    url := fmt.Sprintf("https://api.munsit.com/api/v1/audio/%s/sentiment-analysis", transcriptionID)
    body, _ := json.Marshal(map[string]string{"analysis_depth": "standard"})

    req, _ := http.NewRequest("POST", url, bytes.NewReader(body))
    req.Header.Set("x-api-key", os.Getenv("MUNSIT_API_KEY"))
    req.Header.Set("Content-Type", "application/json")

    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()

    var analysis map[string]any
    json.NewDecoder(resp.Body).Decode(&analysis)
    fmt.Println(analysis["data"].(map[string]any)["overall_sentiment"])
}
```

## Response

The response covers full-content sentiment plus per-speaker and per-moment detail. Depth controls how much of it is populated.

| Field | What it holds |
| --- | --- |
| `language` | Detected language of the analyzed transcript. |
| `overall_sentiment` | Overall sentiment and polarity for the full content. |
| `key_emotions` | Key emotions detected, with confidence scoring. |
| `speaker_sentiment` | Speaker-level sentiment breakdowns. |
| `sentiment_trends` | Temporal sentiment trends across the conversation. |
| `critical_moments` | Notable emotional moments in the conversation. |
| `confidence_score` | Confidence for the analysis as a whole. |
| `analysis_depth` | The depth level the analysis ran at. |
| `processing_metadata` | Metadata about the processing run. |

## Go further

Sentiment is one lens on a transcript — the others are a call away.

- [Transcribe audio](/speech-to-text/transcribe) — Produce the transcriptionId this endpoint needs. — `POST /speech-to-text`

- [Diarization + sentiment](/speech-to-text/diarization-sentiment) — Speakers and sentiment together, in one request. — `POST /stt-diarization`

- [Keyword extraction](/understanding/keyword-extraction) — Pull entities, terms and themes from the same transcript. — `POST …/keyword-extraction`

- [Translation](/understanding/translation) — Translate the transcript with streaming output. — `POST /translation/stream`
