# HTTP capture API

> POST feedback reports from any language: the v1 envelope, receipts, follow-up answers, errors and idempotent retries.

Source: https://mostlovedproduct.com/docs/api

The widget, MCP tool and direct API clients share the same capture envelope. Use the API directly from a browser, CLI or backend when you do not use an SDK.

Base URL: `https://in.mostlovedproduct.com`. JSON only. Request bodies up to 32 KB.

## Endpoints

| Method | Path | Purpose |
|--------|------|---------|
| `POST` | `/api/v1/user-feedback` | Capture widget feedback with a publishable key |
| `POST` | `/api/v1/user-feedback/answers` | Answer or skip a widget follow-up with a publishable key |
| `POST` | `/api/v1/mcp-feedback` | Capture MCP feedback with a secret key. No follow-ups |
| `GET`, `HEAD` | `/v1/health` | Public liveness probe |
| `OPTIONS` | Any listed path | CORS preflight for `Authorization` and `Content-Type` |

## Authentication

Send a write-only capture key in `Authorization: Bearer <key>`. The widget routes require a publishable key and an `Origin` header matching an origin allowed by that key. Publishable keys record feedback as `anonymous`. Secret keys may set `source.trust` and `source.client`.

## Capture widget feedback

```bash
curl -X POST https://in.mostlovedproduct.com/api/v1/user-feedback \
  -H "Authorization: Bearer $MLP_PUBLISHABLE_KEY" \
  -H "Origin: https://app.example.com" \
  -H "Content-Type: application/json" \
  -d '{
    "v": 1,
    "id": "01a1d56f-ee88-7c3a-9b1e-4f2d8a6c5e10",
    "type": "report",
    "sent_at": "2026-11-13T15:04:05Z",
    "report": {
      "source": { "kind": "human", "surface": "web" },
      "kind": "broken",
      "impact": "blocked",
      "summary": "Export times out for ranges over 90 days"
    }
  }'
```

## Capture MCP feedback

```bash
curl -X POST https://in.mostlovedproduct.com/api/v1/mcp-feedback \
  -H "Authorization: Bearer $MLP_SERVER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "v": 1,
    "id": "01a1d571-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
    "type": "report",
    "sent_at": "2026-11-13T15:04:36Z",
    "report": {
      "source": { "kind": "agent", "surface": "mcp" },
      "kind": "broken",
      "impact": "blocked",
      "summary": "export_report times out for ranges over 90 days",
      "subject": { "type": "tool", "name": "export_report" }
    }
  }'
```

### Envelope

| Field | Type | Notes |
|-------|------|-------|
| `v` | `1` | Protocol version |
| `id` | string | UUIDv7 generated by the client **before the first attempt**. For reports, this is the report ID |
| `type` | `"report"` or `"answer"` | |
| `sent_at` | string | ISO 8601, client clock (informational) |
| `sdk` | `{ name, version }` | Optional |
| `report` | Report | When `type` is `report` |
| `answer` | Answer | When `type` is `answer` |
| `options.follow_ups` | `{ count, dynamic }` | Optional. Set `count` to `0`, `1` or `2` and `dynamic` to a boolean. When omitted, intake can offer one catalog question. The MCP endpoint ignores this field |

### Report

| Field | Type | Notes |
|-------|------|-------|
| `source.kind` | `human` or `agent` | Required |
| `source.surface` | `web`, `mcp`, `cli`, `api` | Required |
| `source.client` | `{ name, version? }` | Browser family, or agent host/model as reported |
| `source.trust` | `authenticated`, `known_host`, `anonymous` | Server keys only |
| `source.requested_by_user` | boolean | The agent filed because the user asked |
| `kind` | `broken`, `confusing`, `missing`, `idea`, `praise` | Optional for people (classified later) |
| `impact` | `blocked`, `worked_around`, `friction` | |
| `summary` | string, 1–300 | Required. One sentence |
| `details` | string, ≤ 4000 | |
| `task` | string, ≤ 500 | What they were trying to do |
| `expected`, `actual` | string, ≤ 1000 | |
| `suggestion` | string, ≤ 1000 | |
| `subject` | `{ type, name }` | `type`: `tool`, `page`, `feature`, `docs`, `other` |
| `sentiment` | `positive`, `neutral`, `negative` | |
| `user` | `{ id?, tier?, traits? }` | Your own opaque ID |
| `flags` | object of string or boolean | Experiments and feature flags, ≤ 50 keys |
| `app` | `{ version?, env?, release? }` | |
| `page` | `{ url?, path?, title?, referrer?, locale?, viewport? }` | |
| `context` | object | ≤ 32 keys, strings ≤ 500 chars, arrays ≤ 20 items |
| `contact` | `{ email?, notify_on_fix? }` | Reserved for fix notifications, which are not available yet. Omit it |

Intake ignores unknown fields in the envelope and its nested objects. It validates and retains custom keys in `context`, `user.traits`, and `flags`.

## Receipt

`202 Accepted` means the report is durably stored. A widget receipt may include a follow-up. MCP receipts omit `follow_up`.

```json
{
  "report_id": "01a1d56f-ee88-7c3a-9b1e-4f2d8a6c5e10",
  "status": "captured",
  "duplicate": false,
  "message": "Captured. Thanks.",
  "follow_up": {
    "id": "expected",
    "question": "What did you expect to happen?",
    "input": "text",
    "reply_token": "<reply token>",
    "expires_at": "2026-11-13T15:34:05Z"
  }
}
```

## Follow-up answers

```bash
curl -X POST https://in.mostlovedproduct.com/api/v1/user-feedback/answers \
  -H "Authorization: Bearer $MLP_PUBLISHABLE_KEY" \
  -H "Origin: https://app.example.com" \
  -H "Content-Type: application/json" \
  -d '{
    "v": 1,
    "id": "01a1d570-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
    "type": "answer",
    "sent_at": "2026-11-13T15:04:31Z",
    "answer": {
      "report_id": "01a1d56f-ee88-7c3a-9b1e-4f2d8a6c5e10",
      "follow_up_id": "expected",
      "reply_token": "<reply token>",
      "text": "The CSV should download within a few seconds."
    }
  }'
```

Put the original report ID in `answer.report_id` and give the answer its own UUIDv7 in `id`. Copy `follow_up.id` and `follow_up.reply_token` from the receipt into `answer.follow_up_id` and `answer.reply_token`. Send `"skipped": true` instead of `text` to skip, or `option_id` for choice questions. The reply token expires after 30 minutes. A report never gets more than two questions.

## Errors

```json
{ "error": { "code": "rate_limited", "message": "Too many reports right now. Try again later.", "retryable": true, "retry_after": 30 } }
```

| Status | Code | Retry? |
|--------|------|--------|
| 400 | `invalid_payload` | No. `field` names the problem |
| 401 | `unauthorized` | No. Invalid, expired or revoked key, or wrong key type for the route |
| 403 | `forbidden_origin` | No |
| 409 | `conflict` | No. Same ID, different payload |
| 410 | `follow_up_expired` | No |
| 413 | `payload_too_large` | No |
| 429 | `rate_limited` | After the delay in `Retry-After` |
| 5xx | `unavailable` | When `retryable` is true |

## Idempotency

The client generates the UUIDv7 once and reuses it on every attempt. Sending the same ID with the same payload returns `202` with `"duplicate": true`. Sending the same ID with a different payload returns `409 conflict`. Reuse the exact body, including the ID and timestamp, when retrying a request.

The SDKs can fail over once to a configured fallback endpoint on a network error, timeout, or 5xx response.
