Affiliate Links
Track outbound affiliate clicks and send visitors safely to the right shop. You store each link once (e.g. per product); the page only sends the link key and always gets your stored URL back, so it can never be abused as an open redirect. Click counts per day, link, group, source and page — no personal data stored.
Endpoints (8)
Create or update up to 500 links in one call, matched on link_key. Use this to sync all products at once, e.g. one link per product with link_key = the product slug and target_url = its affiliate URL. Only https:// URLs. Sending an existing link_key replaces its target_url, label, group and is_active.
| Field | Type | Required | Description |
|---|---|---|---|
links |
array | ✓ Yes | List of {"link_key":"ring-doorbell-amazon","target_url":"https://...","label":"Ring Doorbell (Amazon)","group":"amazon","is_active":true}. link_key: 1-80 characters, lowercase letters, digits, - and _. label (max 150) and group (max 60, e.g. retailer or category) are optional. |
Change one link. Only send what changes. Send an empty string for label or group to clear it. is_active false stops the link (the page should then fall back to your own product page).
| Field | Type | Required | Description |
|---|---|---|---|
link_key |
string | ✓ Yes | |
target_url |
string | No | |
label |
string | No | |
group |
string | No | |
is_active |
boolean | No |
Delete one link and its click counts permanently. To pause it instead, use update-link with is_active false.
| Field | Type | Required | Description |
|---|---|---|---|
link_key |
string | ✓ Yes |
All links with their total clicks and clicks in the last 30 days. Paginated, optionally filtered by group or a search on link_key/label.
| Field | Type | Required | Description |
|---|---|---|---|
group |
string | No | |
search |
string | No | |
page |
integer | No | |
per_page |
integer | No | Default 50, max 200. |
How clicks are counted for this project. Only send what changes. Abuse limits only stop COUNTING — visitors are always sent to the shop.
| Field | Type | Required | Description |
|---|---|---|---|
dedupe_minutes |
integer | No | Repeated clicks by the same visitor on the same link count once within this many minutes (0-1440, 0 = count every click). Default 30. |
per_ip_hourly_count |
integer | No | Max counted clicks per IP address per hour (0 = no limit, max 1000). Default 100. |
allowed_sources |
array | No | Allowed values for source, e.g. ["product-card","comparison-table"]. Other values are counted without a source. [] = any source. |
The counting settings of this project, the number of links and the platform limits.
No input parameters required.
Counted clicks over a date range (UTC days, default the last 30 days, max 366), grouped by link, day, group, source or page. Optionally for one link_key or group.
| Field | Type | Required | Description |
|---|---|---|---|
from |
string | No | YYYY-MM-DD. |
to |
string | No | YYYY-MM-DD, default today. |
group_by |
string | No | "link" (default), "day", "group", "source" or "page". |
link_key |
string | No | |
group |
string | No | |
limit |
integer | No | Max rows, default 100, max 500. |
A visitor clicks an affiliate link. Returns {url, counted}: always the stored URL of that link — send the visitor there. counted is false when the click was a repeat or over the abuse limit; the visitor is still sent on. Page pattern: give the <a> an href to your OWN product page (fallback without JavaScript) and a data-link-key. On click: preventDefault; for a new tab call window.open("", "_blank") synchronously FIRST (otherwise popup blockers block it after the await), then POST to /sapi/project/{id}/execute/affiliate-links/click with {link_key, source, page: location.pathname} and set that tab's location to the returned url. If the call fails, keep the fallback href. Unknown or inactive link: error, use the fallback.
| Field | Type | Required | Description |
|---|---|---|---|
link_key |
string | ✓ Yes | |
source |
string | No | Where on the page the click came from, e.g. "product-card". Lowercase letters, digits, - and _. |
page |
string | No | The page path, e.g. location.pathname. Query strings are removed. |
MCP Tool Names
When using this integration through an AI assistant (Claude, ChatGPT, Cursor, etc.), the endpoints are available as MCP tools:
| Endpoint | MCP Tool Name |
|---|---|
| upsert-links | affiliate-links_upsert_links |
| update-link | affiliate-links_update_link |
| delete-link | affiliate-links_delete_link |
| list-links | affiliate-links_list_links |
| set-config | affiliate-links_set_config |
| get-config | affiliate-links_get_config |
| get-stats | affiliate-links_get_stats |
| click | affiliate-links_click |
Website