Models API Reference

Message Models

Message models for WhatsApp SDK.

These models represent all message types supported by WhatsApp Business API. Includes both request models (what users send) and response models (what API returns).

class whatsapp_sdk.models.messages.TextMessage(*, body, preview_url=False)[source]

Bases: BaseModel

Text message request model.

Used to send plain text or text with URL preview.

body: str
preview_url: bool
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.ImageMessage(*, id=None, link=None, caption=None)[source]

Bases: BaseModel

Image message request model.

Send images via media ID or URL.

id: str | None
caption: str | None
classmethod validate_media_source(v, info)[source]

Ensure either id or link is provided, not both.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.DocumentMessage(*, id=None, link=None, caption=None, filename=None)[source]

Bases: BaseModel

Document message request model.

Send documents/files via media ID or URL.

id: str | None
caption: str | None
filename: str | None
classmethod validate_media_source(v, info)[source]

Ensure either id or link is provided, not both.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.AudioMessage(*, id=None, link=None)[source]

Bases: BaseModel

Audio message request model.

Send audio files via media ID or URL.

id: str | None
classmethod validate_media_source(v, info)[source]

Ensure either id or link is provided, not both.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.VideoMessage(*, id=None, link=None, caption=None)[source]

Bases: BaseModel

Video message request model.

Send videos via media ID or URL.

id: str | None
caption: str | None
classmethod validate_media_source(v, info)[source]

Ensure either id or link is provided, not both.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.StickerMessage(*, id=None, link=None)[source]

Bases: BaseModel

Sticker message request model.

Send stickers via media ID or URL.

id: str | None
classmethod validate_media_source(v, info)[source]

Ensure either id or link is provided, not both.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.LocationMessage(*, latitude, longitude, name=None, address=None)[source]

Bases: BaseModel

Location message request model.

Send geographic location with optional details.

latitude: float
longitude: float
name: str | None
address: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.InteractiveHeader(*, type, text=None, image=None, video=None, document=None)[source]

Bases: BaseModel

Header for interactive messages.

type: str
text: str | None
image: ImageMessage | Dict[str, str] | None
video: VideoMessage | Dict[str, str] | None
document: DocumentMessage | Dict[str, str] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.InteractiveBody(*, text)[source]

Bases: BaseModel

Body for interactive messages.

text: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.InteractiveFooter(*, text)[source]

Bases: BaseModel

Footer for interactive messages.

text: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.Button(*, type='reply', reply)[source]

Bases: BaseModel

Button for interactive messages.

type: str
reply: Dict[str, str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.Section(*, title=None, rows)[source]

Bases: BaseModel

Section for list messages.

title: str | None
rows: List[Dict[str, str]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.InteractiveAction(*, buttons=None, button=None, sections=None, name=None, parameters=None)[source]

Bases: BaseModel

Action for interactive messages.

buttons: List[Button] | None
button: str | None
sections: List[Section] | None
name: str | None
parameters: Dict[str, str] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.InteractiveMessage(*, type, header=None, body, footer=None, action)[source]

Bases: BaseModel

Interactive message request model.

Send messages with buttons, lists, or CTA URLs.

type: str
header: InteractiveHeader | None
body: InteractiveBody
footer: InteractiveFooter | None
action: InteractiveAction
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.TemplateParameter(*, type, text=None, image=None, video=None, document=None, currency=None, date_time=None)[source]

Bases: BaseModel

Parameter for template components.

type: str
text: str | None
image: ImageMessage | Dict[str, str] | None
video: VideoMessage | Dict[str, str] | None
document: DocumentMessage | Dict[str, str] | None
currency: Dict[str, Any] | None
date_time: Dict[str, Any] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.TemplateComponent(*, type, sub_type=None, index=None, parameters=<factory>)[source]

Bases: BaseModel

Component for template messages.

type: str
sub_type: str | None
index: int | None
parameters: List[TemplateParameter]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.TemplateLanguage(*, code, policy='deterministic')[source]

Bases: BaseModel

Language settings for template messages.

code: str
policy: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.TemplateMessage(*, name, language, components=None)[source]

Bases: BaseModel

Template message request model.

Send pre-approved template messages with parameters.

name: str
language: TemplateLanguage
components: List[TemplateComponent] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.ReactionMessage(*, message_id, emoji)[source]

Bases: BaseModel

Reaction message request model.

Send emoji reactions to messages.

message_id: str
emoji: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.messages.MessageStatus(*, id, status, timestamp, recipient_id, conversation=None, pricing=None, errors=None)[source]

Bases: BaseModel

Message status update model.

Represents status updates for sent messages.

id: str
status: str
timestamp: str
recipient_id: str
conversation: Dict[str, Any] | None
pricing: Dict[str, Any] | None
errors: List[Dict[str, Any]] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Template Models

Template models for WhatsApp SDK.

These models handle template management including creation, listing, and deletion of message templates.

class whatsapp_sdk.models.templates.TemplateButton(*, type, text, url=None, phone_number=None, example=None)[source]

Bases: BaseModel

Template button definition.

Represents buttons in template definitions.

type: str
text: str
url: str | None
phone_number: str | None
example: List[str] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateHeaderExample(*, header_text=None, header_handle=None)[source]

Bases: BaseModel

Example values for template header.

header_text: List[str] | None
header_handle: List[str] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateBodyExample(*, body_text=None)[source]

Bases: BaseModel

Example values for template body.

body_text: List[List[str]] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateExample(*, header_text=None, body_text=None, header_handle=None)[source]

Bases: BaseModel

Combined examples for template.

header_text: List[str] | None
body_text: List[List[str]] | None
header_handle: List[str] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateComponentDefinition(*, type, format=None, text=None, buttons=None, example=None)[source]

Bases: BaseModel

Template component definition for creating templates.

type: str
format: str | None
text: str | None
buttons: List[TemplateButton] | None
example: TemplateExample | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.Template(*, id=None, name, language, category, components, status=None, rejected_reason=None, quality_score=None)[source]

Bases: BaseModel

Complete template definition.

Represents a message template in the system.

id: str | None
name: str
language: str
category: str
components: List[TemplateComponentDefinition]
status: str | None
rejected_reason: str | None
quality_score: Dict[str, Any] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateResponse(*, id, status, category=None)[source]

Bases: BaseModel

Response after creating a template.

id: str
status: str
category: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateListResponse(*, data, paging=None)[source]

Bases: BaseModel

Response when listing templates.

data: List[Template]
paging: Dict[str, Any] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateDeleteResponse(*, success)[source]

Bases: BaseModel

Response after deleting a template.

success: bool
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.MessageTemplateUpdate(*, components)[source]

Bases: BaseModel

Update existing template components.

components: List[TemplateComponentDefinition]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.templates.TemplateAnalytics(*, template_id, template_name, sent=0, delivered=0, read=0, clicked=None, start_time, end_time)[source]

Bases: BaseModel

Template performance analytics.

template_id: str
template_name: str
sent: int
delivered: int
read: int
clicked: int | None
start_time: str
end_time: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Media Models

Media models for WhatsApp SDK.

These models handle media upload, download, and management for images, videos, documents, and audio files.

class whatsapp_sdk.models.media.MediaUploadResponse(*, id)[source]

Bases: BaseModel

Response after uploading media.

Contains the media ID to use in messages.

id: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.media.MediaURLResponse(*, url, mime_type, sha256, file_size, id)[source]

Bases: BaseModel

Response when retrieving media URL.

Contains the URL and metadata for downloading media.

url: str
mime_type: str
sha256: str
file_size: int
id: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.media.MediaDeleteResponse(*, success)[source]

Bases: BaseModel

Response after deleting media.

Confirms media deletion status.

success: bool
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.media.MediaUploadRequest(*, file_path=None, file_bytes=None, mime_type, filename=None)[source]

Bases: BaseModel

Request to upload media.

Parameters for uploading media files.

file_path: str | None
file_bytes: bytes | None
mime_type: str
filename: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.media.SupportedMediaTypes(*, images=<factory>, documents=<factory>, audio=<factory>, video=<factory>, stickers=<factory>)[source]

Bases: BaseModel

Supported media types and their constraints.

Reference for valid media types and size limits.

class ImageTypes(*, jpeg='image/jpeg', png='image/png', webp='image/webp', max_size=5242880)[source]

Bases: BaseModel

Supported image formats.

jpeg: str
png: str
webp: str
max_size: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class DocumentTypes(*, pdf='application/pdf', doc='application/msword', docx='application/vnd.openxmlformats-officedocument.wordprocessingml.document', ppt='application/vnd.ms-powerpoint', pptx='application/vnd.openxmlformats-officedocument.presentationml.presentation', xls='application/vnd.ms-excel', xlsx='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', txt='text/plain', max_size=104857600)[source]

Bases: BaseModel

Supported document formats.

pdf: str
doc: str
docx: str
ppt: str
pptx: str
xls: str
xlsx: str
txt: str
max_size: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class AudioTypes(*, aac='audio/aac', mp4='audio/mp4', mpeg='audio/mpeg', amr='audio/amr', ogg='audio/ogg', opus='audio/opus', max_size=16777216)[source]

Bases: BaseModel

Supported audio formats.

aac: str
mp4: str
mpeg: str
amr: str
ogg: str
opus: str
max_size: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class VideoTypes(*, mp4='video/mp4', threegp='video/3gpp', max_size=16777216)[source]

Bases: BaseModel

Supported video formats.

mp4: str
threegp: str
max_size: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class StickerTypes(*, webp='image/webp', max_size=524288, dimensions='512x512')[source]

Bases: BaseModel

Supported sticker formats.

webp: str
max_size: int
dimensions: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

images: ImageTypes
documents: DocumentTypes
audio: AudioTypes
video: VideoTypes
stickers: StickerTypes
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.media.ResumableUploadSession(*, id, upload_url, file_offset=0, file_size, expires_at)[source]

Bases: BaseModel

Resumable upload session for large files.

Used for uploading files larger than 5MB.

id: str
upload_url: str
file_offset: int
file_size: int
expires_at: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Webhook Models

Webhook models for WhatsApp SDK.

These models handle incoming webhook events from WhatsApp, including messages, status updates, and system notifications.

class whatsapp_sdk.models.webhooks.WebhookTextMessage(*, body)[source]

Bases: BaseModel

Incoming text message.

body: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookImageMessage(*, id, mime_type, sha256, caption=None)[source]

Bases: BaseModel

Incoming image message.

id: str
mime_type: str
sha256: str
caption: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookVideoMessage(*, id, mime_type, sha256, caption=None)[source]

Bases: BaseModel

Incoming video message.

id: str
mime_type: str
sha256: str
caption: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookAudioMessage(*, id, mime_type, sha256, voice=None)[source]

Bases: BaseModel

Incoming audio message.

id: str
mime_type: str
sha256: str
voice: bool | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookDocumentMessage(*, id, mime_type, sha256, caption=None, filename=None)[source]

Bases: BaseModel

Incoming document message.

id: str
mime_type: str
sha256: str
caption: str | None
filename: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookLocationMessage(*, latitude, longitude, name=None, address=None)[source]

Bases: BaseModel

Incoming location message.

latitude: float
longitude: float
name: str | None
address: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookStickerMessage(*, id, mime_type, sha256, animated=None)[source]

Bases: BaseModel

Incoming sticker message.

id: str
mime_type: str
sha256: str
animated: bool | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookButtonReply(*, id, title)[source]

Bases: BaseModel

Button reply from interactive message.

id: str
title: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookListReply(*, id, title, description=None)[source]

Bases: BaseModel

List selection from interactive message.

id: str
title: str
description: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookInteractiveMessage(*, type, button_reply=None, list_reply=None)[source]

Bases: BaseModel

Incoming interactive message response.

type: str
button_reply: WebhookButtonReply | None
list_reply: WebhookListReply | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookReactionMessage(*, message_id, emoji)[source]

Bases: BaseModel

Incoming reaction message.

message_id: str
emoji: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookContext(*, from_, id)[source]

Bases: BaseModel

Message context (for replies).

from_: str
id: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookMessage(*, from_, id, timestamp, type, context=None, text=None, image=None, video=None, audio=None, document=None, location=None, sticker=None, interactive=None, reaction=None, contacts=<factory>, errors=<factory>)[source]

Bases: BaseModel

Complete incoming message from webhook.

from_: str
id: str
timestamp: str
type: str
context: WebhookContext | None
text: WebhookTextMessage | None
image: WebhookImageMessage | None
video: WebhookVideoMessage | None
audio: WebhookAudioMessage | None
document: WebhookDocumentMessage | None
location: WebhookLocationMessage | None
sticker: WebhookStickerMessage | None
interactive: WebhookInteractiveMessage | None
reaction: WebhookReactionMessage | None
contacts: List[Dict[str, Any | None]]
errors: List[Dict[str, Any | None]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookStatus(*, id, status, timestamp, recipient_id, conversation=<factory>, pricing=<factory>, errors=<factory>)[source]

Bases: BaseModel

Message status update from webhook.

id: str
status: str
timestamp: str
recipient_id: str
conversation: Dict[str, Any | None]
pricing: Dict[str, Any | None]
errors: List[Dict[str, Any | None]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookMetadata(*, display_phone_number, phone_number_id)[source]

Bases: BaseModel

Metadata about the webhook source.

display_phone_number: str
phone_number_id: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookContact(*, profile=<factory>, wa_id)[source]

Bases: BaseModel

Contact information from webhook.

profile: Dict[str, str | None]
wa_id: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookValue(*, messaging_product='whatsapp', metadata, contacts=None, messages=None, statuses=None, errors=<factory>)[source]

Bases: BaseModel

Main webhook value containing messages or statuses.

messaging_product: str
metadata: WebhookMetadata
contacts: List[WebhookContact] | None
messages: List[WebhookMessage] | None
statuses: List[WebhookStatus] | None
errors: List[Dict[str, Any | None]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookChange(*, value, field)[source]

Bases: BaseModel

Webhook change event.

value: WebhookValue
field: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookEntry(*, id, changes)[source]

Bases: BaseModel

Webhook entry containing changes.

id: str
changes: List[WebhookChange]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookEvent(*, object, entry)[source]

Bases: BaseModel

Complete webhook event from WhatsApp.

object: str
entry: List[WebhookEntry]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.webhooks.WebhookVerification(*, hub_mode, hub_challenge, hub_verify_token)[source]

Bases: BaseModel

Webhook verification request.

hub_mode: str
hub_challenge: str
hub_verify_token: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Base Models

Base Pydantic models for WhatsApp SDK.

These models represent the core structures used across the SDK, matching Meta’s WhatsApp Cloud API v23.0 exactly.

class whatsapp_sdk.models.base.BaseResponse(*, messaging_product='whatsapp', **extra_data)[source]

Bases: BaseModel

Base response model for WhatsApp API responses.

All WhatsApp API responses include these common fields.

messaging_product: str
class Config[source]

Bases: object

extra = 'allow'
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.base.Contact(*, input, wa_id, **extra_data)[source]

Bases: BaseModel

Contact information in API responses.

Represents a WhatsApp contact that was processed.

input: str
wa_id: str
class Config[source]

Bases: object

extra = 'allow'
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.base.Message(*, id, **extra_data)[source]

Bases: BaseModel

Message information in API responses.

Represents a sent message confirmation.

id: str
class Config[source]

Bases: object

extra = 'allow'
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.base.Error(*, code, title=None, message, error_data=None, error_subcode=None, error_user_title=None, error_user_msg=None, fbtrace_id=None, **extra_data)[source]

Bases: BaseModel

Error model matching Meta’s error format.

WhatsApp API errors follow this structure.

code: int
title: str | None
message: str
error_data: Dict[str, Any] | None
error_subcode: int | None
error_user_title: str | None
error_user_msg: str | None
fbtrace_id: str | None
class Config[source]

Bases: object

extra = 'allow'
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.base.ErrorResponse(*, error, **extra_data)[source]

Bases: BaseModel

Complete error response from WhatsApp API.

error: Error
class Config[source]

Bases: object

extra = 'allow'
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.base.MessageResponse(*, messaging_product='whatsapp', contacts=<factory>, messages=<factory>, **extra_data)[source]

Bases: BaseResponse

Standard response after sending a message.

This is the response you get when successfully sending any message type.

contacts: List[Contact]
messages: List[Message]
class Config[source]

Bases: object

extra = 'allow'
model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.base.PaginationCursor(*, before=None, after=None)[source]

Bases: BaseModel

Pagination cursor for list responses.

before: str | None
after: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class whatsapp_sdk.models.base.PaginationInfo(*, cursors=None, next=None, previous=None)[source]

Bases: BaseModel

Pagination information for list responses.

cursors: PaginationCursor | None
next: str | None
previous: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].