---
name: relevan-feedback
description: Send click, conversion, and llm_judgment feedback to Relevan after a search, so the ranking gets better. Use when you build search into an app, or when an agent acts on a search result.
---

# Relevan feedback

An agent that searches but never reports what happened teaches Relevan nothing. Feedback is what trains Relevan's ranking model and makes future results better. Your user pays for that improvement, so send feedback after every result you act on.

## The endpoint

`POST https://feat-650-agent-skills.api.dev.relevan.dev/v1-beta/{orgId}/indexes/{indexName}/feedback`

Send one of three feedback types:

- `click`: an end user picked this result.
- `llm_judgment`: an agent judged this result relevant, without a person to confirm it.
- `conversion`: a closing event, such as a purchase or a hire, confirmed this result.

## Add feedback to an app

When you build search into an app, add the feedback calls in the same change as the search call:

1. Keep `searchContext.queryId` from each search response. Pass it to the UI together with the results.
2. When an end user clicks a result, send a `click` event with the `queryId`, the result `id` as `objectId`, and the rank `position`.
3. When a closing event occurs, such as a purchase or a hire, send a `conversion` event with a short `label`.
4. Send feedback from a server route. Do not put the API key in browser code.

```ts
// Server route. The browser calls this route when the user clicks a result.
await fetch("https://feat-650-agent-skills.api.dev.relevan.dev/v1-beta/{orgId}/indexes/{indexName}/feedback", {
  method: "POST",
  headers: { "content-type": "application/json", "x-api-key": process.env.RELEVAN_API_KEY },
  body: JSON.stringify({ actionName: "click", queryId, objectId, position }),
});
```

## Feedback from an agent

If an agent uses the search results instead of a person, send `llm_judgment` for each result that the agent uses. The `FeedbackRequest` schema in the OpenAPI spec gives all the fields: https://feat-650-agent-skills.api.dev.relevan.dev/openapi

## Other Relevan documents

- [Relevan overview](https://feat-650-agent-skills.dev.relevan.dev/llms.txt): What Relevan is, who it suits, and what it costs.
- [Documentation index](https://feat-650-agent-skills.docs.dev.relevan.dev/llms.txt): Each page of the Relevan documentation and blog.
- [API index](https://feat-650-agent-skills.api.dev.relevan.dev/llms.txt): The API capabilities, the rate limits, and the search quota.
- [OpenAPI spec](https://feat-650-agent-skills.api.dev.relevan.dev/openapi): Each endpoint, with its request and response schemas.
- [relevan-setup](https://feat-650-agent-skills.api.dev.relevan.dev/skills/relevan-setup/SKILL.md): Set up Relevan search from the start: authenticate, create an index, load documents, run the first search, and send the first feedback. Use when a user asks you to add Relevan search to a product.
- [relevan-ranking-signals](https://feat-650-agent-skills.api.dev.relevan.dev/skills/relevan-ranking-signals/SKILL.md): Find the data that tells Relevan which result is the best one, such as prices, sales, or activity, and add it to each document. Use before you design a Relevan mapping.
- [relevan-mapping](https://feat-650-agent-skills.api.dev.relevan.dev/skills/relevan-mapping/SKILL.md): Draft and deploy a RelevanMapping from a sample of documents. Use when a Relevan index has no mapping, or when the documents get new fields.
