CutMeShort CMS API
Project description
CutMeShort CMS Python SDK
The CutMeShort Python SDK enables you to track lead and sales events in your Python applications with ease.
It provides a clean and simple interface for:
- Lead tracking
- Deferred lead attribution (
mode="deferred") - Sale / purchase tracking
Installation
Install from PyPI (recommended)
pip install cms-python-client
Install from GitHub
pip install git+https://github.com/CutMeShort/cms-python-client.git
📋 Requirements
- Python 3.9+
Setup
Set your Bearer token:
export CMS_BEARER_TOKEN="your_jwt_token"
⚡ Quick Start
import os
from cms_python import CMSClient
client = CMSClient(token=os.environ["CMS_BEARER_TOKEN"])
response = client.track_lead(
click_id="id_123",
event_name="signup_started",
customer_external_id="user_42",
)
print(response)
What is Deferred Attribution?
Deferred attribution allows you to track a click before knowing the customer identity.
Flow:
-
First Call (store association)
- Send
click_id+mode="deferred"
- Send
-
Later Calls
- Send normal events without
click_id - Backend automatically resolves mapping
- Send normal events without
Example Use Case
User clicks an ad → later signs up → events get linked automatically.
Track a Lead Event (Standard Flow)
from cms_python import CMSClient
client = CMSClient(token="your_jwt_token")
response = client.track_lead(
click_id="id_123",
event_name="signup_started",
customer_external_id="user_42",
customer_name="Jane Doe", # optional
customer_email="jane@example.com", # optional
)
print(response)
Track a Lead Event (Deferred Flow)
Step 1: Store association
response = client.track_lead(
click_id="id_123",
event_name="lead_captured",
customer_external_id="user_42",
mode="deferred",
)
Step 2: Send follow-up event
response = client.track_lead(
event_name="kyc_completed",
customer_external_id="user_42",
)
Track a Sale Event
from cms_python import CMSClient
client = CMSClient(token="your_jwt_token")
response = client.track_sale(
click_id="id_123",
event_name="purchase_completed",
customer_external_id="user_42",
invoice_id="inv_987",
amount=4999, # in cents
currency="USD", # 3-letter code
customer_email="jane@example.com", # optional
)
print(response)
CMSClient Reference
Initialization
from cms_python import CMSClient
client = CMSClient(token="your_jwt_token")
# Custom base URL
client = CMSClient(token="your_jwt_token", host="https://custom.com")
Methods
track_lead()
Track a lead event.
Required:
event_name: strcustomer_external_id: str
Optional:
click_id: strcustomer_name: strcustomer_email: strcustomer_avatar: strtimestamp: datetimemode: str("deferred"only)
track_sale()
Track a sale event.
Required:
click_id: strevent_name: strcustomer_external_id: strinvoice_id: stramount: int(in cents)currency: str(3-letter code)
Optional:
customer_name: strcustomer_email: strcustomer_avatar: strtimestamp: datetime
Response Format
All methods return a dictionary:
Success Response
{
"success": true,
"message": "Event tracked successfully",
"data": {...}
}
Error Response
{
"success": false,
"error": "Validation failed",
"status_code": 422
}
Error Handling
Errors are handled internally by the SDK.
response = client.track_lead(...)
if response.get("success"):
print("Success:", response["data"])
else:
print("Error:", response)
📊 Payload Reference
Lead Payload
Required:
event_namecustomer_external_id
Conditionally Required:
click_id(for standard flow or deferred setup)
Optional:
timestampcustomer_namecustomer_emailcustomer_avatarmode("deferred"only)
Sale Payload
Required:
click_idevent_namecustomer_external_idinvoice_idamountcurrency
Optional:
timestampcustomer_namecustomer_emailcustomer_avatar
Example Scripts
- examples/lead_example.py – Lead tracking and deferred attribution
- examples/sale_example.py – Sale tracking
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cms_python_client-1.0.0.tar.gz.
File metadata
- Download URL: cms_python_client-1.0.0.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9151a07a5f2d90b3339ef7374f0a3a93f664e67476199dec2bb36198f053f40a
|
|
| MD5 |
96a6cfe68a00aea7e23d74a325324400
|
|
| BLAKE2b-256 |
7564f00fdc43cedbdd1b00aebeded9de4efd7a5440c36e2e1dd4a658b0b5b4f4
|
File details
Details for the file cms_python_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cms_python_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46744a04cf43c6a5fd6ce7cbc048983fb5e64aaadaae84a3593e625664a0654a
|
|
| MD5 |
0156fc0b269a97d9e0dbd5c4171016ef
|
|
| BLAKE2b-256 |
bb54154c9578fa88e66dd4e56d85aa81d7bbdacfee6ef9228b0ef86740ba2ef1
|