---
title: Python
description: Notiflows Python SDK for server-side integration
---

The Python SDK (`notiflows`) allows you to trigger notiflows, manage users, and interact with the Notiflows Admin API from your Python backend.

## Installation

```bash
pip install notiflows
```

## Quick Start

```python
from notiflows import Notiflows

client = Notiflows(
    api_key="pk_your_api_key",
    secret="sk_your_secret_key",
)

# Trigger a notiflow
client.notiflows.run(
    "welcome-email",
    data={"name": "Jane"},
    recipients=[{"external_id": "user_123"}],
)
```

## Configuration

```python
client = Notiflows(
    api_key="pk_your_api_key",
    secret="sk_your_secret_key",
)
```

Both `api_key` and `secret` are required. Find them in your project's **Settings > API Keys**.

## Triggering Notiflows

```python
# Send to specific recipients
client.notiflows.run(
    "order-shipped",
    data={"order_id": "order_789", "tracking_url": "https://example.com/track/789"},
    recipients=[
        {"external_id": "user_123"},
        {"external_id": "user_456"},
    ],
)

# Send to all subscribers of a topic
client.notiflows.run(
    "new-comment",
    topic="post_123",
    data={"commenter": "Jane", "comment": "Great post!"},
    actor={"external_id": "user_456"},
)
```

## Managing Users

### Upsert User

```python
user = client.users.upsert(
    "user_123",
    email="jane@example.com",
    first_name="Jane",
    last_name="Doe",
)
```

### Get User

```python
user = client.users.retrieve("user_123")
```

### List Users

```python
users_page = client.users.list(limit=20)
```

### Delete User

```python
client.users.delete("user_123")
```

## User Preferences

```python
# Get preferences
prefs = client.users.preferences.retrieve("user_123")

# Update preferences
client.users.preferences.update(
    "user_123",
    channel_types={"email": True, "sms": False},
)
```

## Topic Subscriptions

```python
# Subscribe user to topic
client.users.subscriptions.subscribe("user_123", topic_name="product-updates")

# List user subscriptions
subs = client.users.subscriptions.list("user_123")

# Unsubscribe
client.users.subscriptions.unsubscribe("product-updates", user_external_id="user_123")
```

## Topics

```python
# List topics
topics = client.topics.list(limit=10)

# Get topic
topic = client.topics.retrieve("product-updates")

# Delete topic
client.topics.delete("product-updates")
```

## Notifications & Deliveries

```python
# List notifications
notifications = client.notifications.list(limit=10)

# Get notification
notification = client.notifications.retrieve("notification_id")

# List deliveries for a notification
deliveries = client.notifications.list_deliveries("notification_id")

# List all deliveries
deliveries = client.deliveries.list(limit=10)

# Get delivery
delivery = client.deliveries.retrieve("delivery_id")
```

## User Notifications & Deliveries

```python
# List user's notifications
client.users.notifications.list("user_123")

# List user's deliveries
client.users.deliveries.list("user_123")
```
