Backend and database

Integrate WhatsApp with Supabase

Supabase is an open source backend platform built on PostgreSQL. It delivers a relational database, authentication, file storage, automatic REST and GraphQL APIs, realtime and Edge Functions, which are serverless functions in Deno with a timeout of about 60 seconds. It is the common choice for those who want to spin up a complete backend without managing servers, using real SQL and triggers in the database itself to react to data events.

Why connect

Whoever uses Supabase keeps everything in Postgres: sign-ups, orders, appointments, payment status. The problem is notifying the customer on WhatsApp when something changes. By connecting Supabase to ZapZap API, you send the message from inside your own backend. A concrete example: when a row enters the orders table with status confirmed, a database trigger calls an Edge Function that sends the confirmation to the customer's WhatsApp right away. No checking a spreadsheet or pasting numbers by hand. Since ZapZap API uses managed instances with community warm-up and an anti-ban layer, you lower the risk of the account being taken down in automatic sending, and you also have AI per instance to handle customer replies without leaving the flow.

Step by step

  1. 1

    Get your keys from ZapZap API

    In the ZapZap API dashboard, activate a number (R$15/month, prepaid, with a welcome credit when you create the account, subject to the current campaign) and copy the instance's x-api-key and x-api-secret. Keep the API base: https://api.zapzapapi.com. The exact fields of each route are in the docs at https://api.zapzapapi.com/llms.txt.

  2. 2

    Create an Edge Function in Supabase

    In the Supabase dashboard, go to Edge Functions and click Deploy a new function, or run in the terminal: supabase functions new send-whatsapp. This generates the index.ts file in supabase/functions/send-whatsapp/ written in Deno/TypeScript.

  3. 3

    Store the keys as Secrets

    In Edge Functions, Secrets tab (or via CLI: supabase secrets set ZAPZAP_KEY=... ZAPZAP_SECRET=...). Never leave x-api-key and x-api-secret in the code. Inside the function, read them with Deno.env.get('ZAPZAP_KEY').

  4. 4

    Make the fetch to ZapZap API inside the function

    In index.ts, use Deno's native fetch to call https://api.zapzapapi.com with the x-api-key and x-api-secret headers, sending number and text in the body. Deploy with supabase functions deploy send-whatsapp. Check the route and the exact field names at https://api.zapzapapi.com/llms.txt.

  5. 5

    Trigger it from a database trigger

    In Database, create a SQL function and an AFTER INSERT trigger on your table. Use the pg_net extension (supabase_functions.http_request) or the net.http_post wrapper to call your Edge Function's URL whenever a new row comes in. That way WhatsApp goes out automatically on every new record in Postgres.

Example

// Edge Function (Deno) on Supabase: supabase/functions/send-whatsapp/index.ts
// ILLUSTRATIVE example. Check the route and exact fields at https://api.zapzapapi.com/llms.txt

Deno.serve(async (req) => {
  const { number, text } = await req.json();

  const resp = await fetch("https://api.zapzapapi.com/api/v1/{instanceId}/send/text", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": Deno.env.get("ZAPZAP_KEY")!,
      "x-api-secret": Deno.env.get("ZAPZAP_SECRET")!,
    },
    body: JSON.stringify({ number, text }),
  });

  return new Response(await resp.text(), { status: resp.status });
});

Illustrative. The exact fields and endpoints are in the documentation.

Frequently asked questions

Do I need the official WhatsApp API to use it with Supabase?

No. ZapZap API works with managed WhatsApp instances, so you do not need to go through official API approval or set up templates. Just activate a number and use your x-api-key and x-api-secret inside the Edge Function.

Can I send WhatsApp straight from a Postgres trigger?

Yes. You create an AFTER INSERT or AFTER UPDATE trigger that calls an Edge Function via pg_net (net.http_post), and that function does the fetch to ZapZap API. The sending happens at the same moment the data changes in the database.

Does the 60s Edge Function timeout get in the way of sending?

Not for a simple send, which responds in a few seconds. If you need to send many messages at once, break them into batches or use a queue with pg_cron calling the function at intervals, so you do not hit the Edge Function limit.

How do I receive customer replies in Supabase?

ZapZap API sends webhooks per event. Point the incoming message webhook to another public Supabase Edge Function, which writes the reply to a Postgres table. The events and the payload format are documented at https://api.zapzapapi.com/llms.txt.

Can sending automatic messages from Supabase get my number banned?

Every automatic send carries risk. ZapZap API uses community warm-up and an anti-ban layer to lower the risk, but avoid high volume all at once, personalize the messages and respect intervals between sends.

Start now

Create your account, connect a number in minutes and test the API with warm-up and anti-ban. R$15 per active number/month, prepaid, no lock-in.