The Status feature provides APIs for posting text, image, and video status updates, reacting to statuses (e.g. the “like” heart), and revoking previously sent statuses.
Access
Access status operations through the client:
let status = client.status();
Methods
send_text
Send a text status update with background color and font style.
pub async fn send_text(
&self,
text: &str,
background_argb: u32,
font: i32,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error>
Parameters:
text - Status text content
background_argb - Background color as ARGB (e.g., 0xFF1E6E4F)
font - Font style index (0-4)
recipients - Slice of recipient JIDs
options - Privacy and delivery options
Returns:
SendResult containing the message_id and to JID. Use result.message_key() to get a wa::MessageKey for revocation or other follow-up operations.
Example:
use whatsapp_rust::{Jid, StatusSendOptions};
let recipients = [
Jid::pn("15551234567"),
Jid::pn("15559876543"),
];
let result = client.status()
.send_text(
"Hello from Rust!",
0xFF1E6E4F, // Green background
0, // Default font
&recipients,
StatusSendOptions::default(),
)
.await?;
println!("Status sent: {}", result.message_id);
send_image
Send an image status update.
pub async fn send_image(
&self,
upload: UploadResponse,
thumbnail: Vec<u8>,
caption: Option<&str>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error>
Parameters:
upload - Upload response from client.upload() (takes ownership)
thumbnail - JPEG thumbnail bytes
caption - Optional caption text
recipients - Slice of recipient JIDs
options - Privacy options
Example:
use wacore::download::MediaType;
// Upload the image first
let image_data = std::fs::read("photo.jpg")?;
let upload = client.upload(image_data, MediaType::Image, Default::default()).await?;
// Create thumbnail (simplified - use proper JPEG encoding)
let thumbnail = create_thumbnail(&image_data)?;
let result = client.status()
.send_image(
upload,
thumbnail,
Some("Check this out!"),
&[Jid::pn("15551234567")],
StatusSendOptions::default(),
)
.await?;
send_video
Send a video status update.
pub async fn send_video(
&self,
upload: UploadResponse,
thumbnail: Vec<u8>,
duration_seconds: u32,
caption: Option<&str>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error>
Parameters:
upload - Upload response from client.upload() (takes ownership)
thumbnail - JPEG thumbnail bytes
duration_seconds - Video duration
caption - Optional caption text
recipients - Slice of recipient JIDs
options - Privacy options
Example:
use wacore::download::MediaType;
let video_data = std::fs::read("video.mp4")?;
let upload = client.upload(video_data, MediaType::Video, Default::default()).await?;
let thumbnail = extract_video_thumbnail(&video_data)?;
let result = client.status()
.send_video(
upload,
thumbnail,
30, // 30 seconds
None,
&[Jid::pn("15551234567")],
StatusSendOptions::default(),
)
.await?;
send_raw
Send a custom message type as a status update.
pub async fn send_raw(
&self,
message: wa::Message,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error>
Example:
use waproto::whatsapp as wa;
let message = wa::Message {
extended_text_message: Some(Box::new(wa::message::ExtendedTextMessage {
text: Some("Custom message".to_string()),
..Default::default()
})),
..Default::default()
};
let result = client.status()
.send_raw(message, recipients, StatusSendOptions::default())
.await?;
revoke
Delete a previously sent status update.
pub async fn revoke(
&self,
message_id: impl Into<String>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error>
Parameters:
message_id - ID of the status to revoke
recipients - Same recipients the status was sent to
options - Privacy options
Example:
// Send a status
let result = client.status()
.send_text("Temporary status", 0xFF000000, 0, &recipients, Default::default())
.await?;
// Later, revoke it
client.status()
.revoke(&result.message_id, &recipients, Default::default())
.await?;
send_reaction
React to someone’s status update (e.g. the “like” heart on WhatsApp). Pass an empty string to remove a previous reaction.
pub async fn send_reaction(
&self,
status_owner: &Jid,
server_id: u64,
reaction: &str,
) -> Result<(), anyhow::Error>
Parameters:
status_owner - JID of the person whose status you are reacting to
server_id - Server-assigned ID of the status message
reaction - Emoji to send (e.g. "💚"). Pass "" to remove the reaction
Example:
// React to a status with a heart emoji
client.status()
.send_reaction(
&Jid::pn("15551234567"),
1234567890,
"💚",
)
.await?;
// Remove a previous reaction
client.status()
.send_reaction(
&Jid::pn("15551234567"),
1234567890,
"",
)
.await?;
The server_id is the server-assigned numeric ID of the status message, not the client-generated message ID. You can obtain it from the status message event payload.
Types
StatusPrivacySetting
Privacy setting for status delivery.
#[non_exhaustive]
pub enum StatusPrivacySetting {
/// Send to all contacts in address book (default)
Contacts,
/// Send only to contacts in an allow list
AllowList,
/// Send to all contacts except those in a deny list
DenyList,
}
StatusPrivacySetting is #[non_exhaustive], so match statements should include a wildcard arm to handle future variants.
StatusSendOptions
Options for sending status updates.
pub struct StatusSendOptions {
/// Privacy setting for this status
pub privacy: StatusPrivacySetting,
}
Example:
use whatsapp_rust::{StatusSendOptions, StatusPrivacySetting};
// Send to all contacts
let options = StatusSendOptions::default();
// Send to allow list only
let options = StatusSendOptions {
privacy: StatusPrivacySetting::AllowList,
};
Font styles
WhatsApp Web supports 5 font styles (0-4):
| Index | Style |
|---|
| 0 | Default (sans-serif) |
| 1 | Serif |
| 2 | Typewriter (monospace) |
| 3 | Bold script |
| 4 | Condensed |
Background colors
Background colors use ARGB format (0xAARRGGBB):
// Solid green
let green = 0xFF1E6E4F_u32;
// Solid blue
let blue = 0xFF1A73E8_u32;
// Solid red
let red = 0xFFD93025_u32;
// Semi-transparent black
let overlay = 0x80000000_u32;
Recipient management
Recipients should be JIDs of users who can see the status. You can pass any &[Jid] — an array literal, a slice of a Vec, or a fixed-size array:
// Single recipient (array literal)
let recipients = &[Jid::pn("15551234567")];
// Multiple recipients
let recipients = &[
Jid::pn("15551234567"),
Jid::pn("15559876543"),
"15557654321@s.whatsapp.net".parse()?,
];
// From an existing Vec
let jids = vec![Jid::pn("15551234567")];
let recipients = &jids;
The recipients list should match your privacy settings. When revoking a status, use the same recipients list that was used when posting.
Phash validation
After sending a status update, the library validates the participant hash (phash) from the server’s acknowledgment against the locally computed value. On mismatch, the sender key device cache is invalidated so the next status send re-fetches current device lists. This runs in the background and does not affect the send result. See Signal Protocol — Phash validation for details.