To complete this guide, you will need the following:

1. Create a Supabase Function

To create a Supabase Edge Function you must run the following command locally:

supabase functions new zbd-send

This will create a /supabase/functions/zbd-send folder structure in your project.

2. Write the Edge Function

Use the code below as a starting point for your handler function. You will need to replace the ZBD_API_KEY with your own ZBD Project’s API key.

import { serve } from ""

const ZBD_API_KEY = "b7Ya3s2JZKZcXXX2Dqf8wjKTZZZRuWr8";

const zbdSend = async (_request: Request): Promise<Response> => {
  const res = await fetch("", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "apikey": `${ZBD_API_KEY}`,
    body: JSON.stringify({
      lnAddress: '', // Who is the recipient of the payment?
      amount: '100000', // 100 satoshis (100,000 msats) -- ~$0.03
      comment: 'Money at internet speed', // What is this payment for?

  const data = await res.json();

  return new Response(JSON.stringify(data), {
    status: 200,
    headers: {
      "Content-Type": "application/json",


3. Send payment locally

In order to successfully send payments through the API, you must have an active balance in the ZBD Project you are using. Learn more about depositing funds into a ZBD Project wallet.

If you do not have funds in the ZBD Project you are using, you will receive a 4xx error from the API stating insufficient funds.

To run this Supabase Edge Function locally you can spin up your Supabase instance using the following command. You may already have this running at this stage.

supabase functions start

Then you can run the following command to start your serverless function:

supabase functions serve zbd-send --no-verify-jwt

Note that we add the --no-verify-jwt flag to the command to disable JWT verification. This is because we are not passing a JWT token to the function when we call it. This is not recommended for production use.

Supabase CLI will output a HTTP URL endpoint that you can use to test your function by issuing a POST request to that resource.

4. Deploying to Supabase Edge

After testing it locally, you can deploy your function to Supabase Edge using the following command. You will need to enter your Supabase project ID to deploy.

supabase functions deploy zbd-send

Once you deploy you will receive a URL that you can use to view that function in production on Supabase’s Web Dashboard:

Supabase Edge Functions dashboard

Opening your browser (or another HTTP client) to the URL provided by Supabase: should return a JSON response with the payment sent message.

You can also test this using curl command:


You’re looking for the status of completed to know that the payment settled successfully.

Payments in the Lightning Network are asynchronous so you may see a response stating the payment is processing. This is expected — use the callbackUrl property to receive updates about your payments.

5. Try it yourself

You can now begin sending instant Bitcoin payments on the edge with Supabase + ZBD!