Skip to main content

Keplars Email SDK for Python

Official Python SDK for the Keplars Email API - modern transactional email service with priority-based delivery.

Installation

pip install keplars

or with Poetry:

poetry add keplars

Quick Start

Synchronous Client

from keplars import Keplars

client = Keplars(api_key='kms_<workspaceId>.live_<secret>')

result = client.emails.send_instant(
    **{'from': 'noreply@yourdomain.com'},
    to='user@example.com',
    subject='Your verification code is 123456',
    html='<p>Your verification code is <strong>123456</strong></p>'
)

print(result.data.job_id)

Async Client

import asyncio
from keplars import AsyncKeplars

async def main():
    async with AsyncKeplars(api_key='kms_<workspaceId>.live_<secret>') as client:
        result = await client.emails.send_instant(
            **{'from': 'noreply@yourdomain.com'},
            to='user@example.com',
            subject='Welcome!',
            html='<h1>Welcome aboard</h1>'
        )
        print(result.data.job_id)

asyncio.run(main())

API Key Types

Type Format Used for
Regular kms_<id>.live_<secret> Email sending
Admin kms_<id>.adm_<secret> Contacts, audiences, automations, domains

Using Both Send and Admin Operations

Provide admin_key alongside a live api_key to use a single client for both email sending and admin operations:

client = Keplars(
    api_key='kms_<id>.live_<secret>',
    admin_key='kms_<id>.adm_<secret>'
)

client.emails.send_instant(...)   # uses api_key
client.audiences.list()           # uses admin_key

If you only have an admin key, pass it as api_key directly:

client = Keplars(api_key='kms_<id>.adm_<secret>')

Email Sending

Priority Levels

Method Delivery Use case
send_instant 0–5 sec OTPs, login codes, critical alerts
send_high 0–30 sec Transactional, notifications
send_async / send 0–5 min General transactional
send_bulk Idle Newsletters, marketing

Response Shape

result.success      # True
result.message      # 'Email queued'
result.data.job_id  # 'job_abc123'
result.data.priority # 'instant'

Send with Recipients

result = client.emails.send_high(
    **{'from': 'noreply@yourdomain.com'},
    to=[{'email': 'user@example.com', 'name': 'John Doe'}],
    cc=[{'email': 'manager@example.com'}],
    subject='Order Confirmation',
    html='<p>Your order has been confirmed</p>'
)

Send with Template

result = client.emails.send(
    **{'from': 'noreply@yourdomain.com'},
    to='user@example.com',
    subject='Password Reset',
    template_id='tpl_reset_password',
    template_data={'name': 'John', 'reset_link': 'https://example.com/reset/abc'}
)

Schedule Email

result = client.emails.schedule(
    **{'from': 'newsletter@yourdomain.com'},
    to='user@example.com',
    subject='Your weekly digest',
    html='<p>Here is your weekly digest...</p>',
    scheduled_for='2026-06-01T09:00:00Z',
    priority='bulk'
)

Contacts (Admin API Key Required)

admin_client = Keplars(api_key='kms_<workspaceId>.adm_<secret>')

admin_client.contacts.add(email='user@example.com', name='John Doe', audience_id='aud_abc123')

contact = admin_client.contacts.get('user@example.com')

contacts = admin_client.contacts.list(audience_id='aud_abc123', page=1, limit=20)

admin_client.contacts.update('user@example.com', name='Jane Doe')

admin_client.contacts.delete('user@example.com')

Audiences (Admin API Key Required)

audience = admin_client.audiences.create('Newsletter Subscribers', description='Main list')

audiences = admin_client.audiences.list(page=1, limit=20)

audience = admin_client.audiences.get('aud_abc123')

admin_client.audiences.delete('aud_abc123')

Automations (Admin API Key Required)

automations = admin_client.automations.list()

automation = admin_client.automations.get('auto_abc123')

admin_client.automations.enroll('auto_abc123', 'user@example.com')

admin_client.automations.unenroll('auto_abc123', 'user@example.com')

Domains (Admin API Key Required)

domain = admin_client.domains.add('mail.yourcompany.com')

domains = admin_client.domains.list()

status = admin_client.domains.get_status('dom_abc123')

result = admin_client.domains.verify('dom_abc123')

api_key = admin_client.domains.create_api_key(domain_id='dom_abc123', name='Production Key')

admin_client.domains.delete('dom_abc123')

Error Handling

from keplars import (
    Keplars,
    AuthenticationError,
    RateLimitError,
    ValidationError,
)

try:
    result = client.emails.send_instant(...)
except AuthenticationError:
    print('Invalid API key')
except RateLimitError as e:
    print(f'Rate limited, retry after: {e.retry_after}s')
except ValidationError as e:
    print(f'Validation error: {e}')

Metadata

Release files for keplars 2.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keplars 2.9.0
File Size Uploaded Provenance Actions
keplars-2.9.0.tar.gz 11.6 kB Without provenance Details for keplars-2.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for keplars 2.9.0
File Interpreter ABI Platform Actions
keplars-2.9.0-py3-none-any.whl Python 3 none any Details for keplars-2.9.0-py3-none-any.whl

Total release size: 25.1 kB

Release files / keplars-2.9.0.tar.gz

Download URL keplars-2.9.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ab8b7b2d50979f9f10c5174a5cfad1990c5a579405398b715ec2b34691da2bf6
BLAKE2b-256 checksum
How to use checksums
1360af464407c476de1aacdca13bef5879cba32aa25614a149863864a869782a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.11.15 Linux/6.17.0-1022-azure

Release files / keplars-2.9.0-py3-none-any.whl

Download URL keplars-2.9.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a35dccf4aae965351a00918bc4b666f137c4b789c9f64cf45df816644106b4b
BLAKE2b-256 checksum
How to use checksums
7d021ad1bd967515b4e9b9a3266f7da7c31c5c1277b80fc47252224030dfacc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.11.15 Linux/6.17.0-1022-azure

Security for keplars 2.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.9.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page