API Reference

Build custom integrations with the CreatorScore Attribution API.

Authentication

All API requests require an API key passed in the x-api-key header.

header
x-api-key: cs_live_your_api_key_here

Generate API keys at /brand/attribution/setup. Keys start with cs_live_.

Base URL

url
https://creatorscore.io/api/v1

Endpoints

POST

/track

Record a tracking event (page view, add to cart, purchase).

Headers

HeaderRequiredDescription
x-api-keyYesYour API key
Content-TypeYesapplication/json

Request Body

json
{
  "event_type": "purchase",
  "pv_id": "550e8400-e29b-41d4-a716-446655440000",
  "page_url": "https://yourstore.com/thank-you",
  "product_id": "PROD_456",
  "order_id": "ORDER_123",
  "revenue": 49.99,
  "currency": "USD",
  "promo_code_used": "CREATOR20",
  "is_new_customer": true,
  "event_data": {}
}

Field Reference

FieldTypeRequiredDescription
event_typestringYesOne of: page_view, add_to_cart, checkout_start, purchase
pv_idstring (UUID)YesPage view session ID (from the pixel's _cs_pv cookie)
page_urlstringNoCurrent page URL
product_idstringNoProduct identifier
order_idstringNoOrder/transaction ID (required for purchase events)
revenuenumberNoOrder total (required for purchase events)
currencystringNoISO 4217 currency code (default: USD)
promo_code_usedstringNoDiscount code used at checkout
is_new_customerbooleanNoWhether this is a first-time buyer
event_dataobjectNoAdditional custom data (stored as JSON)

Responses

Success (200)

json
{ "ok": true }

Invalid API key (401)

json
{ "error": "Invalid API key" }

Validation error (400)

json
{ "error": "Invalid event data", "details": ["event_type is required"] }

GET

/track/pixel.js

Serve the JavaScript tracking pixel.

Parameters

ParameterRequiredDescription
keyYesYour API key (query parameter)

Response: JavaScript file (text/javascript)

Usage

html
<script src="https://creatorscore.io/api/v1/track/pixel.js?key=YOUR_API_KEY" async></script>

The pixel automatically exposes window.CreatorScore with these methods:

MethodDescription
CreatorScore.track(eventType, data)Send a custom tracking event
CreatorScore.getPvId()Get the current page view session ID
CreatorScore.getRef()Get the tracking link reference code

GET

/track/click

Fallback click redirect (when Cloudflare Worker is unavailable).

Parameters

ParameterRequiredDescription
codeYesTracking link short code

Response: 302 redirect to destination URL


Webhook Endpoints

POST

/api/webhooks/shopify

Receive Shopify order webhooks.

Headers (sent by Shopify)

HeaderDescription
x-shopify-hmac-sha256HMAC signature for verification
x-shopify-topicEvent type (orders/create or app/uninstalled)
x-shopify-shop-domainStore domain

This endpoint is called automatically by Shopify. You don't need to call it directly.


POST

/api/webhooks/fairing

Receive Fairing post-purchase survey responses.

Headers

HeaderDescription
x-fairing-signatureAPI key for verification

Request Body

json
{
  "order_id": "123",
  "question": "How did you hear about us?",
  "answer": "jessica_styles",
  "shop_domain": "mystore.myshopify.com"
}

Rate Limits

Currently no rate limits enforced. We recommend keeping event ingestion under 100 requests/second per API key.

CORS

The /api/v1/track endpoint supports CORS from all origins, allowing browser-side tracking.


Error Codes

StatusMeaning
200Success
400Invalid request body or missing required fields
401Invalid or missing API key
404Resource not found (invalid short code, etc.)
500Internal server error

Code Examples

cURL

bash
curl -X POST https://creatorscore.io/api/v1/track \
  -H "Content-Type: application/json" \
  -H "x-api-key: cs_live_your_key" \
  -d '{
    "event_type": "purchase",
    "pv_id": "550e8400-e29b-41d4-a716-446655440000",
    "order_id": "ORDER_123",
    "revenue": 49.99
  }'

JavaScript (fetch)

javascript
await fetch('https://creatorscore.io/api/v1/track', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'cs_live_your_key'
  },
  body: JSON.stringify({
    event_type: 'purchase',
    pv_id: document.cookie.match(/_cs_pv=([^;]+)/)?.[1],
    order_id: 'ORDER_123',
    revenue: 49.99
  })
})

Python

python
import requests

requests.post(
    'https://creatorscore.io/api/v1/track',
    headers={'x-api-key': 'cs_live_your_key'},
    json={
        'event_type': 'purchase',
        'pv_id': '550e8400-e29b-41d4-a716-446655440000',
        'order_id': 'ORDER_123',
        'revenue': 49.99
    }
)