Skip to main content
POST
Finalizes a streaming recording after all chunks have been uploaded. This endpoint marks the recording as complete, queues a background job to stitch audio chunks into a single file, and triggers transcription once stitching is complete.

Authentication

Requires a valid device token or API key with recordings:write scope.

Path Parameters

id
string
required
Recording ID from the initial streaming recording creation (e.g., rec_abc123xyz)

Request Body

total_chunks
integer
required
Total number of chunks uploaded (must match actual chunk count)
final_duration_ms
integer
required
Actual recording duration in milliseconds
checksum_md5
string
MD5 checksum of the complete audio (optional, for integrity verification)
content_sha256
string
SHA-256 of the complete audio bytes as a 64-character lowercase hex string (optional). When supplied, the server recomputes the SHA-256 of the assembled object after chunk stitching and marks the recording status=integrity_failure on mismatch.
trailer_base64
string
Optional base64-encoded bytes to append to the assembled audio after all chunks. Use this if your encoder writes bytes at close that were not captured in the chunk stream — for example, the final-page flush and EOS page that OGG/Opus encoders emit during fclose(). Without this, those bytes are absent from the assembled S3 object and content_sha256 verification will fail even though the audio was transmitted correctly. Max 16384 base64 characters (≈12KB raw).

Response

Returns the finalized recording status.

Response Fields

Background Processing

After calling /finalize, the following happens asynchronously: Typical Processing Times:
  • Chunk stitching: 5-30 seconds (depending on chunk count)
  • Transcription: 1-5 minutes (depending on duration)

Webhooks

You’ll receive webhooks for:
  1. recording.uploaded - Fired immediately after finalization
  2. transcription.queued - Transcription job queued
  3. transcription.completed - Transcription finished successfully
  4. transcription.failed - Transcription failed

Streaming Upload Example (Full Flow)

Step 1: Create Streaming Recording

Note: When using device tokens (dtok_*), device_id and end_user_id are automatically extracted from the token. When using API keys (sk_*), include device_id and end_user_id in the request body.
Response:

Step 2: Upload Chunks (Device)

Step 3: Finalize Recording

Response:

Step 4: Wait for Webhooks

Best Practices

Verify Chunk Count: Ensure total_chunks matches the number of chunks you actually uploaded. The backend will verify chunk existence before stitching.
Include Checksum: Provide an MD5 checksum for integrity verification, especially for critical recordings (e.g., medical, legal).
Don’t Finalize Early: Only call /finalize after all chunks are uploaded. Finalizing with missing chunks will result in an error.
Idempotency: Calling /finalize multiple times with the same parameters is safe (idempotent). Duplicate requests will return the same response without re-processing.

Troubleshooting

Problem: “Chunk count mismatch” error Solution: Check that all chunks were uploaded successfully. Use the error response to identify missing chunks.
Problem: Stitching takes too long Solution: This is normal for recordings with many chunks (>50). Check stitching job status via webhooks or polling the recording endpoint.