webhookUrl. The run pauses until Importly posts the result to that URL, and you aren’t billed for compute while it waits.
This page uses @trigger.dev/sdk v4 and plain fetch.
1. Add your key
Create your key on the API key page (it is shown once). Add it asIMPORTLY_API_KEY in your Trigger.dev project’s environment variables for each environment you deploy to, and to .env for trigger dev:
.env
2. A small client
Both tasks share one helper that sends a request and turns an error response into an exception. A400 (a bad link), 401 (a wrong key) or 402 (balance too low) won’t change on a retry, so they abort the run. Anything else throws a normal error, and Trigger.dev retries the run with the task’s retry settings:
trigger/importly.ts
3. Transcribe a link
"mode": "auto" uses the video’s captions and falls back to speech-to-text when it has none. wait: true holds the request open for up to 30 seconds, so a transcript from captions usually comes back in the response. When it doesn’t, the run waits on the token until the webhook arrives:
trigger/transcribe-link.ts
data, while the status endpoint nests them under result (Webhooks), which is why the last line handles both. A caption transcript costs $0.003; speech-to-text is billed per minute, and maxCostDollars caps what one link can cost. More options are in Transcripts.
4. Download the file
POST /import returns a job ID straight away, and the file is ready when the webhook arrives:
trigger/import-link.ts
mediaUrl is valid for 7 days. To keep files, copy them to your storage in the next step of the task, or connect your bucket once and import with store: true so every file lands there (Save to your bucket).
Run it
Startnpx trigger.dev@latest dev, open the task in the dashboard and run it with:
Notes
POST /import allows 240 requests per hour per key, and an account can have 50 imports queued or running at once. A 429 throws a normal error, so Trigger.dev retries the run later. For hundreds of links, set a queue with a concurrencyLimit on the import task, and see Batch imports.
Running your own Node workers on Redis instead of Trigger.dev? The BullMQ guide does the same job with two queues and one shared rate limit.
Importly posts each result once, with no retries. The token’s timeout is the fallback: when it passes, the task reads the job from the status endpoint instead.
A youtube.com/playlist?list=… link is rejected with PLAYLIST_NOT_SUPPORTED. Trigger one run per video, for example with batchTrigger.