Metadata-Version: 2.4
Name: qubrics-sending
Version: 2.0.0
Summary: Generated Python client for the Qubrics Sending API.
Project-URL: Repository, https://github.com/qubrics/qubrics-sdk
License-Expression: MIT
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: certifi
Requires-Dist: pydantic<3,>=2
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: qubrics-core<3.0.0,>=2.0.0
Requires-Dist: typing-extensions>=4.7.1
Requires-Dist: urllib3<3,>=2.3.0
Description-Content-Type: text/markdown

# qubrics-sending

[![PyPI version](https://img.shields.io/pypi/v/qubrics-sending)](https://pypi.org/project/qubrics-sending/)
[![Python versions](https://img.shields.io/pypi/pyversions/qubrics-sending)](https://pypi.org/project/qubrics-sending/)
[![PyPI downloads](https://img.shields.io/pypi/dm/qubrics-sending)](https://pypi.org/project/qubrics-sending/)
[![Licence](https://img.shields.io/pypi/l/qubrics-sending)](https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE)

Generated Python client for the Qubrics Sending API.

## Documentation

- Sending API reference: [qubrics.com/docs/sending-api/introduction](https://qubrics.com/docs/sending-api/introduction)
- Source repository: [qubrics/qubrics-sdk](https://github.com/qubrics/qubrics-sdk)

## Requirements

- Python 3.10 or newer.
- A send-capable `smx_mbx_*` key or owner-approved Sending-resource `smx_agent_*` token.

For OAuth, use a REST access token with the scopes and mailbox access required by the operation. See [OAuth for REST APIs](https://qubrics.com/docs/developer-tools/oauth).

## Installation

These commands target the Qubrics release of `qubrics-sending`. Until it is published, install `sendmux-sending` with its existing import names.

```sh
pip install qubrics-sending
```

## Connection checks

Check the authenticated team and credential without sending an email:

```python
import os

from qubrics.sending import MetaApi, create_sending_client

with create_sending_client(api_key=os.environ["QUBRICS_SENDING_API_KEY"]) as client:
    connection = MetaApi(client).sending_get_connection()
    print(connection.data.label)
```

## OAuth access tokens

Pass either `api_key` or `access_token`. `access_token` accepts a bare token string or a synchronous callable; the callable is evaluated for each authenticated request. Your application owns token storage, expiry checks and refresh coordination.

```python
import os

from qubrics.sending import create_sending_client

client = create_sending_client(
    access_token=lambda: os.environ["QUBRICS_ACCESS_TOKEN"]
)
```

## Usage

```python
import os

from qubrics.sending import Address, EmailSendRequest, EmailsApi, create_sending_client

client = create_sending_client(api_key=os.environ["QUBRICS_SENDING_API_KEY"])
api = EmailsApi(client)

response = api.sending_send_email(
    EmailSendRequest(
        var_from=Address(email="sender@example.com"),
        to=Address(email="recipient@example.com"),
        subject="Hello from Qubrics",
        html_body="<p>Hello.</p>",
        text_body="Hello.",
    ),
    idempotency_key="email_123",
)

print(response.data.message_id)
```

The package exports every generated Sending model and API class plus:

- `create_sending_client`
- `configure_sending`
- `QubricsSendingApiClient`
- file helpers: `upload_attachment_from_file`, `send_email_with_files`, and explicit legacy `attachment_from_file`

## Attachments

For real files, upload bytes first and send with returned `attachment_id` refs. `send_email_with_files` does that automatically, so file bytes never enter model context or the JSON send body. Inline base64 remains available only when you intentionally call `attachment_from_file` for tiny generated content.

```python
import os

from qubrics.sending import create_sending_client, send_email_with_files

client = create_sending_client(api_key=os.environ["QUBRICS_SENDING_API_KEY"])

send_email_with_files(
    client,
    files=["./report.pdf"],
    idempotency_key="report-123",
    body={
        "from": {"email": "sender@example.com"},
        "to": {"email": "recipient@example.com"},
        "subject": "Report",
        "html_body": "<p>Attached.</p>",
    },
)
```

To upload first and compose the send yourself:

```python
import os

from qubrics.sending import EmailSendRequest, EmailsApi, create_sending_client, upload_attachment_from_file

client = create_sending_client(api_key=os.environ["QUBRICS_SENDING_API_KEY"])
attachment = upload_attachment_from_file(client, file_path="./report.pdf")

EmailsApi(client).sending_send_email(
    EmailSendRequest.from_dict({
        "from": {"email": "sender@example.com"},
        "to": {"email": "recipient@example.com"},
        "subject": "Report",
        "html_body": "<p>Attached.</p>",
        "attachments": [{"attachment_id": attachment.data.attachment_id}],
    })
)
```

## Request helpers

Use `qubrics-core` when you need explicit idempotency, conditional request, pagination, retry, or typed-error helpers. The generated Sending client already uses the shared retry and error mapper.

## Support

Open an issue in [qubrics/qubrics-sdk](https://github.com/qubrics/qubrics-sdk/issues) with the package name, version, and request ID from any API error.

## Licence

MIT. See the [licence file](https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE).
