# Python SDK

URL: https://notifly.io/docs/python-sdk

> notifly-sdk — the official, fully typed Python SDK covering the full Notifly REST surface, sync and async.

`notifly-sdk` is the official Python SDK for the Notifly API (import it as `notifly_py`). It is generated from the platform's OpenAPI spec, covers the full REST surface (131 operations), and is fully typed (`py.typed`) with both sync and async call styles on `httpx`.

## Install

```bash
pip install notifly-sdk==0.1.0
```

Requires Python 3.11+.

## Authentication

Notifly authenticates with your environment's secret key via the `Authorization: ApiKey <secret_key>` header:

```python
from notifly_py import AuthenticatedClient

client = AuthenticatedClient(
    base_url="https://api.notifly.io",
    token="<NOTIFLY_SECRET_KEY>",
    prefix="ApiKey",
)
```

<Callout type="warn">
  `prefix="ApiKey"` is required — the default `Bearer` prefix is for JWT sessions, not API keys.
</Callout>

## Trigger a workflow

```python
from notifly_py.api.events import events_controller_trigger
from notifly_py.models import TriggerEventRequestDto, TriggerEventRequestDtoPayload

payload = TriggerEventRequestDtoPayload()
payload.additional_properties = {"body": "Hello from Python!"}

with client as client:
    result = events_controller_trigger.sync(
        client=client,
        body=TriggerEventRequestDto(
            name="my-workflow",          # workflow identifier
            to="subscriber-id",          # or SubscriberPayloadDto / TopicPayloadDto / list of them
            payload=payload,
        ),
    )
```

Or async:

```python
async with client as client:
    result = await events_controller_trigger.asyncio(client=client, body=...)
```

## API structure

Endpoints live under `notifly_py.api.<tag>`, one module per operation. Each module exposes four call styles:

| Function           | Behavior                                                         |
| ------------------ | ---------------------------------------------------------------- |
| `sync`             | blocking, returns the parsed body (or `None`)                    |
| `sync_detailed`    | blocking, returns `Response` (status code, headers, parsed body) |
| `asyncio`          | async, returns the parsed body                                   |
| `asyncio_detailed` | async, returns `Response`                                        |

Available tags: `audit_logs`, `channel_connections`, `channel_endpoints`, `contexts`, `environment_variables`, `environments`, `events`, `integrations`, `layouts`, `messages`, `notifications`, `subscribers`, `topics`, `workflows`. All request/response models are in `notifly_py.models`.

## Client options

Both `Client` and `AuthenticatedClient` accept:

* `timeout` — an `httpx.Timeout`
* `verify_ssl` — path to a CA bundle, or `False` (not recommended)
* `headers` / `cookies` — extra values sent with every request
* `raise_on_unexpected_status` — raise on undocumented status codes (recommended: `True`)

The SDK is MIT-licensed and generated from the Notifly OpenAPI spec; releases publish to PyPI via GitHub Actions Trusted Publishing.
