Metadata-Version: 2.4
Name: contackd-sync
Version: 0.1.1
Summary: Python SDK for Contackd Sync
Project-URL: Homepage, https://example.com/contackd-sync
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.31.0
Requires-Dist: urllib3>=2.0.0

# contackd-sync (Python)

Python SDK for pushing and syncing customer data (`contacts`, `leads`, `prospects`).

## Install

```bash
pip install contackd-sync
```

## 2-Minute Start (Push Customer Details)

```python
from contackd_sync import ContackdClient, Contact

client = ContackdClient(
    api_key="sk_live_...",
    base_url="https://api.yourapp.com/v1",  # no trailing slash required
)

# Create/update a customer contact by email
customer = client.contacts.upsert(
    Contact(
        email="jane@acme.com",
        first_name="Jane",
        last_name="Doe",
        phone="+14155550199",
        tags=["customer", "vip"],
        custom={
            "customer_id": "CUST-1001",
            "plan": "pro",
            "country": "US",
        },
    )
)

print(customer)
```

## Common Customer Push Patterns

### 1) Push one new customer

```python
from contackd_sync import Contact

created = client.contacts.create(
    Contact(email="new@acme.com", first_name="New", last_name="Customer")
)
```

### 2) Push many customers (bulk upsert)

```python
from contackd_sync import Contact

result = client.contacts.bulk_upsert(
    [
        Contact(email="a@acme.com", first_name="A"),
        Contact(email="b@acme.com", first_name="B", tags=["trial"]),
    ]
)

print(len(result.created), len(result.updated), result.errors)
```

### 3) Read/filter customers

```python
page = client.contacts.list(page=1, per_page=50, email="jane@acme.com")
```

## API Key Setup

1. Create key (JWT required):

```bash
curl -X POST http://localhost:8000/api/v1/auth/api-keys \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"name":"py-sdk"}'
```

2. Use returned `api_key` as `api_key` in `ContackdClient`.

3. Revoke key:

```bash
curl -X DELETE http://localhost:8000/api/v1/auth/api-keys/<API_KEY_ID> \
  -H "Authorization: Bearer <ACCESS_TOKEN>"
```

## Backend Routes Expected by SDK

Given `base_url = https://api.yourapp.com/v1`:

- `GET /health`
- `POST /contacts|leads|prospects`
- `GET /contacts|leads|prospects/{id}`
- `PUT /contacts|leads|prospects/{id}`
- `DELETE /contacts|leads|prospects/{id}`
- `GET /contacts|leads|prospects`
- `POST /contacts|leads|prospects/upsert`
- `POST /contacts|leads|prospects/bulk`
- `POST /contacts|leads|prospects/bulk/upsert`
- `POST /contacts|leads|prospects/bulk/delete`
