# Diarization + sentiment

> Analyze sentiment from a diarization output by its diarization ID — overall tone, per-speaker sentiment and trends across the conversation, at the analysis depth you choose.

## Endpoint

`POST /api/v1/diarization/{diarizationId}/sentiment-analysis`

Authenticate with your API key in the `x-api-key` header. See [Authentication](/authentication).

| Header | Value |
| --- | --- |
| `x-api-key` | YOUR\_MUNSIT\_API\_KEY |

> This is post-call analysis of an existing diarized transcription. For live calls with one speaker per audio channel, streaming with channels=2 gives per-speaker turns with per-turn Sentiment events in real time.

## Request

The diarization record is addressed in the path; the analysis depth goes in the JSON body.

| Path parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `diarizationId` | string (UUID) | **Yes** | Diarization record ID — from a previous [Diarization](/speech-to-text/diarization) run. |

| Body field | Type | Required | Description |
| --- | --- | --- | --- |
| `analysis_depth` | string | No | `light`, `standard`, or `deep`. |

## Example request

Run [Diarization](/speech-to-text/diarization) first, then pass its record ID here.

```bash
curl -X POST "https://api.munsit.com/api/v1/diarization/42/sentiment-analysis" \
  -H "x-api-key: $MUNSIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"analysis_depth": "standard"}'
```

```python
import requests, os

diarization_id = 42
r = requests.post(
    f"https://api.munsit.com/api/v1/diarization/{diarization_id}/sentiment-analysis",
    headers={"x-api-key": os.environ["MUNSIT_API_KEY"]},
    json={"analysis_depth": "standard"},
)
print(r.json())
```

```javascript
const diarizationId = 42;

const res = await fetch(
  `https://api.munsit.com/api/v1/diarization/${diarizationId}/sentiment-analysis`,
  { method: "POST",
    headers: {
      "x-api-key": process.env.MUNSIT_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ analysis_depth: "standard" }) }
);
console.log(await res.json());
```

```go
package main

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

func main() {
	diarizationID := 42
	body, _ := json.Marshal(map[string]string{"analysis_depth": "standard"})

	url := fmt.Sprintf(
		"https://api.munsit.com/api/v1/diarization/%d/sentiment-analysis",
		diarizationID)
	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 out map[string]any
	json.NewDecoder(resp.Body).Decode(&out)
	fmt.Println(out)
}
```

## Response highlights

The analysis covers the whole conversation and each speaker in it.

| Field | What it tells you |
| --- | --- |
| `language` | Language detected in the analyzed conversation. |
| `overall_sentiment` | Sentiment of the conversation as a whole. |
| `speaker_sentiment` | Sentiment broken down per diarized speaker. |
| `sentiment_trends` | How sentiment evolves across the conversation. |
| `confidence_score` | Confidence of the analysis. |

## Go further

The rest of the understanding stack, and where the diarization ID comes from.

- [Diarization →](/speech-to-text/diarization) — Produce the diarization record this endpoint analyzes. — `POST /audio/diarization/transcribe`

- [Sentiment analysis →](/understanding/sentiment-analysis) — Sentiment on plain transcripts, without speakers. — `POST /sentiment-analysis`

- [Keyword extraction →](/understanding/keyword-extraction) — Key topics from the same conversation. — `POST /keyword-extraction`

- [Minutes of meetings →](/speech-to-text/minutes-of-meetings) — Structured transcripts for meeting records. — `POST /minutes-of-meeting/transcribe`
