> ## Documentation Index
> Fetch the complete documentation index at: https://docs.impact.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Feedback

> Attach feedback to an Interaction, span, Product Trace, or Session in JavaScript and Python.

After [setting up capture](https://docs.impact.ai/quickstart.md), attach feedback to the application work you want to evaluate.

## Record feedback

Give each feedback occurrence a `name` and at least one of `score`, `label`, or `explanation`. Omit
`target` to use the active Interaction.
[Start an Interaction in JavaScript](https://docs.impact.ai/sdk/javascript/api.md#group-work-into-an-interaction) ·
[Start an Interaction in Python](https://docs.impact.ai/sdk/python/api.md#record-a-logical-request)

Outside an Interaction, supply an explicit target. Use `kind: 'interaction'` or `kind: 'session'` with
the application `id`, or `kind: 'trace'` with the Product Trace UUID as `id`. A `kind: 'span'` target
takes native OpenTelemetry IDs in `traceId` and `spanId` in JavaScript, or `trace_id` and `span_id` in
Python. An explicit target takes precedence over the active Interaction and uses its own carrier.
Ended spans keep their original contents.

These examples record feedback after an Interaction using its known ID.

```javascript JavaScript theme={null}
import { feedback } from 'impact-ai';

const receipt = feedback({
  name: 'answer_helpful',
  label: 'yes',
  target: { kind: 'interaction', id: 'request-42' },
});
```

```python Python theme={null}
import impact

receipt = impact.feedback(
    "answer_helpful",
    label="yes",
    target={"kind": "interaction", "id": "request-42"},
)
```

Both SDKs validate the complete occurrence before local recording. Compact feedback JSON, including
the target, can use up to 1 MiB of UTF-8 bytes and 4,096 JSON values. Nesting must stay below 64 levels.
Labels and explanations count toward the same whole-occurrence budget. Invalid or oversized feedback
raises an error before enqueueing. Python applies local sampling and delivery routing after validation.

## Retry the same occurrence

The SDK generates an `id` if you omit it. Save the returned `id`, `producer`, and timestamp.
On a retry, pass all three back with the same feedback fields and target. A new `id` records a new
occurrence.

| SDK | Receipt fields |
| - | - |
| JavaScript `FeedbackResult` | `id`, `producer`, `occurredAt`, `outcome` |
| Python `FeedbackReceipt` | `id`, `producer`, `occurred_at`, `outcome` |

## Verify the outcome

`recorded-locally` confirms local capture. Use authenticated Product readback to find the matching
record and confirm delivery. `not-recorded` means local capture did not occur, for example when
observation is unavailable or stopped. The SDK still validates the occurrence and explicit target.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.