Skip to content

Connect with Vaarto

If you build a product that sends WhatsApp messages for your customers, Connect with Vaarto replaces “go to Vaarto, create an API key, paste it here, now add a webhook…” with one button.

Your customer clicks it, signs in to Vaarto in a popup, picks their workspace and approves. Your server then receives an API key for that workspace and, if you asked for events, a webhook already pointed at your server with its signing secret.

  1. Your page calls VaartoConnect.open(). A Vaarto popup opens.
  2. The customer signs in (if they aren’t already), picks a workspace, and sees exactly what your app will get: the API permissions and where events will be sent.
  3. They click Connect. The popup hands a one-time code back to your page and closes.
  4. Your page sends the code to your server.
  5. Your server exchanges the code, with your client secret, for the API key and webhook secret. The code works once and expires after 5 minutes.

The API key never passes through a browser: only your server, holding the client secret, can turn a code into credentials.

Connect is available to approved partners. Contact us with:

We need Example Why
Product name and logo Talking Tech Shown on the consent screen
Website https://talkingtech.ai Shown on the consent screen
Allowed origins https://app.talkingtech.ai, https://*.talkingtech.ai, http://localhost:3000 Only pages on these origins can open the popup and receive the code
Webhook domains talkingtech.ai Each customer’s webhook URL must be on one of these (subdomains included)
Permissions Send messages, Read messages The scopes the customer’s API key gets
Events message.received, message.status What the webhook receives. Skip if you don’t need a webhook

You receive a client ID (vci_…, public) and a client secret (vcs_…, shown once, keep it on your server only). If the secret leaks, ask us to rotate it; existing connections keep working.

Everything runs on one script, served by Vaarto, so you always have the latest version with nothing to install or upgrade:

<script src="https://app.vaarto.com/connect.js"></script>

It adds window.VaartoConnect.open(options). Pick your stack below.

<script src="https://app.vaarto.com/connect.js"></script>
<button id="connect-vaarto">Connect WhatsApp with Vaarto</button>
<script>
document.getElementById("connect-vaarto").addEventListener("click", async () => {
try {
const { code } = await VaartoConnect.open({
clientId: "vci_your_client_id",
webhookUrl: "https://hooks.talkingtech.ai/vaarto/customer-123",
});
await fetch("/integrations/vaarto/complete", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code }),
});
} catch (error) {
console.warn("Vaarto connect did not finish:", error.code); // cancelled | closed | popup_blocked
}
});
</script>

Works the same in WordPress, PHP, Rails, Django or any server-rendered page.

Option Required Description
clientId yes Your client ID
webhookUrl if you registered events Where this customer’s events go. Must be https:// on one of your webhook domains. Put your own customer ID in the path or query so you know whose events they are
state no Any string up to 500 characters; returned unchanged. A random one is generated if you leave it out

It resolves with { code, state }. It rejects with an error whose code is:

error.code Meaning
cancelled The customer clicked Cancel
closed The popup was closed before connecting
popup_blocked The browser blocked the popup. Call open() directly from a click handler, with the script already loaded

The code is only ever posted to your page’s own origin, and only if that origin is registered, so another site can’t intercept it.

If your site sets Cross-Origin-Opener-Policy

Section titled “If your site sets Cross-Origin-Opener-Policy”

A Cross-Origin-Opener-Policy: same-origin header cuts the link between your page and the popup, so the result never arrives and connect() ends with closed. Use same-origin-allow-popups on the page with the button, or leave the header unset.

connect.js is a thin wrapper around this. To implement it yourself (a native web view, a framework without script tags):

  1. Open, from a click: https://app.vaarto.com/connect?client_id=…&origin=<your page's origin>&state=<random>&webhook_url=… (webhook_url is optional; URL-encode every value.)
  2. Listen for message events on window. Accept only those where event.origin === "https://app.vaarto.com", event.data.type === "vaarto:connect" and event.data.state equals your state.
  3. event.data.code is the code. event.data.error === "cancelled" means they cancelled. If the popup closes with no message, treat it as closed.
POST https://vaarto.com/api/v1/connect/token
Content-Type: application/json
{
"client_id": "vci_your_client_id",
"client_secret": "vcs_your_client_secret",
"code": "the code from the popup"
}
{
"connection_id": "0193f5c2-…",
"workspace": { "id": "0193a1b0-…", "name": "Acme Retail" },
"api_key": "ck_live_a1b2c3d4_Xy9…",
"scopes": ["WHATSAPP_SEND", "MESSAGES_READ"],
"webhook": {
"id": "0193f5c2-…",
"url": "https://hooks.talkingtech.ai/vaarto/customer-123",
"secret": "9f2c…",
"events": ["MESSAGE_RECEIVED", "MESSAGE_STATUS"]
}
}

webhook is null when your app has no events. This is the only time you see api_key and webhook.secret. Store both, encrypted, against your customer.

app.post("/integrations/vaarto/complete", express.json(), async (req, res) => {
const response = await fetch("https://vaarto.com/api/v1/connect/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
client_id: process.env.VAARTO_CLIENT_ID,
client_secret: process.env.VAARTO_CLIENT_SECRET,
code: req.body.code,
}),
});
if (!response.ok) return res.status(400).json({ error: "Could not connect Vaarto" });
const connection = await response.json();
await saveVaartoConnection(req.user.customerId, {
connectionId: connection.connection_id,
workspaceName: connection.workspace.name,
apiKey: connection.api_key, // encrypt at rest
webhookSecret: connection.webhook?.secret, // encrypt at rest
});
res.sendStatus(204);
});
Status Message What to do
401 Invalid client credentials Check the client ID and secret, and that your app is active
400 This code is invalid or has expired Codes last 5 minutes. Ask the customer to connect again
400 This code has already been used Each code works once. Don’t retry a successful exchange
429 Too many requests Back off and retry

The API key works exactly like one the customer created themselves:

Terminal window
curl https://vaarto.com/api/v1/messages/whatsapp \
-H "Authorization: Bearer ck_live_…" \
-H "Content-Type: application/json" \
-d '{"to":"+919876543210","text":"Hello from Talking Tech"}'

See Send a message, and verify every webhook delivery with the secret as described in Webhooks.

Connecting the same workspace to your app again replaces the earlier connection: its API key is revoked and its webhook removed the moment the new code is exchanged. Always store the latest api_key and webhook.secret; the old ones stop working.

If an exchange fails on our side, nothing is left half-made and the code stays usable, so you can retry it within its 5 minutes.

Customers see your app under Settings → Connected apps in Vaarto. Disconnecting revokes the API key and deletes the webhook immediately, so your calls start returning 401 with an invalid-key error. Treat that as “disconnected” and show the Connect button again.

The key and webhook also appear on the customer’s API keys and Webhooks pages, named after your app. Revoking either there has the same effect on that part.

  • The client secret lives only on your server, never in your frontend or repo.
  • connect.js is loaded before the click, and VaartoConnect.open() is called directly from the click with no await before it.
  • The button’s page doesn’t send Cross-Origin-Opener-Policy: same-origin.
  • Your page’s origin (and localhost while testing) is registered.
  • Each customer gets their own webhookUrl, so you can tell their events apart.
  • You store api_key and webhook.secret encrypted, and handle a 401 as a disconnect.