Skip to main content
The 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 under wacore::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.
Construct a MexRequest with MexRequest::new using those constants and a Variables value:
For operations whose Variables schema is too permissive to model exactly, pass any serde::Serialize value (for example a serde_json::json!({...})) as the variables — query and mutate are generic over V: Serialize.

Methods

query

Execute a GraphQL query.

mutate

Execute a GraphQL mutation.
Example — mutation with typed variables:
Example — loosely-typed variables with 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.
WhatsApp Web issues this request at app launch. It refreshes the cap on a TTL (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 from wacore::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’s NAME and DOC_ID with its variables.

MexResponse

Response from a GraphQL operation.
Methods:
  • has_data()true if the response contains data.
  • has_errors()true if the response contains errors.
  • fatal_error() — the first fatal error (any error with an error_code), if any.

MexGraphQLError

Methods:
  • error_code() — the numeric error code, if present.
  • is_summary()true when the error is marked as a summary.
  • has_error_code()true when 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 cycle
  • cycle_start_timestamp / cycle_end_timestamp / server_sent_timestamp — Unix seconds. The cap lifts once cycle_end_timestamp passes.
Methods:
  • remaining_quota() -> Option<u64> — saturating subtraction of used_quota from total_quota, when both are present; returns Some(0) when used_quota exceeds total_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 an error_code are non-fatal and surface in response.errors alongside any partial data.

Decode the typed response

Generated operation modules also expose a Response 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.