WABridges
INSTALL PROVISION PAIR SEND RECEIVE
Full API Docs

RUST QUICKSTART

Send your first WhatsApp message in under 5 minutes. You need a WA Bridges API key - get one from the dashboard.

1. INSTALL

SHELL
cargo add reqwest --features blocking,json && cargo add serde_json
ENV
export WA_API_KEY="sk_..."

2. PROVISION A BRIDGE

One bridge = one WhatsApp number. customer_ref is your internal identifier (user ID, slug, etc.).

RUST
use reqwest::blocking::Client;
use serde_json::{json, Value};
use std::env;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = env::var("WA_API_KEY")?;
    let client  = Client::new();

    let bridge: Value = client
        .post("https://wabridges.com/api/instances")
        .bearer_auth(&api_key)
        .json(&json!({
            "customer_ref": "user-123",
            "webhook_url":  "https://yourbackend.com/hook",
        }))
        .send()?
        .json()?;

    println!("{}", bridge);
    Ok(())
}
RESPONSE
{"id": 42, "customer_ref": "user-123", "state": "running"}

3. PAIR A PHONE

Request a pairing code. Open WhatsApp on the phone, go to Linked Devices → Link a device → Link with phone number, then enter the code.

RUST
let result: Value = client
    .post("https://wabridges.com/api/instances/user-123/proxy/pair")
    .bearer_auth(&api_key)
    .json(&json!({ "phone": "15550001234" }))
    .send()?
    .json()?;

println!("Enter this code on the phone: {}", result["code"]);
RESPONSE
{"code": "ABCD-EFGH"}

Once paired, the bridge fires a connected webhook event. Poll /proxy/status or wait for the event.

4. SEND A MESSAGE

RUST
let msg: Value = client
    .post("https://wabridges.com/api/instances/user-123/proxy/send/text")
    .bearer_auth(&api_key)
    .json(&json!({ "chat": "15559876543", "body": "Hello from the API!" }))
    .send()?
    .json()?;

println!("{}", msg["message_id"]);
RESPONSE
{"message_id": "ACE41E...", "timestamp": 1777180605}

5. RECEIVE EVENTS

Inbound messages and events are delivered via POST to your webhook_url. Return 200 immediately.

RUST
// Cargo.toml: cargo add axum tokio --features tokio/full && cargo add serde_json
use axum::{extract::Json, routing::post, Router};
use serde_json::Value;

async fn hook(Json(payload): Json<Value>) -> &'static str {
    if payload["event"] == "message" && payload["from_me"] != true {
        println!("{}: {}", payload["name"], payload["body"]);
    }
    ""
}

#[tokio::main]
async fn main() {
    let app = Router::new().route("/hook", post(hook));
    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

See the webhook guide for all event types and fields.