# API overview

The public API is for user-owned clients such as the SellTraces CLI, browser flows, Rebate frontends, and integrations that act on behalf of a signed-in user.

The generated endpoint reference is built with `zod-openapi` from `scripts/generate-openapi.ts`, shared Zod request schemas, and the Next.js route tree under `apps/web/src/app/api/**`.

## Base URLs

| Environment | Base URL |
| --- | --- |
| Production | `https://app.rebates.ai` |
| Local development | `http://localhost:3000` |

The generated OpenAPI file includes both servers.

## Main surfaces

| Surface | Endpoints |
| --- | --- |
| SellTraces CLI | `POST /api/cli/device/start`, `GET /api/cli/device/poll`, `GET /api/cli/session`, `POST /api/cli/telemetry`, `POST /api/cli/feedback` |
| SellTraces ingest | `POST /api/ingest`, `GET /api/ingest/jobs/{jobId}` |
| SellTraces traces | `GET /api/traces/{id}`, `PATCH /api/traces/{id}`, `POST /api/traces/bulk`, `GET /api/traces/{id}/download`, `POST /api/traces/known` |
| Rebates ads | `GET /api/ad`, `POST /api/ad/contextual` |
| Rebates devices | `POST /api/rebate/claim` |

Internal and delegated routes such as health checks, Better Auth, and Gravity tracking proxy URLs are excluded from the public API reference.

## Generated reference

Open the API Reference tab for generated operation pages. Endpoint pages use stable `/api-reference/...` URLs generated from the OpenAPI manifest.

| Surface | Generated endpoint pages |
| --- | --- |
| SellTraces CLI | [Start device login](/api-reference/selltraces-cli/post-api-cli-device-start), [poll device login](/api-reference/selltraces-cli/get-api-cli-device-poll), [get CLI session](/api-reference/selltraces-cli/get-api-cli-session), [submit CLI feedback](/api-reference/selltraces-cli/post-api-cli-feedback), [submit parser diagnostics](/api-reference/selltraces-cli/post-api-cli-telemetry) |
| SellTraces ingest | [Queue trace ingestion](/api-reference/selltraces-ingest/post-api-ingest), [get ingest job status](/api-reference/selltraces-ingest/get-api-ingest-jobs-jobid) |
| SellTraces traces | [Get trace sale state](/api-reference/selltraces-traces/get-api-traces-id), [update trace sale eligibility](/api-reference/selltraces-traces/patch-api-traces-id), [bulk update trace sale eligibility](/api-reference/selltraces-traces/post-api-traces-bulk), [check known trace hashes](/api-reference/selltraces-traces/post-api-traces-known), [download scrubbed trace JSON](/api-reference/selltraces-traces/get-api-traces-id-download) |
| Rebates ads | [Serve a terminal ad](/api-reference/rebates-ads/get-api-ad), [serve a contextual terminal ad](/api-reference/rebates-ads/post-api-ad-contextual) |
| Rebates devices | [Claim a device](/api-reference/rebates-devices/post-api-rebate-claim) |

The raw OpenAPI document is available at:

```text
https://app.rebates.ai/docs/openapi.json
```

## Response style

Most application-owned JSON routes return an `ok` envelope:

```json
{
  "ok": true
}
```

Errors generally return:

```json
{
  "ok": false,
  "error": "unauthorized"
}
```

Some Rebates ad-delivery routes return bare `error` objects because their wire contract predates the shared envelope and is optimized for CLI rendering fallback.
