Skip to content

Transcribe audio

Async transcriptions and webhooks

Queue recordings up to 4 hours, poll or receive signed webhooks.

POSThttps://api.shihab.co.uk/v1/transcriptions

Create a job

Async jobs take the same inputs and query parameters as /v1/listen, for audio up to 4 hours. The request returns immediately with 202 Accepted and a job ID (tr_...). Add a webhook_url to be called when it finishes, and up to 2 KB of metadata that we echo back.

# From a URL, with a webhook and your own metadata
curl https://api.shihab.co.uk/v1/transcriptions \
  -H "Authorization: Bearer $SHIHAB_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: call-1029" \
  -d '{
    "url": "https://example.com/recordings/call-1029.mp3",
    "webhook_url": "https://example.com/hooks/shihab",
    "metadata": {"call_id": "1029"}
  }'

# Or upload the file (metadata is a JSON string in multipart)
curl "https://api.shihab.co.uk/v1/transcriptions?numerals=true" \
  -H "Authorization: Bearer $SHIHAB_API_KEY" \
  -F [email protected] \
  -F webhook_url=https://example.com/hooks/shihab \
  -F 'metadata={"course": "arabic-101"}'
202 Accepted
{
  "id": "tr_01JAB3C4D5E6F7G8H9J0K1M2N3",
  "object": "transcription_job",
  "status": "queued",
  "created": "2026-10-12T12:00:00Z",
  "completed_at": null,
  "request_id": "req_01JAB3C4D5E6F7G8H9J0K1M2N4",
  "model": "shihab-asr-v1",
  "language": "ar",
  "tags": [],
  "metadata": { "call_id": "1029" },
  "webhook_url": "https://example.com/hooks/shihab"
}

Job status

A job moves from queued to processing to completed or failed. Fetch it with GET /v1/transcriptions/{id}; a completed job carries the same fields as a sync transcription.

Terminal
curl https://api.shihab.co.uk/v1/transcriptions/tr_01JAB3C4D5E6F7G8H9J0K1M2N3 \
  -H "Authorization: Bearer $SHIHAB_API_KEY"
200 OK · completed
{
  "id": "tr_01JAB3C4D5E6F7G8H9J0K1M2N3",
  "object": "transcription_job",
  "status": "completed",
  "created": "2026-10-12T12:00:00Z",
  "completed_at": "2026-10-12T12:00:41Z",
  "request_id": "req_01JAB3C4D5E6F7G8H9J0K1M2N4",
  "model": "shihab-asr-v1",
  "model_version": "1.1.0",
  "language": "ar",
  "tags": [],
  "metadata": { "call_id": "1029" },
  "webhook_url": "https://example.com/hooks/shihab",
  "duration": 412.6,
  "transcript": "السلام عليكم، معك خدمة الزبائن...",
  "segments": [{ "id": 0, "start": 0.0, "end": 6.1, "text": "السلام عليكم، معك خدمة الزبائن." }],
  "usage": { "audio_seconds": 412.6, "billed_seconds": 413, "cost_usd": "0.0826" },
  "processing_ms": 9120
}
200 OK · failed
{
  "id": "tr_01JAB3C4D5E6F7G8H9J0K1M2N3",
  "object": "transcription_job",
  "status": "failed",
  "error": { "code": "unsupported_audio", "message": "The file could not be decoded as audio." }
}

Webhooks

When a job finishes we POST a JSON event to its webhook_url. The type is transcription.completed or transcription.failed and data is the job. Answer with any 2xx within 10 seconds. Webhook URLs must be public HTTPS addresses.

HTTP
POST /hooks/shihab HTTP/1.1
Content-Type: application/json
Shihab-Signature: t=1760270441,v1=6a3f0c...e91b

{
  "type": "transcription.completed",
  "data": {
    "id": "tr_01JAB3C4D5E6F7G8H9J0K1M2N3",
    "object": "transcription_job",
    "status": "completed",
    "transcript": "السلام عليكم، معك خدمة الزبائن...",
    "metadata": { "call_id": "1029" }
  }
}

Verify signatures

Every delivery carries Shihab-Signature: t=<unix seconds>,v1=<hex>, where v1 is the HMAC-SHA256 of "<t>.<raw body>" keyed with your organisation's webhook secret (console, Webhooks). Verify it against the raw request body before you trust the event, and reject old timestamps to stop replays.

With the SDKs:

# pip install fastapi uvicorn shihab-asr
import os

from fastapi import FastAPI, Header, HTTPException, Request, Response
from shihab_asr import WebhookVerificationError, webhooks

app = FastAPI()
SECRET = os.environ["SHIHAB_WEBHOOK_SECRET"]


@app.post("/hooks/shihab", status_code=204)
async def shihab_webhook(request: Request, shihab_signature: str = Header(None)) -> Response:
    raw = await request.body()  # the raw bytes: never re-serialize before verifying
    try:
        event = webhooks.verify(raw, shihab_signature, SECRET)
    except WebhookVerificationError:
        raise HTTPException(status_code=400) from None
    if event.type == "transcription.completed":
        print(event.data.id, event.data.transcript)
    else:
        print(event.data.id, "failed:", event.data.error)
    return Response(status_code=204)

Without an SDK:

import hashlib
import hmac
import time


def verify_signature(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
    """Shihab-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")>"""
    try:
        parts = dict(item.strip().split("=", 1) for item in header.split(","))
        timestamp, signature = parts["t"], parts["v1"]
        age = abs(time.time() - int(timestamp))
    except (KeyError, ValueError):
        return False
    if age > tolerance:  # reject replays of old deliveries
        return False
    signed = timestamp.encode() + b"." + raw_body
    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)

Retries and idempotency

  • If your endpoint does not answer 2xx within 10 seconds, we retry 6 times: after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours. Deliveries can arrive more than once: use the job id to de-duplicate.
  • Send an Idempotency-Key header on create. For 24 hours, the same key returns the same job instead of creating a new one; the same key with a different request returns 409 idempotency_conflict. The SDKs generate one for you.
  • Send a test delivery from the console (Webhooks) to check your endpoint.

List and delete

GET /v1/transcriptions?limit=20&status=completed lists your jobs, newest first; pass next_cursor as starting_after for the next page. DELETE /v1/transcriptions/{id} deletes the stored transcript text and keeps the billing record. Details in the API reference.

Need help? Email [email protected] or message us on WhatsApp.