---
title: "Record a click"
method: POST
path: "/v1/clicks"
tags: ["Clicks"]
---

# Record a click

`POST /v1/clicks`

## Request

- Base URL: `https://api.affiliaterail.com`
- URL: `https://api.affiliaterail.com/v1/clicks`
- Auth: HTTP bearer

Server-side tracking: the same resolution `rail.js` uses (handle first, then custom link values). An unknown value is a 404, not a silent drop. The same `visitor_token` across clicks joins one referral.

**Scope:** `commissions:write` (or `write`)

## Request body

- ClickCreate
  - `program_id` string, required: Prefixed id (`prg_…`)
  - `value` string, required: The partner handle or link value the visitor arrived with
  - `param` string
  - `landing_url` string, uri, required
  - `visitor_token` string, required: Your stable identifier for this visitor; the same token across clicks makes one referral
  - `referrer` string
  - `ip` string: Hashed on write, never stored
  - `user_agent` string
  - `country` string
  - `device` string

## Response `201`

The click, attached to its referral

- Click
  - `id` string, required: Prefixed id (`clk_…`)
  - `object` 'click', required
  - `program_id` string, required: Prefixed id (`prg_…`)
  - `partner_id` string, required: Prefixed id (`part_…`)
  - `link_id` string, nullable, required: Prefixed id (`lnk_…`)
  - `referral_id` string, nullable, required: Prefixed id (`ref_…`)
  - `user_agent` string, nullable, required
  - `referer` string, nullable, required
  - `country` string, nullable, required
  - `device` string, nullable, required
  - `landing_url` string, nullable, required
  - `created_at` string, date-time, required: ISO-8601, UTC

## Other responses

- `400`: Invalid request
- `401`: Missing or unknown API key
- `403`: Key lacks the required scope
- `404`: No such object in your organization
- `422`: The request was understood and refused
- `429`: Rate limited: see Retry-After

---

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