WABridges
INSTALL PROVISION PAIR SEND RECEIVE
Full API Docs

PYTHON 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
pip install requests flask
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.).

PYTHON
import os
import requests

API_KEY = os.environ['WA_API_KEY']
BASE    = 'https://wabridges.com/api'
HEADERS = {'Authorization': f'Bearer {API_KEY}'}

def provision(customer_ref, webhook_url):
    r = requests.post(f'{BASE}/instances', json={
        'customer_ref': customer_ref,
        'webhook_url':  webhook_url,
    }, headers=HEADERS)
    r.raise_for_status()
    return r.json()  # { 'id', 'customer_ref', 'state' }

bridge = provision('user-123', 'https://yourbackend.com/hook')
print(bridge)
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.

PYTHON
def pair(customer_ref, phone):
    r = requests.post(
        f'{BASE}/instances/{customer_ref}/proxy/pair',
        json={'phone': phone},
        headers=HEADERS
    )
    r.raise_for_status()
    return r.json()['code']  # "ABCD-EFGH"

code = pair('user-123', '15550001234')
print(f'Enter this code on the phone: {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

PYTHON
def send_text(customer_ref, to, body):
    r = requests.post(
        f'{BASE}/instances/{customer_ref}/proxy/send/text',
        json={'chat': to, 'body': body},
        headers=HEADERS
    )
    r.raise_for_status()
    return r.json()  # { 'message_id', 'timestamp' }

send_text('user-123', '15559876543', 'Hello from the API!')
RESPONSE
{"message_id": "ACE41E...", "timestamp": 1777180605}

5. RECEIVE EVENTS

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

PYTHON
from flask import Flask, request
import threading

app = Flask(__name__)

def handle(payload):
    if payload.get('event') == 'message' and not payload.get('from_me'):
        print(f"{payload['name']}: {payload['body']}")

@app.route('/hook', methods=['POST'])
def webhook():
    payload = request.get_json()
    threading.Thread(target=handle, args=(payload,)).start()
    return '', 200

See the webhook guide for all event types and fields.