ScriptBase

Errors

Error codes and handling

Errors

All errors return JSON with an error field:

{ "error": "Error message here" }

Error Codes

StatusErrorWhat to do
400url query parameter is requiredAdd url param
400format must be json, srt, or textUse json, srt, or text
400Unsupported URLUse a supported platform URL
401Missing X-API-Key headerAdd X-API-Key header
401Invalid API keyCheck your key is correct and active
401API key expiredCreate a new key in the dashboard
402Insufficient creditsBuy more credits or upgrade plan
502Upstream service errorRetry — transcription service had an issue
504Transcript processing timed outRetry — video may be too long

Retry Strategy

  • 4xx errors — Fix the request, don't retry blindly
  • 402 — Buy credits, then retry
  • 502/504 — Retry with exponential backoff
async function transcribe(url: string, apiKey: string, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    const response = await fetch(
      `https://api.scriptbase.app/api/v1/transcribe?url=${encodeURIComponent(url)}`,
      { headers: { "X-API-Key": apiKey } }
    );

    if (response.ok) return response.json();

    // Don't retry client errors
    if (response.status < 500) throw new Error(await response.text());

    // Exponential backoff for server errors
    await new Promise((r) => setTimeout(r, Math.pow(2, attempt) * 1000));
  }
  throw new Error("Max retries exceeded");
}