Python
Official Python SDK for Keplars
Installation
Install the package
pip install keplarspoetry add keplarsuv add keplarsSet your API key
KEPLARS_API_KEY=kms_your_workspace_id.live_your_secretSend 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
| Method | Delivery | Use case |
|---|---|---|
send_instant | 0–5 seconds | OTP, 2FA, password reset |
send_high | 0–30 seconds | Transactional confirmations |
send_async / send | 0–5 minutes | Welcome emails, notifications |
send_bulk | Background | Newsletters, 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
- Admin API - Contacts, audiences, automations, domains
- Send Emails - API reference
- Email Templates - Build reusable templates
- Schedule Emails - Delayed delivery