# Batch transcription

Send a recording, or its address, and collect its text with words, times and speakers when it is done.

> **When batch opens on your workspace.** Batch transcription is not open on every workspace yet. When `GET /v1/models` lists a model whose `mode` is `batch`, your workspace can use it. Until then, a request answers `400` `unsupported_model`. Live audio works already: [Real-time transcription](https://platform.vatis.tech/docs/realtime).

## Transcribe a file

`POST /v1/speech-to-text`

Starts the transcription of an audio or video file and answers at once with its transcript, queued. The body is `multipart/form-data`.

Send the file as `file`, and the options as form fields next to it. `metadata` is any JSON object of your own, returned unchanged with the transcript. The request is answered at once, and the file is transcribed in the background: ask for the transcript by its id until it is done, as here, or have it posted to your server ([Webhooks](https://platform.vatis.tech/docs/batch/webhooks)).

```bash
# 1. Send the file: the answer comes at once, with the transcript queued
curl -sS -H "Authorization: Bearer $VATIS_KEY" https://api.eu.vatis.tech/v1/speech-to-text \
  -F model_id=vatis_ro_v9 -F diarize=true -F metadata='{"case": "2026-118"}' -F file=@speech.wav

# 2. Ask every 2 seconds while it is queued or processing (-o keeps the last answer in a file)
ID=tr_3b41a7db9aba52c0   # the "id" of the first answer
while sleep 2; do
  curl -sS -H "Authorization: Bearer $VATIS_KEY" -o transcript.json https://api.eu.vatis.tech/v1/transcripts/$ID
  grep -qE '"status": ?"(queued|processing)"' transcript.json || break
done
cat transcript.json
```

```javascript
// A file to text with speakers: node transcribe.mjs speech.wav
import { openAsBlob } from "node:fs";
import { basename } from "node:path";
import { setTimeout as sleep } from "node:timers/promises";

const base = "https://api.eu.vatis.tech";
const headers = { Authorization: `Bearer ${process.env.VATIS_KEY}` };

// The answer's JSON, or the error on one line and exit
async function answer(response) {
  const body = await response.json();
  if (!response.ok) {
    console.error(`${response.status} ${body.error.code}: ${body.error.message}`);
    process.exit(1);
  }
  return body;
}

// 1. Send the file: the answer comes at once, with the transcript queued
const form = new FormData();
form.append("model_id", "vatis_ro_v9");
form.append("diarize", "true");
form.append("metadata", JSON.stringify({ case: "2026-118" })); // returned unchanged with the transcript
form.append("file", await openAsBlob(process.argv[2]), basename(process.argv[2]));
let transcript = await answer(await fetch(`${base}/v1/speech-to-text`, { method: "POST", headers, body: form }));
console.log(`queued ${transcript.id}`);

// 2. Ask every 2 seconds until it is completed or failed
while (transcript.status === "queued" || transcript.status === "processing") {
  await sleep(2000);
  transcript = await answer(await fetch(`${base}/v1/transcripts/${transcript.id}`, { headers }));
}
if (transcript.status === "failed") {
  console.error(`failed: ${transcript.error.code}: ${transcript.error.message}`);
  process.exit(1);
}
for (const segment of transcript.segments) console.log(`${segment.speaker}: ${segment.text}`);
```

```go
// A file to text with speakers: go run transcribe.go speech.wav
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
	"path/filepath"
	"time"
)

const base = "https://api.eu.vatis.tech"

// Transcript holds what this code reads of the answers.
type Transcript struct {
	ID       string
	Status   string
	Segments []struct{ Speaker, Text string }
	Error    struct{ Code, Message string }
}

// answer sends the request with the key: the answer's JSON,
// or the error on one line and exit.
func answer(request *http.Request) Transcript {
	request.Header.Set("Authorization", "Bearer "+os.Getenv("VATIS_KEY"))
	response, err := http.DefaultClient.Do(request)
	check(err)
	defer response.Body.Close()
	var body Transcript
	check(json.NewDecoder(response.Body).Decode(&body))
	if response.StatusCode >= 400 {
		e := body.Error
		check(fmt.Errorf("%d %s: %s", response.StatusCode, e.Code, e.Message))
	}
	return body
}

func main() {
	// 1. Send the file: the answer comes at once, with the transcript queued
	var body bytes.Buffer
	form := multipart.NewWriter(&body)
	check(form.WriteField("model_id", "vatis_ro_v9"))
	check(form.WriteField("diarize", "true"))
	// returned unchanged with the transcript
	check(form.WriteField("metadata", `{"case": "2026-118"}`))
	audio, err := os.Open(os.Args[1])
	check(err)
	defer audio.Close()
	part, err := form.CreateFormFile("file", filepath.Base(os.Args[1]))
	check(err)
	_, err = io.Copy(part, audio)
	check(err)
	check(form.Close())
	request, err := http.NewRequest("POST", base+"/v1/speech-to-text", &body)
	check(err)
	request.Header.Set("Content-Type", form.FormDataContentType())
	transcript := answer(request)
	fmt.Println("queued", transcript.ID)

	// 2. Ask every 2 seconds until it is completed or failed
	for transcript.Status == "queued" || transcript.Status == "processing" {
		time.Sleep(2 * time.Second)
		request, err = http.NewRequest("GET", base+"/v1/transcripts/"+transcript.ID, nil)
		check(err)
		transcript = answer(request)
	}
	if transcript.Status == "failed" {
		e := transcript.Error
		check(fmt.Errorf("failed: %s: %s", e.Code, e.Message))
	}
	for _, segment := range transcript.Segments {
		fmt.Printf("%s: %s\n", segment.Speaker, segment.Text)
	}
}

// check stops the program on an error.
func check(err error) {
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}
```

```python
"""A file to text with speakers: python3 transcribe.py speech.wav"""
import json
import os
import sys
import time

import httpx

client = httpx.Client(base_url="https://api.eu.vatis.tech", timeout=600,
                      headers={"Authorization": f"Bearer {os.environ['VATIS_KEY']}"})

def answer(response):
    """The answer's JSON, or the error on one line and exit."""
    body = response.json()
    if response.is_error:
        sys.exit(f"{response.status_code} {body['error']['code']}: {body['error']['message']}")
    return body

# 1. Send the file: the answer comes at once, with the transcript queued
data = {
    "model_id": "vatis_ro_v9",
    "diarize": "true",
    "metadata": json.dumps({"case": "2026-118"}),  # returned unchanged with the transcript
}
with open(sys.argv[1], "rb") as audio:
    transcript = answer(client.post("/v1/speech-to-text", data=data, files={"file": audio}))
print(f"queued {transcript['id']}")

# 2. Ask every 2 seconds until it is completed or failed
while transcript["status"] in ("queued", "processing"):
    time.sleep(2)
    transcript = answer(client.get(f"/v1/transcripts/{transcript['id']}"))
if transcript["status"] == "failed":
    sys.exit(f"failed: {transcript['error']['code']}: {transcript['error']['message']}")
for segment in transcript["segments"]:
    print(f"{segment['speaker']}: {segment['text']}")
```

```java
// A file to text with speakers: java Transcribe.java speech.wav
import java.io.ByteArrayOutputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.charset.StandardCharsets.UTF_8;

public class Transcribe {
    static final String base = "https://api.eu.vatis.tech";
    static final String boundary = "vatis" + System.nanoTime();
    static final HttpClient client = HttpClient.newHttpClient();

    // Sends the request with the key: the answer's JSON,
    // or the error on one line and exit
    static String answer(HttpRequest.Builder request) throws Exception {
        request.header("Authorization", "Bearer " + System.getenv("VATIS_KEY"));
        HttpResponse<String> response =
            client.send(request.build(), HttpResponse.BodyHandlers.ofString());
        String body = response.body();
        if (response.statusCode() >= 400) {
            System.err.println(response.statusCode() + " " + field(body, "code") + ": "
                + field(body, "message"));
            System.exit(1);
        }
        return body;
    }

    public static void main(String[] args) throws Exception {
        // 1. Send the file: the answer comes at once, with the transcript queued
        Path audio = Path.of(args[0]);
        ByteArrayOutputStream form = new ByteArrayOutputStream();
        addPart(form, "name=\"model_id\"", "vatis_ro_v9".getBytes(UTF_8));
        addPart(form, "name=\"diarize\"", "true".getBytes(UTF_8));
        // returned unchanged with the transcript
        addPart(form, "name=\"metadata\"", "{\"case\": \"2026-118\"}".getBytes(UTF_8));
        addPart(form, "name=\"file\"; filename=\"" + audio.getFileName() + "\"",
            Files.readAllBytes(audio));
        form.write(("--" + boundary + "--\r\n").getBytes(UTF_8));
        URI start = URI.create(base + "/v1/speech-to-text");
        String transcript = answer(HttpRequest.newBuilder(start)
            .header("Content-Type", "multipart/form-data; boundary=" + boundary)
            .POST(HttpRequest.BodyPublishers.ofByteArray(form.toByteArray())));
        String id = field(transcript, "id");
        System.out.println("queued " + id);

        // 2. Ask every 2 seconds until it is completed or failed
        String status = field(transcript, "status");
        while (status.equals("queued") || status.equals("processing")) {
            Thread.sleep(2000);
            URI poll = URI.create(base + "/v1/transcripts/" + id);
            transcript = answer(HttpRequest.newBuilder(poll));
            status = field(transcript, "status");
        }
        if (status.equals("failed")) {
            System.err.println("failed: " + field(transcript, "code") + ": "
                + field(transcript, "message"));
            System.exit(1);
        }
        for (String segment : segments(transcript)) {
            System.out.println(field(segment, "speaker") + ": " + field(segment, "text"));
        }
    }

    // Adds one part to the form: Java has no multipart body built in.
    static void addPart(ByteArrayOutputStream form, String disposition,
            byte[] value) throws Exception {
        String head = "--" + boundary + "\r\n"
            + "Content-Disposition: form-data; " + disposition + "\r\n\r\n";
        form.write(head.getBytes(UTF_8));
        form.write(value);
        form.write("\r\n".getBytes(UTF_8));
    }

    // Reads a text field of the JSON: Java has no JSON parser built in,
    // a real program would use a library.
    static String field(String json, String name) {
        String value = "\"" + name + "\":\\s*\"((?:[^\"\\\\]++|\\\\.)*+)\"";
        Matcher match = Pattern.compile(value).matcher(json);
        if (!match.find()) {
            return null;
        }
        Pattern escaped = Pattern.compile("\\\\(u....|.)");
        return escaped.matcher(match.group(1)).replaceAll((escape) -> {
            String code = escape.group(1);
            if (code.equals("n")) {
                return "\n";
            }
            if (code.length() > 1) {
                int number = Integer.parseInt(code.substring(1), 16);
                code = String.valueOf((char) number);
            }
            return Matcher.quoteReplacement(code);
        });
    }

    // The transcript's segments, each as its JSON text: a segment holds no
    // object or list, so a match that skips over strings finds its end.
    static List<String> segments(String json) {
        String object = "\\{(?:[^{}\"]++|\"(?:[^\"\\\\]++|\\\\.)*+\")*+\\}";
        Matcher match = Pattern.compile("\\s*,?\\s*(" + object + ")").matcher(json);
        List<String> found = new ArrayList<>();
        int key = json.indexOf("\"segments\":");
        int at = json.indexOf('[', key) + 1;
        while (key >= 0 && match.region(at, json.length()).lookingAt()) {
            found.add(match.group(1));
            at = match.end();
        }
        return found;
    }
}
```

```csharp
// A file to text with speakers: dotnet run --project transcribe -- speech.wav
// Put this in transcribe/Program.cs, after: dotnet new console -o transcribe
using System.Net.Http.Headers;
using System.Text.Json;

using var http = new HttpClient
{
    BaseAddress = new Uri("https://api.eu.vatis.tech"),
    Timeout = TimeSpan.FromMinutes(10),
};
var apiKey = Environment.GetEnvironmentVariable("VATIS_KEY");
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", apiKey);

// 1. Send the file: the answer comes at once, with the transcript queued
using var form = new MultipartFormDataContent();
form.Add(new StringContent("vatis_ro_v9"), "model_id");
form.Add(new StringContent("true"), "diarize");
// returned unchanged with the transcript
form.Add(new StringContent("""{"case": "2026-118"}"""), "metadata");
using var audio = File.OpenRead(args[0]);
form.Add(new StreamContent(audio), "file", Path.GetFileName(args[0]));
var transcript = await Answer(await http.PostAsync("/v1/speech-to-text", form));
var id = transcript.GetProperty("id").GetString();
Console.WriteLine($"queued {id}");

// 2. Ask every 2 seconds until it is completed or failed
while (transcript.GetProperty("status").GetString() is "queued" or "processing")
{
    await Task.Delay(2000);
    transcript = await Answer(await http.GetAsync($"/v1/transcripts/{id}"));
}
if (transcript.GetProperty("status").GetString() == "failed")
{
    var error = transcript.GetProperty("error");
    var code = error.GetProperty("code");
    Console.Error.WriteLine($"failed: {code}: {error.GetProperty("message")}");
    return 1;
}
foreach (var segment in transcript.GetProperty("segments").EnumerateArray())
{
    var speaker = segment.GetProperty("speaker");
    Console.WriteLine($"{speaker}: {segment.GetProperty("text")}");
}
return 0;

// The answer's JSON, or the error on one line and exit
static async Task<JsonElement> Answer(HttpResponseMessage response)
{
    var text = await response.Content.ReadAsStringAsync();
    var body = JsonDocument.Parse(text).RootElement;
    if (!response.IsSuccessStatusCode)
    {
        var error = body.GetProperty("error");
        var code = error.GetProperty("code");
        var message = error.GetProperty("message");
        Console.Error.WriteLine($"{(int)response.StatusCode} {code}: {message}");
        Environment.Exit(1);
    }
    return body;
}
```

**Expected result:** `202` at once, with the transcript queued ([The first answer](https://platform.vatis.tech/docs/batch/send-now-collect-later#the-first-answer)):

```json
{"id": "tr_3b41a7db9aba52c0", "status": "queued", "created_at": "2026-11-12T09:14:03Z"}
```

Then, a few seconds later for a few minutes of audio, the transcript, `completed` (trimmed here: a real one has every word). Every field: [The transcript object](https://platform.vatis.tech/docs/transcript-object).

```json
{
  "id": "tr_3b41a7db9aba52c0",
  "status": "completed",
  "model_id": "vatis_ro_v9",
  "language_code": "ro",
  "created_at": "2026-11-12T09:14:03Z",
  "completed_at": "2026-11-12T09:14:05Z",
  "duration_s": 5.62,
  "processing_s": 1.41,
  "metadata": {"case": "2026-118"},
  "text": "Bună ziua, luați loc. Am venit pentru contractul din 12 martie.",
  "words": [
    {"text": "Bună", "start": 0.12, "end": 0.4, "confidence": 0.98, "speaker": "speaker_0"},
    ...
  ],
  "segments": [
    {"speaker": "speaker_0", "start": 0.12, "end": 1.7, "text": "Bună ziua, luați loc."},
    {"speaker": "speaker_1", "start": 2.48, "end": 5.1, "text": "Am venit pentru contractul din 12 martie."}
  ],
  "speakers": ["speaker_0", "speaker_1"]
}
```

- Keep the `id`: the transcript is kept for 7 days after its job ends, to read, export or delete ([Manage transcripts](https://platform.vatis.tech/docs/batch/manage-transcripts)). The uploaded audio is deleted 1 day after.
- A request the API refuses answers at once with the error, for example `400` `invalid_parameter`, and `param` names the field.
- A transcription that fails ends `failed`, with its `error`, for example `invalid_audio`. The failed transcript stays readable by its id.

## In this guide

- [Send now, collect later](https://platform.vatis.tech/docs/batch/send-now-collect-later): Every request is answered at once with the transcript queued: collect it when it is done, by asking for it or by having it posted to you.
- [Webhooks](https://platform.vatis.tech/docs/batch/webhooks): Get a finished transcript posted to your server, signed so you know it came from us.
- [Parameters](https://platform.vatis.tech/docs/batch/parameters): The form fields a request takes and the rules they follow, its headers, and files sent by their address.
- [Idempotency](https://platform.vatis.tech/docs/batch/idempotency): Send a request again safely after a timeout: the same Idempotency-Key gets the first answer, and no second job starts.
- [Manage transcripts](https://platform.vatis.tech/docs/batch/manage-transcripts): Read, list and delete your transcripts, who can read which, and how long they are kept.
- [Exports](https://platform.vatis.tech/docs/batch/exports): Download a finished transcript as plain text or as SRT or WebVTT subtitles, with speaker names.
- [Request errors](https://platform.vatis.tech/docs/batch/request-errors): The errors a transcription request can get, and what to do about each.

## Next steps

- [The transcript object](https://platform.vatis.tech/docs/transcript-object): every field, the speakers and the segments.
- [Real-time transcription](https://platform.vatis.tech/docs/realtime): live audio, with the text back as it is spoken.
