start-transcriptstarts the job for a signed-in user and stores its ID in atranscriptsrow.importly-webhookreceives Importly’s signed webhook and fills in the row.sweep-transcriptsruns every few minutes and finishes any row whose webhook never arrived.
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 withwhsec_) 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. Thestatus 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
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
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
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
https://, so a function served on localhost never receives it.
7. Deploy and call it
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, startPOST /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.