Mex feature wraps WhatsApp’s Meta Exchange (MEX) GraphQL API. Operations are persisted: you reference each query or mutation by a (name, id) pair pulled from a generated operation module, and pass its typed Variables. WhatsApp Web bundle updates rotate the numeric id, so the human-readable name keeps diagnostics stable across releases.
Access
Building a request
Each persisted operation lives in its own module underwacore::iq::mex_operations. Every module exposes:
NAME— the operation name (e.g."WAWebJoinNewsletterMutation").DOC_ID— the current persisted document ID.OPERATION_KIND—"query"or"mutation".Variables— a typed struct matching the operation’s input shape.Response— a typed struct matching the operation’s output shape.
MexRequest with MexRequest::new using those constants and a Variables value:
Methods
query
Execute a GraphQL query.mutate
Execute a GraphQL mutation.serde_json:
fetch_new_chat_message_capping_info
Fetch the cap on how many new one-on-one conversations you can start in the current cycle.wa_individual_new_chat_msg_capping_fetch_ttl_seconds, 1 hour), gated on wa_individual_new_chat_msg_capping_enabled. If the cap doesn’t apply to your account, you still get an answer — the status just reports NONE.
Example:
Types
MexDoc
A persisted-query descriptor. Re-exported fromwacore::iq::mex.
MexRequest
A persisted-query descriptor plus its typed variables.V is the variables type — usually the generated Variables struct for an operation, but any Serialize value works.
new
Pair an operation’sNAME and DOC_ID with its variables.
MexResponse
Response from a GraphQL operation.has_data()—trueif the response contains data.has_errors()—trueif the response contains errors.fatal_error()— the first fatal error (any error with anerror_code), if any.
MexGraphQLError
error_code()— the numeric error code, if present.is_summary()—truewhen the error is marked as a summary.has_error_code()—truewhen an error code is set.
MexGraphQLError is re-exported from the crate root as whatsapp_rust::MexGraphQLError, alongside MexError, MexErrorExtensions, MexRequest, and MexResponse.MexErrorExtensions
NewChatMessageCapping
How many new one-on-one conversations you can still start in the current cycle, and why. Every field is optional — the server omits any that don’t apply to your account’s tier.total_quota/used_quota— new chats allowed / already started this cyclecycle_start_timestamp/cycle_end_timestamp/server_sent_timestamp— Unix seconds. The cap lifts oncecycle_end_timestamppasses.
remaining_quota() -> Option<u64>— saturating subtraction ofused_quotafromtotal_quota, when both are present; returnsSome(0)whenused_quotaexceedstotal_quota
CappingStatus
Where you stand against the cap.CappingOteStatus
Whether you’re eligible for the one-time extension that lifts the cap for a cycle.CappingMvStatus
Your Meta Verified subscription state, which lifts the cap permanently.NewChatMessageCapping, CappingStatus, CappingOteStatus, and CappingMvStatus are re-exported from the crate root, alongside the other Mex types.Error handling
query and mutate automatically convert any fatal GraphQL error (any error with an error_code) into MexError::ExtensionError so you can match on it without inspecting response.errors yourself.
Response handling
Check for data
Handle non-fatal errors
Errors without anerror_code are non-fatal and surface in response.errors alongside any partial data.
Decode the typed response
Generated operation modules also expose aResponse struct that mirrors the GraphQL schema. Decode it from response.data with serde_json:
The persisted
DOC_ID for each operation is regenerated from the latest WhatsApp Web bundle. Pin to a specific crate version if you need a stable wire format.