> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rootly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Auto-generated Python client for the Rootly API with sync and async support, type-safe models, and full coverage of incident, alert, and on-call endpoints.

The Rootly Python SDK is an auto-generated client for the Rootly API, published on PyPI as [`rootly`](https://pypi.org/project/rootly/) and imported in Python as `rootly_sdk`. Every path and method becomes a typed Python module with both synchronous and asynchronous variants, powered by [httpx](https://www.python-httpx.org/).

## Features

* **Full API coverage** — every endpoint becomes a Python module with typed parameters and responses
* **Sync and async** — each endpoint has blocking (`sync`) and async (`asyncio`) variants
* **Type-safe models** — generated data models for all request and response types
* **Built on httpx** — modern HTTP client with connection pooling, HTTP/2, and event hooks

## Requirements

* Python 3.8+

## Installation

```bash theme={null}
pip install rootly
```

```bash theme={null}
poetry add rootly
```

## Quick Start

```python theme={null}
from rootly_sdk import AuthenticatedClient

client = AuthenticatedClient(
    base_url="https://api.rootly.com",
    token="YOUR_API_TOKEN",
)
```

### Getting an API Key

1. Log in to your Rootly account
2. Navigate to **Settings** > **API Keys**
3. Create a new API key with the permissions you need

## Usage

### Synchronous Requests

```python theme={null}
from rootly_sdk.api.incidents import list_incidents, get_incident
from rootly_sdk.types import Response

with client as c:
    # List incidents
    incidents = list_incidents.sync(client=c)

    # Get full response details
    response: Response = list_incidents.sync_detailed(client=c)
    print(response.status_code)
```

### Async Requests

```python theme={null}
from rootly_sdk.api.incidents import list_incidents, get_incident

async with client as c:
    # Async list
    incidents = await list_incidents.asyncio(client=c)

    # Async with full response
    response = await list_incidents.asyncio_detailed(client=c)
```

### Endpoint Pattern

Every endpoint provides four functions:

| Function           | Description                                                |
| ------------------ | ---------------------------------------------------------- |
| `sync`             | Blocking request, returns parsed data or `None`            |
| `sync_detailed`    | Blocking request, returns full `Response` with status code |
| `asyncio`          | Async version of `sync`                                    |
| `asyncio_detailed` | Async version of `sync_detailed`                           |

All path parameters, query parameters, and request bodies become function arguments.

### Using Models

```python theme={null}
from rootly_sdk.models import Incident, Service, Alert
```

## Configuration

### Custom Base URL

```python theme={null}
client = AuthenticatedClient(
    base_url="https://custom.rootly.com",
    token="your-token",
)
```

### Custom SSL Certificate

```python theme={null}
client = AuthenticatedClient(
    base_url="https://internal_api.rootly.com",
    token="your-token",
    verify_ssl="/path/to/certificate_bundle.pem",
)
```

### Custom httpx Configuration

```python theme={null}
def log_request(request):
    print(f"{request.method} {request.url}")

def log_response(response):
    print(f"{response.status_code}")

client = AuthenticatedClient(
    base_url="https://api.rootly.com",
    token="your-token",
    httpx_args={
        "event_hooks": {
            "request": [log_request],
            "response": [log_response],
        }
    },
)
```

You can also access the underlying httpx client directly:

```python theme={null}
httpx_client = client.get_httpx_client()
async_client = client.get_async_httpx_client()
```

## Feedback & Support

* **Package**: [rootly on PyPI](https://pypi.org/project/rootly/)
* **Source Code**: [GitHub Repository](https://github.com/rootlyhq/rootly-python)
* **Issues**: [GitHub Issues](https://github.com/rootlyhq/rootly-python/issues)
