Skip to main content

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:

  1. First Call (store association)

    • Send click_id + mode="deferred"
  2. Later Calls

    • Send normal events without click_id
    • Backend automatically resolves mapping

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: str
  • customer_external_id: str

Optional:

  • click_id: str
  • customer_name: str
  • customer_email: str
  • customer_avatar: str
  • timestamp: datetime
  • mode: str ("deferred" only)

track_sale()

Track a sale event.

Required:

  • click_id: str
  • event_name: str
  • customer_external_id: str
  • invoice_id: str
  • amount: int (in cents)
  • currency: str (3-letter code)

Optional:

  • customer_name: str
  • customer_email: str
  • customer_avatar: str
  • timestamp: 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_name
  • customer_external_id

Conditionally Required:

  • click_id (for standard flow or deferred setup)

Optional:

  • timestamp
  • customer_name
  • customer_email
  • customer_avatar
  • mode ("deferred" only)

Sale Payload

Required:

  • click_id
  • event_name
  • customer_external_id
  • invoice_id
  • amount
  • currency

Optional:

  • timestamp
  • customer_name
  • customer_email
  • customer_avatar

Example Scripts

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cms_python_client-1.0.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cms_python_client-1.0.0-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

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

Hashes for cms_python_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9151a07a5f2d90b3339ef7374f0a3a93f664e67476199dec2bb36198f053f40a
MD5 96a6cfe68a00aea7e23d74a325324400
BLAKE2b-256 7564f00fdc43cedbdd1b00aebeded9de4efd7a5440c36e2e1dd4a658b0b5b4f4

See more details on using hashes here.

File details

Details for the file cms_python_client-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cms_python_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46744a04cf43c6a5fd6ce7cbc048983fb5e64aaadaae84a3593e625664a0654a
MD5 0156fc0b269a97d9e0dbd5c4171016ef
BLAKE2b-256 bb54154c9578fa88e66dd4e56d85aa81d7bbdacfee6ef9228b0ef86740ba2ef1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page