konigle.models.comm.email
¶
Email communication models for the Konigle SDK.
This module provides Pydantic models for email accounts, channels, identities, and send operations with complete CRUD support.
Email
¶
Bases: CreateModel
Model for sending direct emails through the Konigle email service.
Not supporting cc and bcc since they don't represent the use case of sending transactional emails and marketing emails.
attachments = Field(default=None, title='Attachments', description='Optional file attachments (max 10 files). Can be file paths, bytes, BytesIO, BinaryIO, or tuples of (file_data, filename).', max_length=10)
class-attribute
instance-attribute
¶
Optional file attachments (max 10 files).
body_html = Field(title='HTML Body', description='HTML body content.')
class-attribute
instance-attribute
¶
HTML body content.
body_text = Field(default=None, title='Text Body', description='Plain text body content (optional).')
class-attribute
instance-attribute
¶
Plain text body content (optional).
category = Field(default=None, title='Category', description='Notification category code for the email. If present, the email will not be sent if the to_email is unsubscribed from the category.', max_length=50)
class-attribute
instance-attribute
¶
Notification category code for the email.
channel = Field(title='Channel', description='Channel code to use for sending the email.', max_length=20)
class-attribute
instance-attribute
¶
Channel code to use for sending the email.
from_email = Field(default=None, title='From Email', description='From email address to override the Account.default_from_email.')
class-attribute
instance-attribute
¶
From email address to override the Account.default_from_email.
headers = Field(default=None, title='Custom Headers', description='Optional custom headers to include in the email.')
class-attribute
instance-attribute
¶
Optional custom headers to include in the email.
reply_to_email = Field(default=None, title='Reply-To Email', description='Optional reply-to email address. Overrides Account.default_reply_to_email.')
class-attribute
instance-attribute
¶
Optional reply-to email address. Overrides Account.default_reply_to_email.
save_as_template = Field(default=False, title='Save as Template', description='Whether to save the email as a template for future use.')
class-attribute
instance-attribute
¶
Whether to save the email as a template for future use.
subject = Field(title='Subject', description='Email subject line.', max_length=255)
class-attribute
instance-attribute
¶
Email subject line.
to_email = Field(title='To Email', description='Primary recipient email addresses.', min_length=1)
class-attribute
instance-attribute
¶
Primary recipient email addresses.
normalize_attachments()
¶
Normalize attachments to FileInputT.
validate_attachments(v)
classmethod
¶
Validate attachment files.
validate_headers(v)
classmethod
¶
Validate custom headers.
EmailAccount
¶
Bases: BaseEmailAccount, TimestampedResource
Email account for a website.
Each website gets one email account that contains the default email configuration and serves as the parent for email channels and identities.
is_active = Field(default=True, title='Is Active', description='Whether the email account is active and can be used.')
class-attribute
instance-attribute
¶
Whether the email account is active.
EmailAccountCreate
¶
EmailAccountSetup
¶
Bases: BaseModel
Model for setting up an email account with initial configuration.
account_name = Field(title='Account Name', description='Name of the email account.', max_length=255)
class-attribute
instance-attribute
¶
Name of the email account.
default_from_email = Field(title='Default From Email', description='Default from email address for this account.')
class-attribute
instance-attribute
¶
Default from email address.
default_reply_to_email = Field(default=None, title='Default Reply-To Email', description='Default reply-to email address.')
class-attribute
instance-attribute
¶
Default reply-to email address.
identity_value = Field(title='Identity Value', description='Email address or domain to verify as an identity.', max_length=255)
class-attribute
instance-attribute
¶
Email address or domain to verify as an identity.
EmailAccountUpdate
¶
Bases: UpdateModel
Model for updating an existing email account.
default_from_email = Field(default=None, title='Default From Email', description='Default from email address for this account.')
class-attribute
instance-attribute
¶
Default from email address.
default_from_name = Field(default=None, title='Default From Name', description='Default from name for email headers.', max_length=255)
class-attribute
instance-attribute
¶
Default from name.
default_reply_to_email = Field(default=None, title='Default Reply-To Email', description='Default reply-to email address.')
class-attribute
instance-attribute
¶
Default reply-to email address.
default_reply_to_name = Field(default=None, title='Default Reply-To Name', description='Default reply-to name for email headers.', max_length=255)
class-attribute
instance-attribute
¶
Default reply-to name.
name = Field(default=None, title='Account Name', description='Name of the email account.', max_length=255)
class-attribute
instance-attribute
¶
Name of the email account.
EmailChannel
¶
Bases: BaseEmailChannel, TimestampedResource
Email channel for different types of emails within an account.
Channels separate different email flows (transactional, marketing, etc.) and provide individual configuration and rate limiting.
account = Field(title='Account ID', description='ID of the email account this channel belongs to.')
class-attribute
instance-attribute
¶
Email account this channel belongs to.
daily_quota = Field(default=1000, title='Daily Quota', description='Daily email quota for this channel.', ge=1)
class-attribute
instance-attribute
¶
Daily email quota for this channel.
enable_engagement_tracking = Field(default=False, title='Engagement Tracking', description='Whether engagement tracking (open and click) is enabled for this channel.')
class-attribute
instance-attribute
¶
Whether engagement tracking is enabled for this channel.
rate_limit = Field(default=10, title='Rate Limit', description='Rate limit (emails per second) for this channel.', ge=1, le=20)
class-attribute
instance-attribute
¶
Rate limit (emails per second) for this channel.
status = Field(default=(EmailChannelStatus.ACTIVE), title='Channel Status', description='Current status of the channel.')
class-attribute
instance-attribute
¶
Current status of the channel.
suspended_at = Field(default=None, title='Suspended At', description='When the channel was suspended.')
class-attribute
instance-attribute
¶
When the channel was suspended.
suspension_reason = Field(default=None, title='Suspension Reason', description='Reason for suspension if applicable.', max_length=255)
class-attribute
instance-attribute
¶
Reason for suspension if applicable.
EmailChannelCreate
¶
EmailChannelStatus
¶
Bases: str, Enum
Status of an email channel.
EmailChannelType
¶
Bases: str, Enum
Types of email channels available.
BROADCAST = 'broadcast'
class-attribute
instance-attribute
¶
Broadcast emails like announcements, updates.
MARKETING = 'marketing'
class-attribute
instance-attribute
¶
Marketing emails like newsletters, promotions.
TRANSACTIONAL = 'transactional'
class-attribute
instance-attribute
¶
Transactional emails like order confirmations, password resets.
EmailChannelUpdate
¶
Bases: UpdateModel
Model for updating an existing email channel.
code = Field(default=None, title='Channel Code', description='Unique code for the channel used when sending emails.', max_length=50)
class-attribute
instance-attribute
¶
Unique code for the channel given by the user that is used to refer to when sending the emails.
EmailIdentity
¶
Bases: TimestampedResource
Identities (domains or email addresses) for sending emails.
Identities must be verified before they can be used to send emails. This includes DKIM and SPF verification for domains.
account = Field(title='Account ID', description='ID of the email account this identity belongs to.')
class-attribute
instance-attribute
¶
Email account this identity belongs to.
dkim_records = Field(default_factory=list, title='DKIM Records', description='DKIM DNS records to be added for verification.')
class-attribute
instance-attribute
¶
DKIM DNS records to be added for verification.
dkim_verification_status = Field(default=(EmailVerificationStatus.PENDING), title='DKIM Verification Status', description='DKIM verification status.')
class-attribute
instance-attribute
¶
DKIM verification status.
dkim_verified = Field(default=False, title='DKIM Verified', description='Whether DKIM is verified.')
class-attribute
instance-attribute
¶
Whether DKIM is verified.
identity_type = Field(title='Identity Type', description='Type of identity (domain or email).')
class-attribute
instance-attribute
¶
Type of identity (domain or email).
identity_value = Field(title='Identity Value', description='The domain or email address value.', max_length=255)
class-attribute
instance-attribute
¶
The domain or email address value.
mail_from_domain = Field(default=None, title='MAIL FROM Domain', description='Custom MAIL FROM domain used for envelope sender.', max_length=255)
class-attribute
instance-attribute
¶
Custom MAIL FROM domain used for envelope sender.
mail_from_records = Field(default_factory=list, title='MAIL FROM Records', description='MAIL FROM DNS records to be added for verification.')
class-attribute
instance-attribute
¶
MAIL FROM DNS records to be added for verification.
mail_from_verification_status = Field(default=(EmailVerificationStatus.PENDING), title='MAIL FROM Verification Status', description='MAIL FROM domain verification status. This is SPF verification status.')
class-attribute
instance-attribute
¶
MAIL FROM domain verification status. This is SPF verification status.
mail_from_verified = Field(default=False, title='MAIL FROM Verified', description='Whether MAIL FROM domain is verified.')
class-attribute
instance-attribute
¶
Whether MAIL FROM domain is verified.
use_custom_mail_from = Field(default=False, title='Use Custom MAIL FROM', description='Whether to use custom MAIL FROM domain.')
class-attribute
instance-attribute
¶
Whether to use custom MAIL FROM domain.
verified = Field(default=False, title='Verified', description='Whether the identity is verified for sending emails.')
class-attribute
instance-attribute
¶
Whether the identity is verified for sending emails.
EmailIdentityCreate
¶
Bases: CreateModel
Model for creating a new email identity.
identity_value = Field(title='Identity Value', description='The domain or email address value.', max_length=255)
class-attribute
instance-attribute
¶
The domain or email address value.
EmailIdentityType
¶
EmailIdentityUpdate
¶
Bases: UpdateModel
Model for updating an existing email identity.
use_custom_mail_from = Field(default=None, title='Use Custom MAIL FROM', description='Whether to use custom MAIL FROM domain.')
class-attribute
instance-attribute
¶
Whether to use custom MAIL FROM domain.
EmailResponse
¶
Bases: BaseModel
Response model for successful email send operations.
message_id = Field(default=None, title='Email Message ID', description='Unique identifier for the sent email')
class-attribute
instance-attribute
¶
Unique identifier for the sent email
status = Field(title='Status', description='Status code of the email send operation.')
class-attribute
instance-attribute
¶
Status code of the email send operation.
template_id = Field(default=None, title='Template ID', description='ID of the created template (if save_as_template was True).')
class-attribute
instance-attribute
¶
ID of the created template (if save_as_template was True).
EmailTemplate
¶
Bases: BaseEmailTemplate, TimestampedResource
Email template for reusable email content.
Templates do not support any context as of now except for built in context
unsubscribe_link if the email is sent to a single recipient.
The template must be in valid Jinja2 format.
account = Field(title='Account ID', description='ID of the email account this template belongs to.')
class-attribute
instance-attribute
¶
ID of the email account this template belongs to.
preview_url = Field(default=None, title='Preview URL', description='URL to preview the rendered email template.')
class-attribute
instance-attribute
¶
URL to preview the rendered email template.
EmailTemplateCreate
¶
EmailTemplateUpdate
¶
Bases: UpdateModel
Model for updating an existing email template.
body_html = Field(default=None, title='HTML Body Template', description='HTML body template with variable placeholders.')
class-attribute
instance-attribute
¶
HTML body template with variable placeholders.
body_text = Field(default=None, title='Text Body Template', description='Plain text body template (optional).')
class-attribute
instance-attribute
¶
Plain text body template (optional).
code = Field(default=None, title='Template Code', description='Unique code for the template.', max_length=100)
class-attribute
instance-attribute
¶
Unique code for the template.
is_base = Field(default=None, title='Is Base Template', description='Indicates if this is a base template set for the account.')
class-attribute
instance-attribute
¶
Indicates if this is a base template set for the account.
name = Field(default=None, title='Template Name', description='Name of the email template.', max_length=255)
class-attribute
instance-attribute
¶
Name of the email template.
subject = Field(default=None, title='Subject Template', description='Subject line template with variable placeholders.')
class-attribute
instance-attribute
¶
Subject line template with variable placeholders.
tags = Field(default=None, title='Tags', description='List of tags for categorizing the template.')
class-attribute
instance-attribute
¶
List of tags for categorizing the template.