Batch transcription
Queue up to 50 recordings in one job, poll or wait for it, and get a signed webhook when it finishes.
A batch transcription job takes up to 50 files in one request and transcribes them in the background with the same models and options as file transcription. You get the job id back immediately (202 Accepted), then poll it, wait for it, or let a webhook tell you when it's done. Each file becomes its own transcript, with its own id and charge.
from wistfareai import WistfareAI
client = WistfareAI() # reads WISTFARE_API_KEY
job = client.speech_to_text.jobs.create(
files=["calls/0915.mp3", "calls/0932.mp3", "calls/1004.mp3"],
model="wistfare-stt-v3-beta",
language="auto",
key_terms=["MTN MoMo", "Irembo"],
webhook_url="https://example.com/hooks/wistfare", # optional
)
print(job.id, job.status) # sttjob_… queued
# Store job.webhook_secret now: it's returned only once and signs every delivery.
job = client.speech_to_text.jobs.wait(job.id, poll_interval=5) # or rely on the webhook
for item in job.items:
if item.status == "succeeded":
transcript = client.speech_to_text.transcriptions.get(item.transcription_id)
print(item.name, item.cost_cents, transcript.text[:80])
else:
print(item.name, item.status, item.error)When to use a job
- Many recordings at once: call archives, interview collections, nightly imports.
- Nobody is waiting on one file: you'd rather hand over the whole set and be told when it's done.
- Fire and forget: the webhook means no polling loop to keep alive.
For one recording where someone is waiting, POST /v1/stt returns the transcript in the response.
Options
A job takes the same options as POST /v1/stt, applied to every file, with the same defaults (wistfare-stt-v3-beta, language=auto): model, language, timestamps, diarize (speaker labels), and on v3 boost (key terms), enhanced and punctuation. See the request reference.
| Limit | Value |
|---|---|
| Files per job | 1 to 50 |
| Total upload | 1 GB per job |
| Each file | 128 MB and 30 minutes, like POST /v1/stt |
| Active jobs | 1 per account by default; another job while one is queued or running gets 429 concurrency_limit (raisable on request) |
Send an Idempotency-Key header so a retried upload can't create the job twice.
Every file is checked when you create the job: one that's empty, unreadable or too long fails the whole request with that file's name in the error message, before anything is queued.
Job lifecycle
| Job status | Meaning |
|---|---|
queued | Accepted; no file has started yet. |
running | Files are being transcribed (a few at a time). |
completed | Every file succeeded. |
partial | Some files succeeded and some failed. |
failed | No file succeeded. Nothing was charged. |
canceled | You canceled the job before every file finished. |
Each file (an item) is queued, running, succeeded, failed or canceled. A succeeded item has a transcription_id; fetch the full transcript with GET /v1/stt/transcriptions/{id}. A failed item carries an error with a code and message.
Canceling stops the files that haven't started and releases their held credits at once. Files already being transcribed finish and are charged.
Billing
- One credit check for the whole job. When you create a job, the cost of every file is worked out and held from your balance. If it doesn't fit your available balance or budget, you get
402 insufficient_credits(orbudget_exceeded) and nothing is queued. - Charged per file, on success. Each file is charged like a
POST /v1/sttrequest ($0.006 per minute with v3, $0.012 with v1 or v2, minimum 2¢ per file) when its transcript is saved. Failed and canceled files are never charged, and whatever is left of the hold is released when the job finishes. See holds. totals.cost_centsandtotals.audio_secondsadd up the succeeded files.
Webhooks
Pass a public HTTPS webhook_url when you create the job. When the job reaches a final status (completed, partial, failed or canceled), Wistfare sends one POST to it:
POST /hooks/wistfare HTTP/1.1
Content-Type: application/json
User-Agent: Wistfare-Webhooks/1.0
Wistfare-Signature: t=1791712800,v1=5f0c3b8e1d7a2c4b9e6f8a0d3c5b7e9f1a2c4d6e8f0b1a3c5d7e9f2b4c6d8e0a
{"type":"stt.job.completed","job":{"id":"sttjob_k3n8q2x7d1v9m4b6c0zt","status":"completed", … }}The body's job is exactly what GET /v1/stt/jobs/{id} returns. Delivery is at least once. Respond with any 2xx status within 10 seconds. Anything else, a timeout or a connection error is retried three times, after about 5, 20 and 80 seconds. Redirects aren't followed.
Verify the signature
The create response includes a webhook_secret (whsec_…), shown once. Every delivery is signed with it:
Wistfare-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(webhook_secret, "<t>.<raw body>")>Verify against the raw request body, before parsing JSON. The SDKs do it in one call: they check the HMAC in constant time, reject timestamps more than five minutes old, and return the parsed event.
import json
from fastapi import FastAPI, HTTPException, Request
from wistfareai import WebhookVerificationError, verify_webhook
app = FastAPI()
webhook_secrets: dict[str, str] = {} # job id -> webhook_secret, saved when you created the job
@app.post("/hooks/wistfare")
async def wistfare_webhook(request: Request):
raw = await request.body()
job_id = json.loads(raw)["job"]["id"] # only to find the secret; trust nothing until verified
try:
event = verify_webhook(raw, request.headers.get("Wistfare-Signature"), webhook_secrets[job_id])
except (KeyError, WebhookVerificationError):
raise HTTPException(400, "invalid signature")
job = event["job"]
# Handle it idempotently, keyed on job["id"]: the same job may be delivered more than once.
print(job["id"], job["status"], job["totals"]["cost_cents"])
return {"ok": True}Each job has its own secret, so the handler reads job.id from the body only to look the secret up, then verifies before trusting anything else. To verify without an SDK, see the signature algorithm.
Keep the secret per job
Each job has its own webhook_secret. Store it with the job id when you create the job; it's never shown again. Webhook URLs must be public https:// addresses: private, loopback and local hosts are refused with 400 invalid_webhook_url.