@arizeai/phoenix-client/sessions. See Annotations for the shared annotation model and concepts.
Requires Phoenix Server ≥ 12.0.0. The client will throw an error with the minimum required version if the server is too old.
Relevant Source Files
src/sessions/addSessionAnnotation.tsfor the single-annotation APIsrc/sessions/logSessionAnnotations.tsfor batch loggingsrc/sessions/types.tsfor theSessionAnnotationinterface
Add A Single Session Annotation
Mark a support session as resolved after human review:Batch Log Session Annotations
UselogSessionAnnotations to annotate multiple sessions in a single request. This example scores a batch of support sessions for handoff detection:
Conversation Quality Scoring
After a multi-turn conversation ends, use an LLM to evaluate overall coherence and goal completion:End-User Satisfaction (CSAT)
Log customer satisfaction at the end of a chat session. Normalize the raw rating to a 0–1 scale for consistent scoring:Idempotent Upserts With identifier
Session annotations are unique by (name, sessionId, identifier). The identifier field controls whether a write creates a new annotation or updates an existing one.
Without identifier, a session can only have one annotation per name. Adding an identifier lets you store multiple annotations with the same name on the same session, each keyed by a different identifier. Re-sending the same tuple updates that specific annotation in place.
Parameter Reference
SessionAnnotation
| Field | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | Session / conversation / thread identifier |
name | string | Yes | Annotation name (e.g. "csat") |
annotatorKind | "HUMAN" | "LLM" | "CODE" | No | Defaults to "HUMAN" |
label | string | No* | Categorical label |
score | number | No* | Numeric score |
explanation | string | No* | Free-text explanation |
identifier | string | No | For idempotent upserts |
metadata | Record<string, unknown> | No | Arbitrary metadata |
label, score, or explanation is required.
Source Map
src/sessions/addSessionAnnotation.tssrc/sessions/logSessionAnnotations.tssrc/sessions/types.tssrc/types/annotations.ts

