convex/ folder:
schema.tsadds atranscriptstable.importly.tshas thestartaction your app calls, the internal functions that save a finished job once, and thegetquery your app reads.http.tsreceives Importly’s signed webhook.crons.tsfinishes any job whose webhook never arrived.
useQuery, so it never sees your Importly key, and the page updates on its own when the transcript is saved. Tested with convex 1.51 and convex-test against a mocked API, plus a live call with a bad key.
1. Add your keys
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. Set both on your deployment:
--prod for your production deployment. CONVEX_SITE_URL, which the webhook URL is built from, is set by Convex for you.
2. The table
convex/schema.ts
transcripts table to it.
3. Start a transcript and save the result
convex/importly.ts
start: "mode": "auto" uses the video’s captions and falls back to speech-to-text when there are none, and webhookUrl points at the HTTP action below. A rejected request (a bad link, a key problem, or a low balance) throws a ConvexError with Importly’s code and message, and nothing is saved. See Error handling. The Promise<Id<'transcripts'>> return type is there because the action returns the result of runMutation: without it, TypeScript can’t infer the type.
saveJob and finish: the webhook and the sweep both read the job from the status endpoint with your key, then save it in a mutation that only updates a transcript still queued or running. A second delivery, or the sweep finding a job the webhook already saved, does nothing.
Sign-in: the action and the query use ctx.auth, so they work with Convex Auth, Clerk or any other auth provider you’ve set up in Convex.
4. Receive the webhook
convex/http.ts
node:crypto. It reads the raw body with request.text(), because the signature covers the exact bytes Importly sent. Right after you rotate the signing secret, Importly sends two v1 signatures for 24 hours, and this check accepts either. See Webhooks.
The handler takes only the jobId from the payload, schedules saveJob and answers 200 straight away. saveJob reads the result from the API with your key, so a forged request can’t put data into your app.
5. Sweep up missed webhooks
convex/crons.ts
https://, so a local deployment never receives it, while a cloud dev deployment does.
6. Call it from your app
segments holds the same transcript with start and end times in seconds, for captions, chapters or search. A job that fails later, for example because the video is private, is saved with status: 'failed' and its errorCode and errorMessage.
Downloading the file instead
For the video or audio file itself, startPOST /import the same way and save mediaUrl from GET /import/status in saveJob. 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.