Keplars

Python

Official Python SDK for Keplars

Installation

Install the package

pip install keplars
poetry add keplars
uv add keplars

Set your API key

KEPLARS_API_KEY=kms_your_workspace_id.live_your_secret

Send your first email

from keplars import Keplars
import os

client = Keplars(api_key=os.environ['KEPLARS_API_KEY'])

response = client.emails.send_instant(
    **{'from': '[email protected]'},
    to='[email protected]',
    subject='Hello!',
    body='<h1>It works!</h1>',
    is_html=True,
)

print(response.id)
from keplars import AsyncKeplars
import os

async def main():
    async with AsyncKeplars(api_key=os.environ['KEPLARS_API_KEY']) as client:
        response = await client.emails.send_instant(
            **{'from': '[email protected]'},
            to='[email protected]',
            subject='Hello!',
            body='<h1>It works!</h1>',
            is_html=True,
        )
        print(response.id)

Priority Levels

MethodDeliveryUse case
send_instant0–5 secondsOTP, 2FA, password reset
send_high0–30 secondsTransactional confirmations
send_async / send0–5 minutesWelcome emails, notifications
send_bulkBackgroundNewsletters, campaigns
client.emails.send_instant(...)
client.emails.send_high(...)
client.emails.send_async(...)
client.emails.send_bulk(...)

Using Templates

response = client.emails.send_instant(
    **{'from': '[email protected]'},
    to='[email protected]',
    template_id='your-template-id',
    params={
        'user_name': 'Jane',
        'verification_code': '123456',
    },
)

Schedule an Email

response = client.emails.schedule(
    **{'from': '[email protected]'},
    to='[email protected]',
    subject='Weekly digest',
    body='<p>Here is your digest.</p>',
    is_html=True,
    scheduled_for='2026-02-01T09:00:00Z',
    timezone='America/New_York',
)

Error Handling

from keplars import Keplars, AuthenticationError, RateLimitError, ValidationError

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

Admin API

Need to manage contacts, audiences, automations, or domains? Use an admin key - same client, different key suffix:

client = Keplars(api_key='kms_xxx.adm_xxx')

client.contacts.add(email='[email protected]', name='Jane')
client.audiences.create('Newsletter')
client.automations.enroll('auto_id', '[email protected]')
client.domains.verify('domain_id')

See the full Admin API reference.

Next Steps

On this page