# Feedback

> Report a result or an answer that was wrong, missing or out of date, with reasons from a fixed list, and rate answers with votes.

- Human-readable page: https://dashboard.sproutsdata.ai/docs/guides/feedback
- This document: https://dashboard.sproutsdata.ai/docs/agents/guides/feedback
- Index of every agent document: https://dashboard.sproutsdata.ai/llms.txt
- API base URL: https://api.sproutsdata.ai

## Summary

Report wrong, missing or stale results (`POST /v1/feedback`) or rate an answer (`PUT /v1/feedback/votes`). Reasons come from one closed vocabulary (`GET /v1/feedback/tags`). Free. Reports and flags join the Sprouts Data team's review queue; a report's `status` starts `open` and changes as it is reviewed. Reports are kept one year. Use only when the user says a result was wrong, missing or stale.

## Rules

- Scopes: every feedback route needs `dsp.search.read` or `dsp.usage.read`.
- Reason vocabulary (version 2), `tag` → level: `irrelevant`, `wrong_entity`, `stale`, `data_quality`, `duplicate` → `result`; `bad_ranking`, `missing`, `no_results`, `too_few`, `too_many` → `result_set`; `other` → either, and REQUIRES a non-empty `comment`. Unknown tags or tags of the other level: 422.
- `POST /v1/feedback` body: `target` (required: `kind` `result` | `result_set`; `entity_id` max 255, the row's `id`, for `result`; `entity_type` max 32), `subject_ref` (optional: `kind` `request` with the call's `request_id` from `meta.request_id` / `X-Request-Id`, or `kind` `agent_run` with a run id; `id` 1 to 128 chars), `sentiment` (`bad` default | `good`), `tags` (max 10), `comment` (max 5,000), `expected` (`should_include` max 200 strings, `should_exclude` max 200 strings, `note` max 5,000). Unknown fields: 422.
- `subject_ref` must name a run visible in the caller's usage history (an API key: its own calls; a person: their own and their keys'; an admin: the workspace's); otherwise 404 `feedback.subject_not_found`. `target_verified` = true for `result_set` with a subject, or when `entity_id` was among the run's recorded records; false without a subject.
- Answer 201: `feedback_id`, `created_at`, `subject_ref`, `target`, `sentiment`, `tags`, `comment`, `expected`, `target_verified`, `status` (`open` at creation), `tag_vocab_version`.
- `Idempotency-Key` optional (max 255): a repeat with the same key answers 200 with the existing report.
- `GET /v1/feedback?limit=&cursor=`: your reports newest first (an admin: the workspace's; a key: its own); `limit` 1 to 100, default 25; `cursor` max 64.
- `PUT /v1/feedback/votes` body: `request_id` (required, 1 to 64), `level` (`result_set` | `result`), `entity_category` (required, 1 to 32), `entity_id` (max 255), `vote` (`like` | `dislike` | `flag`), `reason_code` (max 32, a tag of the vote's level), `text` (max 1,000).
- Vote rules: `result` takes only `flag` and requires `entity_id`; `result_set` takes `like` or `dislike`; `like` takes no `reason_code`; `text` requires `reason_code`. Violations: 422.
- One active vote per voter per (request_id, level, entity_id). A different vote supersedes the old one; the identical vote changes nothing. Answer: `{vote, changed}`.
- `GET /v1/feedback/votes?request_id=` (required): the caller's current votes on that request.

## Examples

```json
{
  "subject_ref": { "kind": "request", "id": "req_7f3a9c2e1b4d" },
  "target": { "kind": "result_set" },
  "sentiment": "bad",
  "tags": ["too_many"],
  "comment": "Several results are headquartered outside Germany.",
  "expected": { "should_exclude": ["stripe.com"] }
}
```

```json
{
  "request_id": "req_7f3a9c2e1b4d",
  "level": "result_set",
  "entity_category": "company",
  "vote": "dislike",
  "reason_code": "too_many"
}
```

## Operations

### POST /v1/feedback

Report

- URL: `POST https://api.sproutsdata.ai/v1/feedback`
- Scopes (any one): `dsp.search.read`, `dsp.usage.read`
- Cost: free
- Idempotency-Key header: optional

Tell us a search went wrong (or right). Send `Idempotency-Key` to make a retry safe.

Headers:

- `Idempotency-Key` (string): Send one to make a retry safe: a retry with the same key on the same UTC day is charged once.

Request body (JSON, required):

- `target` (object, required)
  - `kind` (string, required): One of: `"result"`, `"result_set"`.
  - `entity_id` (string or null): Limits: at most 255 characters.
  - `entity_type` (string or null): Limits: at most 32 characters.
- `comment` (string or null): Limits: at most 5000 characters.
- `expected` (object or null)
  - `note` (string or null): Limits: at most 5000 characters.
  - `should_exclude` (array of string): Limits: at most 200 items.
  - `should_include` (array of string): Limits: at most 200 items.
- `sentiment` (string): One of: `"bad"`, `"good"`. Default `"bad"`.
- `subject_ref` (object or null)
  - `id` (string, required): Limits: 1 to 128 characters.
  - `kind` (string, required): One of: `"request"`, `"agent_run"`.
- `tags` (array of string): Limits: at most 10 items.

Response 201 (application/json): Successful Response
Response fields:

- `comment` (string or null, required)
- `created_at` (string (date-time), required)
- `expected` (object or null, required)
- `feedback_id` (string, required)
- `sentiment` (string, required)
- `status` (string, required)
- `subject_ref` (object or null, required)
  - `id` (string, required): Limits: 1 to 128 characters.
  - `kind` (string, required): One of: `"request"`, `"agent_run"`.
- `tag_vocab_version` (integer, required)
- `tags` (array of string, required)
- `target` (object, required)
  - `kind` (string, required): One of: `"result"`, `"result_set"`.
  - `entity_id` (string or null): Limits: at most 255 characters.
  - `entity_type` (string or null): Limits: at most 32 characters.
- `target_verified` (boolean, required)

Errors:

- 401: No credential, or one that does not verify (`auth.unauthorized`).
- 403: The credential lacks the scope this route needs (`auth.insufficient_scope`), or the signed-in user has not chosen a workspace (`auth.workspace_required`).
- 404: No such resource for this workspace (`*.not_found`), or no such route (`route.not_found`).
- 422: The request is invalid (`request.invalid`), or its cursor is (`pagination.*`).
- 429: Too many requests for this key or workspace (`quota.burst_exceeded`). See `Retry-After`.
- 503: A service this request needs is unavailable, or the API is at capacity. See `Retry-After`.

Example request:

```bash
curl -X POST "https://api.sproutsdata.ai/v1/feedback" \
  -H "X-API-Key: $SPROUTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "target": {
         "kind": "result_set"
       },
       "sentiment": "bad",
       "comment": "Several results are headquartered outside Germany."
     }'
```

### GET /v1/feedback/tags

Tags

- URL: `GET https://api.sproutsdata.ai/v1/feedback/tags`
- Scopes (any one): `dsp.search.read`, `dsp.usage.read`
- Cost: free

The reasons a report or vote may give.

Response 200 (application/json): Successful Response
Response fields:

- `tags` (array of object, required)
  - `description` (string, required)
  - `label` (string, required)
  - `level` (string, required)
  - `requires_comment` (boolean, required)
  - `tag` (string, required)
- `version` (integer, required)

Errors:

- 401: No credential, or one that does not verify (`auth.unauthorized`).
- 403: The credential lacks the scope this route needs (`auth.insufficient_scope`), or the signed-in user has not chosen a workspace (`auth.workspace_required`).
- 429: Too many requests for this key or workspace (`quota.burst_exceeded`). See `Retry-After`.

Example request:

```bash
curl "https://api.sproutsdata.ai/v1/feedback/tags" \
  -H "X-API-Key: $SPROUTS_API_KEY"
```

### PUT /v1/feedback/votes

Vote

- URL: `PUT https://api.sproutsdata.ai/v1/feedback/votes`
- Scopes (any one): `dsp.search.read`, `dsp.usage.read`
- Cost: free

Thumbs up or down on a result set, or flag one record. Sending the same vote again
changes nothing.

Request body (JSON, required):

- `entity_category` (string, required): Limits: 1 to 32 characters.
- `level` (string, required): One of: `"result_set"`, `"result"`.
- `request_id` (string, required): Limits: 1 to 64 characters.
- `vote` (string, required): One of: `"like"`, `"dislike"`, `"flag"`.
- `entity_id` (string or null): Limits: at most 255 characters.
- `reason_code` (string or null): Limits: at most 32 characters.
- `text` (string or null): Limits: at most 1000 characters.

Response 200 (application/json): Successful Response
Response fields:

- `changed` (boolean, required)
- `vote` (object, required)
  - `entity_category` (string, required)
  - `entity_id` (string or null, required)
  - `level` (string, required)
  - `reason_code` (string or null, required)
  - `request_id` (string, required)
  - `text` (string or null, required)
  - `vote` (string, required)
  - `vote_id` (string, required)

Errors:

- 401: No credential, or one that does not verify (`auth.unauthorized`).
- 403: The credential lacks the scope this route needs (`auth.insufficient_scope`), or the signed-in user has not chosen a workspace (`auth.workspace_required`).
- 404: No such resource for this workspace (`*.not_found`), or no such route (`route.not_found`).
- 422: The request is invalid (`request.invalid`), or its cursor is (`pagination.*`).
- 429: Too many requests for this key or workspace (`quota.burst_exceeded`). See `Retry-After`.
- 503: A service this request needs is unavailable, or the API is at capacity. See `Retry-After`.

Example request:

```bash
curl -X PUT "https://api.sproutsdata.ai/v1/feedback/votes" \
  -H "X-API-Key: $SPROUTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "request_id": "req_7f3a9c2e1b4d",
       "level": "result_set",
       "entity_category": "company",
       "vote": "like"
     }'
```

### GET /v1/feedback

Reports

- URL: `GET https://api.sproutsdata.ai/v1/feedback`
- Scopes (any one): `dsp.search.read`, `dsp.usage.read`
- Cost: free

Your reports (an admin: the workspace's), newest first.

Query parameters:

- `cursor` (string or null): Limits: at most 64 characters.
- `limit` (integer): Default `25`. Limits: 1 to 100.

Response 200 (application/json): Successful Response
Response fields:

- `next_cursor` (string or null, required)
- `results` (array of object, required)
  - `comment` (string or null, required)
  - `created_at` (string (date-time), required)
  - `expected` (object or null, required)
  - `feedback_id` (string, required)
  - `sentiment` (string, required)
  - `status` (string, required)
  - `subject_ref` (object or null, required)
    - `id` (string, required): Limits: 1 to 128 characters.
    - `kind` (string, required): One of: `"request"`, `"agent_run"`.
  - `tag_vocab_version` (integer, required)
  - `tags` (array of string, required)
  - `target` (object, required)
    - `kind` (string, required): One of: `"result"`, `"result_set"`.
    - `entity_id` (string or null): Limits: at most 255 characters.
    - `entity_type` (string or null): Limits: at most 32 characters.
  - `target_verified` (boolean, required)

Errors:

- 401: No credential, or one that does not verify (`auth.unauthorized`).
- 403: The credential lacks the scope this route needs (`auth.insufficient_scope`), or the signed-in user has not chosen a workspace (`auth.workspace_required`).
- 404: No such resource for this workspace (`*.not_found`), or no such route (`route.not_found`).
- 422: The request is invalid (`request.invalid`), or its cursor is (`pagination.*`).
- 429: Too many requests for this key or workspace (`quota.burst_exceeded`). See `Retry-After`.
- 503: A service this request needs is unavailable, or the API is at capacity. See `Retry-After`.

Example request:

```bash
curl "https://api.sproutsdata.ai/v1/feedback?limit=20" \
  -H "X-API-Key: $SPROUTS_API_KEY"
```

### GET /v1/feedback/votes

Votes

- URL: `GET https://api.sproutsdata.ai/v1/feedback/votes`
- Scopes (any one): `dsp.search.read`, `dsp.usage.read`
- Cost: free

Query parameters:

- `request_id` (string, required): Limits: 1 to 64 characters.

Response 200 (application/json): Successful Response
Response fields:

- `request_id` (string, required)
- `votes` (array of object, required)
  - `entity_category` (string, required)
  - `entity_id` (string or null, required)
  - `level` (string, required)
  - `reason_code` (string or null, required)
  - `request_id` (string, required)
  - `text` (string or null, required)
  - `vote` (string, required)
  - `vote_id` (string, required)

Errors:

- 401: No credential, or one that does not verify (`auth.unauthorized`).
- 403: The credential lacks the scope this route needs (`auth.insufficient_scope`), or the signed-in user has not chosen a workspace (`auth.workspace_required`).
- 404: No such resource for this workspace (`*.not_found`), or no such route (`route.not_found`).
- 422: The request is invalid (`request.invalid`), or its cursor is (`pagination.*`).
- 429: Too many requests for this key or workspace (`quota.burst_exceeded`). See `Retry-After`.
- 503: A service this request needs is unavailable, or the API is at capacity. See `Retry-After`.

Example request:

```bash
curl "https://api.sproutsdata.ai/v1/feedback/votes?request_id=req_7f3a9c2e1b4d" \
  -H "X-API-Key: $SPROUTS_API_KEY"
```

## Errors to handle

- 404 `feedback.subject_not_found`: `subject_ref` is not a run this caller may read.
- 422 `request.invalid`: tag of the wrong level, `other` without a comment, an incoherent vote, or other validation.
- 429 `quota.burst_exceeded`: rate limit; wait `Retry-After`.

## See also

- https://dashboard.sproutsdata.ai/docs/agents/api-reference/feedback
- https://dashboard.sproutsdata.ai/docs/agents/guides/usage-history
