# pilot-status (Python SDK)

SDK oficial em Python para consumir a API pública do Pilot Status.

## Instalação

```bash
pip install pilot-status
```

## Uso

Crie uma API key no painel e use somente no backend.

```python
import os

from pilot_status import PilotStatusClient

client = PilotStatusClient(
    api_key=os.environ["PILOT_STATUS_API_KEY"],
)

accepted = client.messages.send(
    {
        "templateId": "onboarding-test",
        "destinationNumber": "+5511999999999",
        "variables": {"name": "João"},
    }
)

message = client.messages.get(accepted["id"])
print(message["status"])
```

## Analytics

```python
stats = client.analytics.get_dashboard_stats(tz="America/Sao_Paulo")
print(stats["totalSent"], stats["failureRate"])
```

## Webhooks (parse/validação)

```python
from pilot_status import parse_customer_webhook

def handler(payload: dict):
    event = parse_customer_webhook(payload)

    if event["event"] == "message.failed":
        print(event["data"]["errorMessage"])
```

