---
title: "Record a client-side affiliate link click"
method: POST
path: "/api/affiliate-click"
tags: ["redirects"]
---

# Record a client-side affiliate link click

`POST /api/affiliate-click`

## Request

- Base URL: `https://voltplan.app`
- URL: `https://voltplan.app/api/affiliate-click`
- Auth: none declared

Writes one `component_click_events` row (`resolved_country: universal`; `User-Agent` and `Referer` truncated to 255 characters). Development short-circuit: with `NODE_ENV=development` the handler answers `{ ok: true }` before reading the body, so nothing is validated or recorded. Bot user agents, a failed PocketBase admin login, a malformed JSON body and any server error also answer 200 `{ ok: true }` without recording.

## Request body

- AffiliateClickRequest: Click tracked by POST /api/affiliate-click.
  - `component_id` string, required: Clicked PocketBase `components` id; missing or empty → 400.
  - `component_name` string: Stored as given; defaults to empty.
  - `component_type` string: Stored as given; defaults to empty.
  - `link_type` string: `search` records source `amazon_search`, any other value or absence `affiliate`; ignored when `source` is set.
  - `target_url` string: Destination URL; defaults to empty.
  - `source` string: Explicit click source; overrides the `link_type` mapping.

## Response `200`

Accepted (also returned whenever recording is skipped or fails).

- AffiliateClickResponse: Acknowledgement of POST /api/affiliate-click.
  - `ok` true, required

## Other responses

- `400`: `component_id` missing or empty (not checked in development).

---

[API](https://skmtc.dev/voltplan/apis/voltplan-api.md) · [All operations](https://skmtc.dev/voltplan/apis/voltplan-api/llms.txt) · [OpenAPI document](https://skmtc.dev/voltplan/apis/voltplan-api/revisions/575b86a7af92?raw)
