## Applies to:

- Plan - Any
- Deployment - Braintrust-hosted
- Use case - Programmatically adding scores to existing traces via API

## Summary

**Issue:** Scores submitted via the Braintrust feedback API do not appear in the UI for existing traces, and instead create new trace entries with the provided `span_id` and `root_span_id`.  
**Cause:** The `span_id` used in the API payload does not match the actual `id` property in the raw trace data.  
**Resolution:** Use the correct `id` from the raw span data when submitting scores via the feedback API.

## Resolution Steps

### Step 1: Get the correct span ID

Navigate to the trace in the Braintrust UI and click the “Raw span and trace data” button to view the underlying JSON.

### Step 2: Identify the ID field

Locate the `id` property in the raw trace data JSON - this is the value you need to use in your API calls.

### Step 3: Update your API payload

Use the `id` from the raw data as the `span_id` in your feedback API payload:

```
payload = {
    "events": [\
        {\
            "span_id": "correct-id-from-raw-data",\
            "root_span_id": "correct-id-from-raw-data",\
            "scores": 0.0,\
            "metadata": feedback_update["metadata"],\
            "_is_merge": True,\
            "_merge_paths": merge_paths,\
        }\
    ]
}
```

### Step 4: Verify the score appears

Refresh the trace view in the UI to confirm the score is now attached to the existing trace instead of creating a new one.
