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 cutmeshort

📋 Requirements

  • Python 3.9+

Setup

Set your Bearer token:

export CMS_BEARER_TOKEN="your_jwt_token"

⚡ Quick Start

import os
from cutmeshort 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 cutmeshort 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 cutmeshort 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 cutmeshort 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

cutmeshort-1.0.1.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

cutmeshort-1.0.1-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file cutmeshort-1.0.1.tar.gz.

File metadata

  • Download URL: cutmeshort-1.0.1.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cutmeshort-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ea667e699c4c621b6ccf5863974d780797ee03705bbeec444d871974273fe186
MD5 cf0f4d4d63a36cdae5f77780e47ed602
BLAKE2b-256 c676cb2084def19c7007adc32784fa9587e41fa5aaa5cefd4c21a46882509ec7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cutmeshort-1.0.1.tar.gz:

Publisher: publish.yml on Cut-Me-Short/cms-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cutmeshort-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cutmeshort-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cutmeshort-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f2d5e12d76741826b2e445912d2c949f872ec4b6c24ac88a454422d358790e1
MD5 efde867006e79853815556d9018c0418
BLAKE2b-256 7409fdeed5e5760d862515fe64ad1ae67936c5db5a49308f2ed7d75e87956c8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cutmeshort-1.0.1-py3-none-any.whl:

Publisher: publish.yml on Cut-Me-Short/cms-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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