Skip to main content

Server-side Python SDK for Sentroy platform API

Project description

Sentroy

Sentroy Client SDK for Python

Server-side SDK to interact with the Sentroy platform API.
Manage mail (domains, mailboxes, templates, inbox, send) and storage (buckets, media) from a single entry point.

PyPI version license


Installation

pip install sentroy-client-sdk

Quick Start

from sentroy import Sentroy

sentroy = Sentroy(
    base_url="https://sentroy.com",
    company_slug="my-company",
    access_token="stk_...",
)

Access tokens can be created from Admin > Access Tokens in the Sentroy dashboard.

Usage

Domains

# List all domains
domains = sentroy.domains.list()

# Get a single domain
domain = sentroy.domains.get("domain-id")

Mailboxes

# List all mailbox accounts
mailboxes = sentroy.mailboxes.list()

Templates

# List all templates
templates = sentroy.templates.list()

# Get a template by ID
template = sentroy.templates.get("template-id")

Templates support multiple languages. A field like name or subject can be a plain string or a dict keyed by language code:

# Example template response
{
    "id": "b3f1a2c4-...",
    "name": {"en": "Welcome Email", "tr": "Hosgeldin E-postasi"},
    "subject": {"en": "Welcome, {{name}}!", "tr": "Hosgeldin, {{name}}!"},
    "mjmlBody": {"en": "<mjml>...</mjml>", "tr": "<mjml>...</mjml>"},
    "variables": ["name", "company"],
    "domainId": "a1b2c3d4-...",
    "domainName": "example.com"
}

Use the variables list to know which placeholders ({{name}}, {{company}}) the template expects.

Inbox

from sentroy import InboxListParams

# List messages
messages = sentroy.inbox.list(InboxListParams(
    mailbox="info@example.com",
    folder="INBOX",
    page=1,
    limit=20,
))

# Get a single message
message = sentroy.inbox.get(1234, mailbox="info@example.com")

# List IMAP folders
folders = sentroy.inbox.list_folders("info@example.com")

# Get a thread by subject
thread = sentroy.inbox.get_thread("Re: Project update", "info@example.com")

# Mark as read / unread
sentroy.inbox.mark_as_read(1234, mailbox="info@example.com")
sentroy.inbox.mark_as_unread(1234, mailbox="info@example.com")

# Move message
sentroy.inbox.move(1234, "Trash", from_folder="INBOX", mailbox="info@example.com")

# Delete message
sentroy.inbox.delete(1234, mailbox="info@example.com")

Send Email

from sentroy import SendParams, Attachment

# Send with a template
result = sentroy.send.email(SendParams(
    to="user@example.com",
    from_addr="info@example.com",
    subject="Welcome!",
    domain_id="domain-id",
    template_id="template-id",
    variables={
        "name": "John",
        "company": "Acme",
    },
))

# Send with a specific language
result = sentroy.send.email(SendParams(
    to="user@example.com",
    from_addr="info@example.com",
    subject="Hosgeldin!",
    domain_id="domain-id",
    template_id="template-id",
    lang="tr",
    variables={"name": "Ahmet"},
))

# Send with raw HTML
result = sentroy.send.email(SendParams(
    to=["user1@example.com", "user2@example.com"],
    from_addr="info@example.com",
    subject="Hello",
    domain_id="domain-id",
    html="<h1>Hello World</h1>",
))

# Send with attachments
result = sentroy.send.email(SendParams(
    to="user@example.com",
    from_addr="info@example.com",
    subject="Invoice",
    domain_id="domain-id",
    html="<p>Please find your invoice attached.</p>",
    attachments=[
        Attachment(
            filename="invoice.pdf",
            content=base64_string,
            content_type="application/pdf",
        ),
    ],
))

Buckets

Storage is organized into buckets — isolated containers with their own visibility (public vs private) and usage counters.

# List all buckets
buckets = sentroy.buckets.list()

# Get a single bucket by its slug
bucket = sentroy.buckets.get("product-assets")

# Create (slug auto-derived from name if omitted)
bucket = sentroy.buckets.create(
    name="User Uploads",
    description="Avatars and profile media",
    is_public=False,
)

# Update — toggling is_public cascades to every file's ACL
bucket = sentroy.buckets.update("product-assets", is_public=True)

# Delete (pass force=True to purge files first)
sentroy.buckets.delete("product-assets", force=True)

Media

Upload, list, download, and delete files. The same access token that authorizes mail calls also authorizes storage.

# List files in a bucket
result = sentroy.media.list("product-assets", type="image", limit=50)
print(result.total, len(result.items))

# Get a single media record
media = sentroy.media.get("product-assets", "media-id")

# Upload from a file path
uploaded = sentroy.media.upload(
    "product-assets",
    body="./photo.jpg",
    folder="products",
    tags=["v1", "cover"],
    is_public=True,
)

# Upload from raw bytes
uploaded = sentroy.media.upload(
    "product-assets",
    body=photo_bytes,
    filename="photo.jpg",
    content_type="image/jpeg",
)

# Download — returns (bytes, content_type)
data, content_type = sentroy.media.download("product-assets", "media-id")

# Thumbnail variant (500px wide — falls back to original if unavailable)
thumb, _ = sentroy.media.download(
    "product-assets", "media-id", quality=500,
)

# Delete
sentroy.media.delete("product-assets", "media-id")

Error Handling

from sentroy import Sentroy, SentroyError

try:
    sentroy.send.email(params)
except SentroyError as err:
    print(err.status_code)  # 401, 403, 500, etc.
    print(err)              # Human-readable error

Configuration

Option Type Required Description
base_url str Yes Sentroy instance URL (e.g. https://sentroy.com)
company_slug str Yes Your company slug
access_token str Yes Access token (stk_...)
timeout int No Request timeout in seconds (default: 30)

Requirements

  • Python 3.10+
  • Zero external dependencies (stdlib only)

Raw Documentation

For AI agents and LLMs — plain-text version of this document:

https://raw.githubusercontent.com/Sentroy-Co/client-sdk/refs/heads/main/python/README.md

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentroy_client_sdk-2.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentroy_client_sdk-2.0.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file sentroy_client_sdk-2.0.0.tar.gz.

File metadata

  • Download URL: sentroy_client_sdk-2.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sentroy_client_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 46cd4c38d43455ab218ecb37e463a728366a553b54c72cf3c98986b3a1ebaadf
MD5 a2d97fe9d4d8ea954d72c9a2d56d9ad4
BLAKE2b-256 5adec31c4e8bb327d0eb63c90f4bfa267c4a3ed55dba48d4117ccf5c7a3e4295

See more details on using hashes here.

Provenance

The following attestation bundles were made for sentroy_client_sdk-2.0.0.tar.gz:

Publisher: publish-python.yml on Sentroy-Co/client-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sentroy_client_sdk-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sentroy_client_sdk-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0779dbe81ad3995ad94b0094474680316854b9b2154c18e4841492efd9cec59
MD5 6293bba5256195d23234eac7e7aba6d0
BLAKE2b-256 472da9acfffd539d34713d867752109aab6037e670bca399ec21de9b713804b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sentroy_client_sdk-2.0.0-py3-none-any.whl:

Publisher: publish-python.yml on Sentroy-Co/client-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page