> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heardraft.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Submit an audio or video file and retrieve a timestamped transcript using curl, TypeScript, or Python.

Follow these steps to run your first transcription through the HearDraft API.

**1. Generate a workspace API key**

Sign in to an account with an active annual plan, open **[Developers → API Keys](https://heardraft.com/app/developers/api)**, and create a new key. Store it as a server-side environment variable (`HEARDRAFT_API_KEY`).

> [!WARNING]
>
> Never embed a HearDraft API key in browser code, mobile apps, or public repositories. All API requests must originate from your backend.

**2. Submit a recording**

Send the raw audio or video bytes to `POST /api/v1/transcriptions`. Include `filename` and optional `language` (`auto` by default) in the query string, along with `Content-Type`, `Content-Length`, and a unique `Idempotency-Key`.

```bash cURL theme={null}
curl --request POST \
  'https://heardraft.com/api/v1/transcriptions?filename=interview.wav&language=auto' \
  --header "Authorization: Bearer $HEARDRAFT_API_KEY" \
  --header 'Content-Type: audio/wav' \
  --header 'Idempotency-Key: interview-2026-11-24-001' \
  --data-binary @interview.wav
```

```ts TypeScript (Node 20+) theme={null}
import { readFile } from 'node:fs/promises';

const file = await readFile('./interview.wav');
const createRes = await fetch(
  'https://heardraft.com/api/v1/transcriptions?filename=interview.wav&language=auto',
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.HEARDRAFT_API_KEY}`,
      'Content-Type': 'audio/wav',
      'Content-Length': String(file.byteLength),
      'Idempotency-Key': 'interview-2026-11-24-001',
    },
    body: file,
  },
);

if (createRes.status !== 202) {
  throw new Error(`Upload failed (${createRes.status}): ${await createRes.text()}`);
}

const task = await createRes.json();
console.log('Accepted task:', task.id, 'Location:', createRes.headers.get('location'));
```

```python Python theme={null}
import os
import time
import requests

api_key = os.environ["HEARDRAFT_API_KEY"]
with open("interview.wav", "rb") as f:
    payload = f.read()

res = requests.post(
    "https://heardraft.com/api/v1/transcriptions",
    params={"filename": "interview.wav", "language": "auto"},
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "audio/wav",
        "Content-Length": str(len(payload)),
        "Idempotency-Key": "interview-2026-11-24-001",
    },
    data=payload,
    timeout=120,
)
res.raise_for_status()
task = res.json()
print("Accepted:", task["id"], task["status"])
```

A successful upload returns HTTP **`202 Accepted`** with a `Location` header pointing to `/api/v1/transcriptions/{id}`.

**3. Poll until status is ready**

Poll `GET /api/v1/transcriptions/{id}` every 3–5 seconds while `status` is `queued` or `running`.

```bash cURL theme={null}
curl 'https://heardraft.com/api/v1/transcriptions/8b1e23fa-4c2b-4a8e-9b19-1d63df06a012' \
  --header "Authorization: Bearer $HEARDRAFT_API_KEY"
```

```ts TypeScript theme={null}
async function waitForTranscript(id: string) {
  while (true) {
    const res = await fetch(`https://heardraft.com/api/v1/transcriptions/${id}`, {
      headers: { Authorization: `Bearer ${process.env.HEARDRAFT_API_KEY}` },
    });
    const job = await res.json();
    if (job.status === 'ready') return job.result;
    if (job.status === 'failed' || job.status === 'canceled') {
      throw new Error(job.error?.message ?? `Task ended with status ${job.status}`);
    }
    await new Promise(resolve => setTimeout(resolve, 4000));
  }
}
```

```python Python theme={null}
task_id = task["id"]
while True:
    poll = requests.get(
        f"https://heardraft.com/api/v1/transcriptions/{task_id}",
        headers={"Authorization": f"Bearer {api_key}"},
        timeout=30,
    )
    poll.raise_for_status()
    body = poll.json()
    if body["status"] == "ready":
        print(body["result"]["text"])
        break
    if body["status"] in ("failed", "canceled"):
        raise RuntimeError(body.get("error"))
    time.sleep(4)
```

**4. Consume timestamped segments**

When `status` becomes `ready`, `result` contains the full `text`, `durationSeconds`, and `segments` with millisecond timing:

```json theme={null}
{
  "id": "8b1e23fa-4c2b-4a8e-9b19-1d63df06a012",
  "sourceId": "1f9c2810-79a4-4f25-8f55-c2e60ad1a4be",
  "status": "ready",
  "expiresAt": null,
  "result": {
    "text": "Welcome back everyone.\nLet's review the interview timeline before Friday.",
    "durationSeconds": 142.4,
    "segments": [
      {
        "text": "Welcome back everyone.",
        "startMs": 0,
        "endMs": 2150,
        "speaker": "Speaker 1"
      },
      {
        "text": "Let's review the interview timeline before Friday.",
        "startMs": 2400,
        "endMs": 6850,
        "speaker": "Speaker 2"
      }
    ]
  },
  "error": null
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.