Versions in this module Expand all Collapse all v0 v0.1.0 Jun 17, 2026 Changes in this version + const DefaultAPIVersion + const DefaultBaseURL + var ErrInvalidConfig = errors.New("whatsapp: invalid configuration") + var ErrInvalidMessage = errors.New("whatsapp: invalid message") + var ErrInvalidRecipient = errors.New("whatsapp: invalid recipient") + var ErrInvalidSignature = errors.New("whatsapp: invalid webhook signature") + var ErrMediaError = errors.New("whatsapp: media error") + var ErrRateLimited = errors.New("whatsapp: rate limited") + var ErrRecipientNotAllowed = errors.New("whatsapp: recipient not in allowed list") + var ErrReengagementRequired = errors.New("whatsapp: re-engagement required (24h session window closed)") + var ErrSendFailed = errors.New("whatsapp: send failed") + var ErrTemplateNotApproved = errors.New("whatsapp: template not found or not approved") + var ErrTransient = errors.New("whatsapp: transient server error") + var ErrUnauthorized = errors.New("whatsapp: unauthorized") + var ErrUnsupported = errors.New("whatsapp: operation not supported") + func NewWebhookHandler(cfg WebhookConfig, h Handlers) http.Handler + func VerifySignature(appSecret string, body []byte, header string) error + type APIError struct + Code int + Details string + FBTraceID string + HTTPStatus int + Message string + Raw []byte + Subcode int + Title string + Type string + func (e *APIError) Error() string + func (e *APIError) Retryable() bool + func (e *APIError) Unwrap() error + type Button struct + ID string + Title string + type CapturedRequest struct + Body map[string]any + Header http.Header + Method string + RawBody []byte + URL string + type Client struct + func New(cfg Config, opts ...Option) (*Client, error) + func (c *Client) DeleteMedia(ctx context.Context, mediaID string) error + func (c *Client) Download(ctx context.Context, mediaID string) ([]byte, string, error) + func (c *Client) MarkRead(ctx context.Context, messageID string) error + func (c *Client) MediaInfo(ctx context.Context, mediaID string) (*MediaInfo, error) + func (c *Client) Send(ctx context.Context, to string, msg Message) (*Result, error) + func (c *Client) SendReply(ctx context.Context, to, replyToID string, msg Message) (*Result, error) + func (c *Client) SendTemplate(ctx context.Context, to string, tmpl TemplateMessage) (*Result, error) + func (c *Client) SendText(ctx context.Context, to, body string) (*Result, error) + func (c *Client) SendTyping(ctx context.Context, messageID string) error + func (c *Client) Upload(ctx context.Context, filename, mimeType string, r io.Reader) (string, error) + type Config struct + APIVersion string + AccessToken string + AppSecret string + BaseURL string + BusinessAccountID string + PhoneNumberID string + WebhookVerifyToken string + type Doer interface + Do func(req *http.Request) (*http.Response, error) + type Handlers struct + OnMessage func(ctx context.Context, m InboundMessage) + OnStatus func(ctx context.Context, s MessageStatus) + type InboundLocation struct + Address string + Latitude float64 + Longitude float64 + Name string + type InboundMedia struct + Caption string + Filename string + ID string + MimeType string + SHA256 string + Voice bool + type InboundMessage struct + ButtonPayload string + ButtonText string + ContextID string + From string + ID string + Interactive *InteractiveReply + Location *InboundLocation + Media *InboundMedia + Raw json.RawMessage + Reaction *InboundReaction + Text string + Timestamp string + Type string + type InboundReaction struct + Emoji string + MessageID string + type InteractiveButtons struct + Body string + Buttons []Button + Footer string + Header string + type InteractiveList struct + Body string + ButtonText string + Footer string + Header string + Sections []ListSection + type InteractiveReply struct + ID string + Kind string + Title string + type ListRow struct + Description string + ID string + Title string + type ListSection struct + Rows []ListRow + Title string + type Location struct + Address string + Latitude float64 + Longitude float64 + Name string + type Media struct + Caption string + Filename string + ID string + Link string + func AudioByID(id string) Media + func AudioByLink(link string) Media + func DocumentByID(id, filename, caption string) Media + func DocumentByLink(link, filename, caption string) Media + func ImageByID(id, caption string) Media + func ImageByLink(link, caption string) Media + func StickerByID(id string) Media + func StickerByLink(link string) Media + func VideoByID(id, caption string) Media + func VideoByLink(link, caption string) Media + type MediaInfo struct + FileSize int64 + ID string + MimeType string + SHA256 string + URL string + type Message interface + type MessageStatus struct + Category string + ConversationID string + Errors []APIError + MessageID string + RecipientID string + Status string + Timestamp string + type MockTransport struct + func NewMockTransport() *MockTransport + func (m *MockTransport) Do(req *http.Request) (*http.Response, error) + func (m *MockTransport) LastRequest() (CapturedRequest, bool) + func (m *MockTransport) Requests() []CapturedRequest + func (m *MockTransport) Reset() + func (m *MockTransport) WithError(err error) *MockTransport + func (m *MockTransport) WithResponse(status int, body string) *MockTransport + type Option func(*Client) + func WithAPIVersion(version string) Option + func WithBaseURL(baseURL string) Option + func WithHTTPClient(d Doer) Option + func WithLogger(l *slog.Logger) Option + func WithRetry(maxRetries int, base time.Duration) Option + type Reaction struct + Emoji string + MessageID string + type Result struct + Input string + MessageID string + Raw []byte + WAID string + type TemplateComponent struct + Index *int + Parameters []TemplateParameter + SubType string + Type string + func BodyComponent(params ...string) TemplateComponent + type TemplateMessage struct + Components []TemplateComponent + Language string + Name string + func AuthTemplate(name, language, code string) TemplateMessage + type TemplateParameter struct + Text string + Type string + func TextParam(text string) TemplateParameter + type Text struct + Body string + PreviewURL bool + func TextMessage(body string) Text + type WebhookConfig struct + AppSecret string + Logger *slog.Logger + VerifyToken string + type WebhookEvent struct + Messages []InboundMessage + Metadata WebhookMetadata + Object string + Statuses []MessageStatus + func ParseEvent(body []byte) (*WebhookEvent, error) + type WebhookMetadata struct + DisplayPhoneNumber string + PhoneNumberID string