Skip to main content
If your app runs on Supabase (Lovable and Bolt apps often do), a video transcript is the feature that breaks once it ships: the code that worked in the preview gets blocked from a server, and many videos have no captions to read. Edge Functions can’t run a downloader binary anyway. Send the link to Importly instead and save what comes back in your database. This recipe is three functions and one table:
  • start-transcript starts the job for a signed-in user and stores its ID in a transcripts row.
  • importly-webhook receives Importly’s signed webhook and fills in the row.
  • sweep-transcripts runs every few minutes and finishes any row whose webhook never arrived.
Your frontend reads the row with the normal Supabase client, so it never sees your Importly key. For a simpler start without a table or webhook, see Lovable, Bolt & Replit.

1. Add your keys as secrets

Create your key on the API key page (it is shown once), and copy the Webhook signing secret (it starts with whsec_) from the same page. Store both as Edge Function secrets:
SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are already available inside every Edge Function, so you don’t set those. For supabase functions serve, put the two Importly values in supabase/functions/.env and keep that file out of git.

2. The table

Run this in the SQL editor or add it as a migration. Signed-in users can read their own rows; only the functions (with the service role key) write them.

3. Shared helper

Both the webhook and the sweep save a job the same way: they read it from the status endpoint with your key and update its row. The status in (queued, running) filter makes a second delivery, or the sweep finding a job the webhook already saved, do nothing.
supabase/functions/_shared/importly.ts

4. Start the job

The frontend calls this function with the user’s session (Supabase checks the JWT before the function runs). "mode": "auto" uses the video’s captions and falls back to speech-to-text when there are none, and webhookUrl points at the next function.
supabase/functions/start-transcript/index.ts
A rejected request (a bad link, a key problem, or a low balance) comes back with its HTTP status, an error and a code, and no row is written. See Error handling.

5. Receive the webhook

Importly can’t send a Supabase JWT, so turn off the JWT check for this one function. The signature check below is what keeps other callers out.
supabase/config.toml
Deno has Web Crypto built in, and crypto.subtle.verify compares the signature in constant time. The handler takes only the jobId from the payload and reads the result from the API with your key:
supabase/functions/importly-webhook/index.ts
A job that fails later, for example because the video is private, is saved with status: 'failed' and its error_code and error_message. Right after you rotate the signing secret, Importly sends two v1 signatures for 24 hours, and this check accepts either. See Webhooks.

6. Catch missed webhooks

Each job gets one webhook delivery and no retries. This function checks rows that have been pending for more than five minutes:
supabase/functions/sweep-transcripts/index.ts
Run it every five minutes with Supabase Cron. It also covers local development: the webhook URL must be public https://, so a function served on localhost never receives it.

7. Deploy and call it

From your app, start a transcript and read the row back:
segments holds the same transcript with start and end times in seconds, for captions, chapters or search.

Downloading the file instead

For the video or audio file itself, start POST /import the same way and save mediaUrl from GET /import/status in the helper. That link is valid for 7 days, so store the file if your app needs it longer: with store: true, each import is copied to your own S3 or R2 bucket (recipe). Set includeVideo: false for audio only. See Downloads.
A transcript from captions costs $0.003. Speech-to-text for a video without captions is $0.01 per minute, and maxCostDollars stops a long one before it’s charged. Try it free, no card required. See Pricing & credits.

Let your agent write it

Using Claude Code, Cursor or Lovable’s chat on this project? Connect the MCP server and ask it to add transcripts with Importly: it reads the same integration guide and can test with a real link first. See Build with your agent.