Documentation
¶
Overview ¶
Package api defines the wire protocol shared by the CLI, the daemon and the MCP server.
Index ¶
- Constants
- func ExitCode(code string) int
- type AuditEntry
- type AvatarParams
- type BlockParams
- type Call
- type CallRejectParams
- type Candidate
- type Channel
- type ChannelCreateParams
- type ChannelFollowParams
- type ChannelMessage
- type ChannelMessagesParams
- type ChannelMuteParams
- type ChannelReactParams
- type ChannelRef
- type Chat
- type ChatRef
- type CheckParams
- type CheckResult
- type CommunityLinkParams
- type Contact
- type ContactInput
- type DeleteParams
- type DownloadParams
- type DownloadResult
- type Draft
- type DraftApproveParams
- type DraftListParams
- type DraftRef
- type DryRun
- type EditParams
- type Empty
- type Error
- type Event
- type EventsParams
- type ForwardParams
- type Frame
- type Group
- type GroupCreateParams
- type GroupInviteParams
- type GroupListParams
- type GroupParticipantsParams
- type GroupRef
- type GroupRequestsParams
- type GroupUpdateParams
- type HistoryParams
- type JoinParams
- type LimitParams
- type ListChatsParams
- type ListContactsParams
- type ListMessagesParams
- type Location
- type LocationInput
- type LoginParams
- type MarkReadParams
- type Media
- type Message
- type MessageRef
- type Meta
- type Participant
- type PinParams
- type Poll
- type PollCreateParams
- type PollOption
- type PollVoteParams
- type PresenceParams
- type PrivacySetParams
- type Profile
- type ProfileUpdateParams
- type ReactParams
- type Reaction
- type Request
- type ResolveParams
- type Resolved
- type ScheduleListParams
- type ScheduleParams
- type ScheduleRef
- type Scheduled
- type SearchParams
- type SendFailure
- type SendManyParams
- type SendManyResult
- type SendParams
- type SendResult
- type StarParams
- type Status
- type StatusPostParams
- type Transcript
- type TypingParams
- type UpdateChatParams
- type UserInfo
- type UserRef
- type WaitParams
Constants ¶
const ( CodeInternal = "internal" CodeUsage = "usage" CodeNotLoggedIn = "not_logged_in" CodeAlreadyLoggedIn = "already_logged_in" CodeNotConnected = "not_connected" CodeNotFound = "not_found" CodeAmbiguous = "ambiguous" CodeNotOnWhatsApp = "not_on_whatsapp" CodePolicyDenied = "policy_denied" CodeConfirmationRequired = "confirmation_required" CodeApprovalRequired = "approval_required" CodeRateLimited = "rate_limited" CodeTimeout = "timeout" CodeWhatsApp = "whatsapp_error" CodeUnsupported = "unsupported" )
Error codes. Each maps to a stable process exit code (see ExitCode).
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Time string `json:"time"`
Source string `json:"source"`
Profile string `json:"profile"`
Method string `json:"method"`
Targets string `json:"targets,omitempty"`
OK bool `json:"ok"`
DryRun bool `json:"dry_run,omitempty"`
Sends int `json:"sends,omitempty"`
Error string `json:"error,omitempty"`
}
type AvatarParams ¶
type BlockParams ¶
type CallRejectParams ¶
type ChannelCreateParams ¶
type ChannelFollowParams ¶
type ChannelMessage ¶
type ChannelMessagesParams ¶
type ChannelMuteParams ¶
type ChannelReactParams ¶
type ChannelRef ¶
type ChannelRef struct {
Channel string `json:"channel" jsonschema:"Channel JID, name or invite link (whatsapp.com/channel/...)"`
}
type Chat ¶
type Chat struct {
JID string `json:"jid"`
Name string `json:"name"`
Kind string `json:"kind"` // dm, group, channel, broadcast, status
LastMessageAt *time.Time `json:"last_message_at,omitempty"`
LastMessage string `json:"last_message,omitempty"`
Unread int `json:"unread"`
Archived bool `json:"archived,omitempty"`
Pinned bool `json:"pinned,omitempty"`
MutedUntil *time.Time `json:"muted_until,omitempty"`
Disappearing string `json:"disappearing,omitempty"`
}
type ChatRef ¶
type ChatRef struct {
Chat string `json:"chat" jsonschema:"Chat: name, phone or JID"`
}
type CheckParams ¶
type CheckParams struct {
Phones []string `json:"phones" jsonschema:"Phone numbers with country code"`
}
type CheckResult ¶
type CommunityLinkParams ¶
type ContactInput ¶
type DeleteParams ¶
type DownloadParams ¶
type DownloadResult ¶
type Draft ¶
type Draft struct {
ID int64 `json:"id"`
Status string `json:"status"`
Method string `json:"method"`
Summary string `json:"summary"`
Preview string `json:"preview"`
Reason string `json:"reason,omitempty"`
Targets []string `json:"targets,omitempty"`
Source string `json:"source"`
Profile string `json:"profile"`
Created string `json:"created"`
Expires string `json:"expires"`
ResolvedAt string `json:"resolved_at,omitempty"`
ResolvedBy string `json:"resolved_by,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
Code string `json:"code,omitempty"`
}
type DraftApproveParams ¶
type DraftListParams ¶
type EditParams ¶
type Error ¶
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
Hint string `json:"hint,omitempty"`
Details any `json:"details,omitempty"`
}
Error is the structured error returned by every method.
func (*Error) WithDetails ¶
type Event ¶
type Event struct {
Type string `json:"type"`
Time time.Time `json:"time"`
Chat string `json:"chat,omitempty"`
Data any `json:"data,omitempty"`
}
Event is pushed to `wassup events`, webhooks and streaming calls.
type EventsParams ¶
type ForwardParams ¶
type Frame ¶
type Frame struct {
ID int64 `json:"id"`
Event json.RawMessage `json:"event,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
Final bool `json:"final,omitempty"`
}
Frame is one line of JSON sent back. Streams send Event frames, then exactly one Final frame.
type Group ¶
type Group struct {
JID string `json:"jid"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Owner string `json:"owner,omitempty"`
Created *time.Time `json:"created,omitempty"`
ParticipantCount int `json:"participant_count"`
Participants []Participant `json:"participants,omitempty"`
Announce bool `json:"announce"`
Locked bool `json:"locked"`
ApprovalRequired bool `json:"approval_required"`
MemberAddMode string `json:"member_add_mode,omitempty"`
Disappearing string `json:"disappearing,omitempty"`
IsCommunity bool `json:"is_community,omitempty"`
Community string `json:"community,omitempty"`
IsAdmin bool `json:"is_admin"`
}
type GroupCreateParams ¶
type GroupCreateParams struct {
Name string `json:"name" jsonschema:"Group name (max 100 characters)"`
Participants []string `json:"participants" jsonschema:"People to add (phones, names or JIDs)"`
Community bool `json:"community,omitempty" jsonschema:"Create a community instead of a group"`
Parent string `json:"parent,omitempty" jsonschema:"Community to create the group inside"`
Description string `json:"description,omitempty" jsonschema:"Group description"`
}
type GroupInviteParams ¶
type GroupListParams ¶
type GroupListParams struct {
Query string `json:"query,omitempty" jsonschema:"Filter by name"`
}
type GroupParticipantsParams ¶
type GroupRef ¶
type GroupRef struct {
Group string `json:"group" jsonschema:"Group: name, JID or invite link"`
}
type GroupRequestsParams ¶
type GroupUpdateParams ¶
type GroupUpdateParams struct {
Group string `json:"group" jsonschema:"Group to change"`
Name string `json:"name,omitempty" jsonschema:"New name"`
Description *string `json:"description,omitempty" jsonschema:"New description; empty string clears it"`
Announce *bool `json:"announce,omitempty" jsonschema:"Only admins can send messages"`
Locked *bool `json:"locked,omitempty" jsonschema:"Only admins can edit group info"`
Approval *bool `json:"approval,omitempty" jsonschema:"Admins must approve new members"`
MemberAdd string `json:"member_add,omitempty" jsonschema:"Who can add members: admins or all"`
Photo string `json:"photo,omitempty" jsonschema:"Path to a new group photo"`
RemovePhoto bool `json:"remove_photo,omitempty" jsonschema:"Remove the group photo"`
Disappearing string `json:"disappearing,omitempty" jsonschema:"off, 24h, 7d or 90d"`
}
type HistoryParams ¶
type JoinParams ¶
type JoinParams struct {
Link string `json:"link" jsonschema:"Invite link (chat.whatsapp.com/...) or code"`
}
type LimitParams ¶
type LimitParams struct {
Limit int `json:"limit,omitempty" jsonschema:"Max items (default 50)"`
}
type ListChatsParams ¶
type ListChatsParams struct {
Query string `json:"query,omitempty" jsonschema:"Filter by name"`
Kind string `json:"kind,omitempty" jsonschema:"dm, group, channel or broadcast"`
Unread bool `json:"unread,omitempty" jsonschema:"Only chats with unread messages"`
Archived string `json:"archived,omitempty" jsonschema:"exclude (default), include or only"`
Limit int `json:"limit,omitempty" jsonschema:"Max chats (default 50)"`
}
type ListContactsParams ¶
type ListMessagesParams ¶
type ListMessagesParams struct {
Chat string `json:"chat,omitempty" jsonschema:"Chat to read; empty = all chats"`
Limit int `json:"limit,omitempty" jsonschema:"Max messages (default 30, max 1000)"`
Before string `json:"before,omitempty" jsonschema:"Only messages before this time (RFC3339, 2h, 3d) or message ID"`
After string `json:"after,omitempty" jsonschema:"Only messages after this time (RFC3339, 2h, 3d) or message ID"`
From string `json:"from,omitempty" jsonschema:"Only messages from this sender"`
FromMe *bool `json:"from_me,omitempty" jsonschema:"true = only yours, false = only others'"`
Type string `json:"type,omitempty" jsonschema:"text, image, video, audio, voice, document, sticker, location, contact, poll"`
Unread bool `json:"unread,omitempty" jsonschema:"Only messages received after the chat was last read"`
Order string `json:"order,omitempty" jsonschema:"asc (oldest first, default) or desc"`
}
type LocationInput ¶
type LoginParams ¶
type LoginParams struct {
Phone string `` /* 138-byte string literal not displayed */
}
type MarkReadParams ¶
type Media ¶
type Media struct {
Mime string `json:"mime,omitempty"`
FileName string `json:"file_name,omitempty"`
Size int64 `json:"size,omitempty"`
Seconds int `json:"seconds,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Path string `json:"path,omitempty"` // set once downloaded
}
type Message ¶
type Message struct {
ID string `json:"id"`
Chat string `json:"chat"`
ChatName string `json:"chat_name,omitempty"`
Sender string `json:"sender,omitempty"`
SenderName string `json:"sender_name,omitempty"`
FromMe bool `json:"from_me"`
Time time.Time `json:"time"`
Type string `json:"type"`
Text string `json:"text,omitempty"`
Media *Media `json:"media,omitempty"`
Location *Location `json:"location,omitempty"`
Poll *Poll `json:"poll,omitempty"`
QuotedID string `json:"quoted_id,omitempty"`
Mentions []string `json:"mentions,omitempty"`
Forwarded bool `json:"forwarded,omitempty"`
ViewOnce bool `json:"view_once,omitempty"`
Edited bool `json:"edited,omitempty"`
Revoked bool `json:"revoked,omitempty"`
Starred bool `json:"starred,omitempty"`
Status string `json:"status,omitempty"` // for your own messages: sent, delivered, read, played
Transcript string `json:"transcript,omitempty"`
Reactions []Reaction `json:"reactions,omitempty"`
}
type MessageRef ¶
type MessageRef struct {
Chat string `json:"chat,omitempty" jsonschema:"Chat of the message (optional if the ID is unique locally)"`
ID string `json:"id" jsonschema:"Message ID"`
}
MessageRef addresses one stored message.
type Meta ¶
type Meta struct {
Source string `json:"source,omitempty"` // cli, mcp or rpc
Profile string `json:"profile,omitempty"` // policy profile name
Yes bool `json:"yes,omitempty"` // user confirmed risky actions
DryRun bool `json:"dry_run,omitempty"` // report instead of doing
}
Meta travels with every request and feeds the policy engine.
type Participant ¶
type PinParams ¶
type PinParams struct {
Chat string `json:"chat,omitempty" jsonschema:"Chat of the message (optional)"`
ID string `json:"id" jsonschema:"Message ID"`
Unpin bool `json:"unpin,omitempty" jsonschema:"Unpin instead of pin"`
Duration string `json:"duration,omitempty" jsonschema:"24h, 7d or 30d (default 7d)"`
}
type Poll ¶
type Poll struct {
Question string `json:"question"`
Options []PollOption `json:"options"`
Selectable int `json:"selectable"`
}
type PollCreateParams ¶
type PollCreateParams struct {
To string `json:"to" jsonschema:"Recipient chat"`
Question string `json:"question" jsonschema:"Poll question"`
Options []string `json:"options" jsonschema:"2 to 12 answer options"`
Selectable int `json:"selectable,omitempty" jsonschema:"How many options a voter may pick (default 1; 0 or more than options = any)"`
}
type PollOption ¶
type PollVoteParams ¶
type PresenceParams ¶
type PresenceParams struct {
Online bool `json:"online" jsonschema:"true = online, false = offline"`
}
type PrivacySetParams ¶
type Profile ¶
type Profile struct {
JID string `json:"jid"`
Phone string `json:"phone"`
LID string `json:"lid,omitempty"`
Name string `json:"name"`
About string `json:"about,omitempty"`
PictureURL string `json:"picture_url,omitempty"`
Business string `json:"business_name,omitempty"`
Platform string `json:"platform,omitempty"`
}
type ProfileUpdateParams ¶
type ProfileUpdateParams struct {
Name string `json:"name,omitempty" jsonschema:"New display (push) name"`
About *string `json:"about,omitempty" jsonschema:"New about text"`
Photo string `json:"photo,omitempty" jsonschema:"Path to a new profile photo"`
RemovePhoto bool `json:"remove_photo,omitempty" jsonschema:"Remove the profile photo"`
}
type ReactParams ¶
type Request ¶
type Request struct {
ID int64 `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
Meta Meta `json:"meta"`
}
Request is one line of JSON sent to the daemon socket.
type ResolveParams ¶
type ResolveParams struct {
Query string `json:"query" jsonschema:"Name, phone number or JID to resolve"`
}
type ScheduleListParams ¶
type ScheduleListParams struct {
Status string `json:"status,omitempty" jsonschema:"pending (default), sent, failed, cancelled, missed or all"`
}
type ScheduleParams ¶
type ScheduleParams struct {
SendParams
At string `json:"at,omitempty" jsonschema:"When to send: RFC3339, 'YYYY-MM-DD HH:MM', 'HH:MM', '9am', 'tomorrow 9:30am' (local time)"`
In string `json:"in,omitempty" jsonschema:"Or a delay from now, e.g. 45m, 2h, 1d"`
}
type ScheduleRef ¶
type ScheduleRef struct {
ID int64 `json:"id" jsonschema:"Scheduled message number"`
}
type Scheduled ¶
type Scheduled struct {
ID int64 `json:"id"`
Due string `json:"due"`
Status string `json:"status"`
Summary string `json:"summary"`
To string `json:"to,omitempty"`
Source string `json:"source"`
Created string `json:"created"`
SentAt string `json:"sent_at,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
type SearchParams ¶
type SearchParams struct {
Query string `json:"query" jsonschema:"Words to find; supports \"exact phrases\" and prefix*"`
Chat string `json:"chat,omitempty" jsonschema:"Limit to one chat"`
From string `json:"from,omitempty" jsonschema:"Limit to one sender"`
Type string `json:"type,omitempty" jsonschema:"Limit to a message type"`
After string `json:"after,omitempty" jsonschema:"Only after this time (RFC3339, 2h, 3d)"`
Before string `json:"before,omitempty" jsonschema:"Only before this time"`
Limit int `json:"limit,omitempty" jsonschema:"Max results (default 30)"`
}
type SendFailure ¶
type SendManyParams ¶
type SendManyParams struct {
To []string `json:"to" jsonschema:"Recipients, same formats as send"`
Text string `json:"text,omitempty" jsonschema:"Message text or caption"`
File string `json:"file,omitempty" jsonschema:"Absolute path of a file to attach"`
As string `json:"as,omitempty" jsonschema:"auto, image, video, audio, voice, document or sticker"`
Delay string `json:"delay,omitempty" jsonschema:"Pause between recipients, e.g. 3s (default 2s plus jitter)"`
}
type SendManyResult ¶
type SendManyResult struct {
Sent []SendResult `json:"sent"`
Failed []SendFailure `json:"failed,omitempty"`
}
type SendParams ¶
type SendParams struct {
To string `json:"to" jsonschema:"Recipient: phone number with country code, contact or group name, JID, or 'me' for your own chat"`
Text string `json:"text,omitempty" jsonschema:"Message text, or the caption when a file is attached"`
File string `json:"file,omitempty" jsonschema:"Absolute path of a file to attach"`
As string `json:"as,omitempty" jsonschema:"How to send the file: auto (default), image, video, gif, audio, voice, document or sticker"`
FileName string `json:"file_name,omitempty" jsonschema:"File name shown for documents"`
ReplyTo string `json:"reply_to,omitempty" jsonschema:"Message ID to quote and reply to"`
Mentions []string `json:"mentions,omitempty" jsonschema:"People to @mention (phones, names or JIDs). @<number> in the text is detected too"`
MentionAll bool `json:"mention_all,omitempty" jsonschema:"Notify every group member without adding names to the text"`
ViewOnce bool `json:"view_once,omitempty" jsonschema:"Send image, video or voice as view once"`
NoPreview bool `json:"no_preview,omitempty" jsonschema:"Skip the link preview for URLs in the text"`
Location *LocationInput `json:"location,omitempty" jsonschema:"Send a map pin instead of text"`
ContactCard *ContactInput `json:"contact,omitempty" jsonschema:"Send a contact card"`
Typing bool `json:"typing,omitempty" jsonschema:"Show typing... briefly before sending"`
}
type SendResult ¶
type StarParams ¶
type Status ¶
type Status struct {
Account string `json:"account"`
State string `json:"state"`
LoggedIn bool `json:"logged_in"`
Connected bool `json:"connected"`
JID string `json:"jid,omitempty"`
LID string `json:"lid,omitempty"`
Phone string `json:"phone,omitempty"`
PushName string `json:"push_name,omitempty"`
Platform string `json:"platform,omitempty"`
LastError string `json:"last_error,omitempty"`
ConnectedAt *time.Time `json:"connected_at,omitempty"`
DaemonPID int `json:"daemon_pid,omitempty"`
DaemonStarted *time.Time `json:"daemon_started,omitempty"`
Version string `json:"version"`
WAVersion string `json:"wa_version,omitempty"`
Messages int `json:"messages_stored"`
Chats int `json:"chats_stored"`
HistorySync string `json:"history_sync,omitempty"`
}
type StatusPostParams ¶
type StatusPostParams struct {
Text string `json:"text,omitempty" jsonschema:"Text status, or caption for a media status"`
File string `json:"file,omitempty" jsonschema:"Image or video to post"`
Background string `json:"background,omitempty" jsonschema:"Background color for text statuses, #RRGGBB"`
Font int `json:"font,omitempty" jsonschema:"Font style 0-9 for text statuses"`
}
type Transcript ¶
type TypingParams ¶
type UpdateChatParams ¶
type UpdateChatParams struct {
Chat string `json:"chat" jsonschema:"Chat to change"`
Archive *bool `json:"archive,omitempty" jsonschema:"Archive (true) or unarchive (false)"`
Pin *bool `json:"pin,omitempty" jsonschema:"Pin (true) or unpin (false)"`
Mute string `json:"mute,omitempty" jsonschema:"Mute for a duration like 8h or 7d, 'forever', or 'off' to unmute"`
Read *bool `json:"read,omitempty" jsonschema:"Mark read (true) or unread (false)"`
Disappearing string `json:"disappearing,omitempty" jsonschema:"Disappearing messages: off, 24h, 7d or 90d"`
}
type UserInfo ¶
type UserInfo struct {
JID string `json:"jid"`
Phone string `json:"phone,omitempty"`
LID string `json:"lid,omitempty"`
Name string `json:"name,omitempty"`
PushName string `json:"push_name,omitempty"`
About string `json:"about,omitempty"`
PictureID string `json:"picture_id,omitempty"`
PictureURL string `json:"picture_url,omitempty"`
Devices int `json:"devices"`
Business bool `json:"business"`
BusinessName string `json:"business_name,omitempty"`
Blocked bool `json:"blocked"`
Email string `json:"email,omitempty"`
Website []string `json:"website,omitempty"`
Address string `json:"address,omitempty"`
}
type UserRef ¶
type UserRef struct {
User string `json:"user" jsonschema:"Person: phone, contact name or JID"`
}
type WaitParams ¶
type WaitParams struct {
Chat string `json:"chat,omitempty" jsonschema:"Only messages in this chat"`
From string `json:"from,omitempty" jsonschema:"Only messages from this sender"`
Match string `json:"match,omitempty" jsonschema:"Regular expression the text must match (case-insensitive)"`
Timeout string `json:"timeout,omitempty" jsonschema:"How long to wait, e.g. 90s or 10m (default 5m)"`
IncludeFromMe bool `json:"include_from_me,omitempty" jsonschema:"Also match messages you send from other devices"`
Count int `json:"count,omitempty" jsonschema:"Return after this many matching messages (default 1)"`
}