RelayWA

ENTERPRISE INTEGRATION

Connect every client from your application.

Use your enterprise API key on your backend. Map each client to a stable externalClientId, create their session, and return a short-lived pairing URL to your frontend. All sessions belong to your enterprise account.

1. Create a client session

The same external client ID returns the existing session, so repeated setup does not create duplicates.

2. Issue a pairing embed

Choose an exact approved website origin. The pairing URL lasts 10 minutes and can read/connect only this session.

3. Show QR in your site

Your client scans the QR without leaving your website. Receive connection status from the embed.

Server integration · Node.js

Your own backend must authenticate the client before calling this function. Derive the client ID from that authenticated record; never accept another client’s ID or a website origin directly from an untrusted request.

const BASE = 'https://api.relaywa.com/api/v1/b2b';

const KEY = process.env.RELAYWA_ENTERPRISE_KEY;



async function relaywa(path, body) {

  const res = await fetch(BASE + path, {

    method: 'POST',

    headers: {

      Authorization: 'Bearer ' + KEY,

      'Content-Type': 'application/json'

    },

    body: JSON.stringify(body)

  });

  if (!res.ok) throw new Error(await res.text());

  return res.json();

}



// authorizedClient is loaded after YOUR app verifies client access.

async function pairingFor(authorizedClient) {

  const session = await relaywa('/sessions', {

    externalClientId: String(authorizedClient.id),

    name: authorizedClient.companyName

  });

  await relaywa('/sessions/' + session.id + '/connect', {});

  return relaywa('/sessions/' + session.id + '/embed', {

    origin: authorizedClient.approvedWebsiteOrigin

  });

}

// Return { embedUrl, expiresInSeconds, sessionId } to your frontend.

// Keep KEY on your backend. Never include it in HTML or browser JavaScript.

Embed the QR pairing page

Create the iframe using the embedUrl returned by your backend. Add your own site and client sites in the partner portal or through PATCH /domains first. The iframe is restricted to the chosen origin.

const pairing = await fetch('/your-api/whatsapp/pairing').then(r => r.json());

const frame = document.createElement('iframe');

frame.src = pairing.embedUrl;

frame.title = 'Connect your WhatsApp number';

frame.width = '100%';

frame.height = '560';

frame.style.border = '0';

document.getElementById('whatsapp-pairing').replaceChildren(frame);



window.addEventListener('message', event => {

  if (event.origin !== 'https://relaywa.com') return;

  if (event.source !== frame.contentWindow) return;

  if (event.data?.type === 'relaywa.session.status') {

    console.log(event.data.sessionId, event.data.status);

  }

});

The embed posts status updates only to its approved parent origin. It automatically refreshes the QR while the link is valid. Request a new pairing URL from your backend after expiry. Customize iframe width/height to fit your page.

API reference

Base URL: https://api.relaywa.com/api/v1/b2b. Every endpoint below requires Authorization: Bearer YOUR_ENTERPRISE_KEY. API keys are scoped to one enterprise organization.

MethodEndpointPurpose
GET/accountDomain, approved origins, billing period and unlimited-session entitlement
GET / PATCH/domainsRead/update approved client origins: { allowedOrigins: ["https://client.example"] }
GET/sessionsList your company’s sessions and external client IDs
POST/sessionsCreate or reuse: { externalClientId, name, phoneHint? }
GET/sessions/:idSession state and connection information
GET/sessions/:id/qrQR dataUrl and expiresAt; available=false while waiting
POST/sessions/:id/connectQueue connection or pairing
POST/sessions/:id/restartRequest reconnect
POST/sessions/:id/disconnectLog out the linked WhatsApp account
POST/sessions/:id/embedCreate a 10-minute URL: { origin: "https://client.example" }
POST/sessions/:id/messagesSend text: { to, text, clientMessageId }
GET/sessions/:id/credentialsGet the linked session’s messaging API key after connection
PATCH/sessions/:idUpdate name or phoneHint
DELETE/sessions/:idRemove a pending/logged-out session with no operation in progress
GET/sessions/:id/logsRecent connection events
GET / POST/webhooksList/create signed webhook endpoints; { name, url, eventTypes }

401: missing, revoked or expired credentials. 403: inactive enterprise subscription or unapproved embed origin. 404: session unavailable to this account. 409: conflicting name or operation. Connection commands run asynchronously; poll the session status or use signed webhooks.

Billing and control

$100 monthly or $1,000 annually for unlimited sessions. Contact support@relaywa.com to onboard, renew, or change the company domain. Manage approved client website origins yourself through the portal or API. You can create and revoke server keys in the partner portal. RelayWA administrators manage activation after confirmed payment.

Session limits are unlimited. WhatsApp account conditions, message pacing, and the existing messaging safety controls still apply.