> This page is for API Reference.

> Sarvam Voice Agents (Samvaad) is a voice AI agent platform for Indian languages: build, test and deploy AI calling agents on your own phone numbers, from ₹3 a minute. Start here: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt. For a section index, append `/llms.txt` to any section URL (for example https://docs.sarvam.ai/voice-agents/llms.txt).
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Detect Watermark

POST https://api.sarvam.ai/voices/watermark/detect
Content-Type: multipart/form-data

**Beta.** Detects whether an audio clip carries the Sarvam STFT watermark embedded by Instant Voice Cloning generation.

Upload a clip produced by `POST /voices/clone` (or stream / WebSocket) to check whether Sarvam generated it. Clips shorter than about 5 seconds usually return `inconclusive` — there is not enough signal to be confident.

Accepts `multipart/form-data` with a single `file` upload.

**Base URL:** `https://api.sarvam.ai`.
**Auth:** send your key in the `api-subscription-key` header.

**Limits:** max file size 10 MB; analysis is capped at 120 seconds of audio. Rate limited to 5 requests per minute.

**Billing:** free — this endpoint consumes no credits.

Reference: https://docs.sarvam.ai/api-reference/voice-cloning/detect-watermark

## Authentication

- `api-subscription-key` header (required) — API Key authentication via header

## Request

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required) — Audio clip to analyse. Supported formats include WAV, MP3, FLAC, OGG, M4A, and WebM. Max file size 10 MB. Analysis uses at most the first 120 seconds.

## Response

### 200

Detection completed.

- `status` (string, required) — `success`
- `data` (Sarvam_Model_API_WatermarkDetectData, required)

## Errors

### 400 Bad Request Error

Bad Request. Unsupported audio format, empty file, or file over 10 MB.

- `error` (Sarvam_Model_API_ErrorDetails, required) — Error details

### 401 Unauthorized Error

Unauthorized. The `api-subscription-key` header is missing or invalid.

- `error` (Sarvam_Model_API_ErrorDetails, required) — Error details

### 429 Too Many Requests Error

Too Many Requests. Default rate limit is 5 requests per minute.

- `error` (Sarvam_Model_API_ErrorDetails, required) — Error details

### 500 Internal Server Error

Internal Server Error. Watermark detection failed or is unavailable.

- `error` (Sarvam_Model_API_ErrorDetails, required) — Error details

## Types

### Sarvam_Model_API_WatermarkDetectData

- `verdict` (enum, required) — `watermarked` — the clip carries the Sarvam Instant Voice Cloning watermark. `not_detected` — no watermark found (or it was destroyed by heavy processing). `inconclusive` — usually a clip shorter than about 5 seconds; not enough signal to decide.
  - Allowed values: `watermarked`, `not_detected`, `inconclusive`
- `z_score` (double, required) — Strength of the watermark pattern. Values above about 3.5 typically yield `watermarked`.
- `n_pairs_scored` (integer, required) — Number of frequency pairs scored by the detector.
- `analysed_seconds` (double, required) — Seconds of audio analysed (capped at 120).
- `algorithm_version` (string, required) — Watermark algorithm version, e.g. `stft-patch-qim-v3`.
- `inconclusive` (boolean, required) — `true` when the clip is too short (or otherwise underpowered) to produce a confident verdict.
- `probability` (double, optional, nullable) — Calibrated detection probability. Currently `null` until Platt parameters are fit on a labelled corpus.
- `p_value` (double, optional, nullable) — Probability that this z-score occurred by chance. Lower values mean higher confidence.

### Sarvam_Model_API_ErrorDetails

- `request_id` (string, required, nullable)
- `message` (string, required) — Message describing the error
- `code` (enum, required) — Error code for the specific error that has occurred. Refer to the error code documentation for more details.
  - Allowed values: `invalid_request_error`, `internal_server_error`, `unprocessable_entity_error`, `insufficient_quota_error`, `invalid_api_key_error`, `authentication_error`, `not_found_error`, `rate_limit_exceeded_error`, `model_call_error`, `gateway_timeout_error`, `billing_service_unavailable_error`

## Examples

**Request**

```json
{
  "file": "<file: string>"
}
```

**Response**

```json
{
  "status": "success",
  "data": {
    "verdict": "watermarked",
    "z_score": 9.12,
    "n_pairs_scored": 420,
    "analysed_seconds": 7,
    "algorithm_version": "stft-patch-qim-v3",
    "inconclusive": false,
    "probability": null,
    "p_value": 1e-10
  }
}
```

**SDK Code**

```typescript voiceCloning_detectWatermark_example
import { SarvamAIClient } from "sarvamai";

const client = new SarvamAIClient({
  apiSubscriptionKey: process.env.SARVAM_API_KEY,
});

// Pass contentType explicitly: a bare stream is sent as
// application/octet-stream and the API rejects it with a 400.
const response = await client.voiceCloning.detectWatermark({
  file: { path: "clip.wav", contentType: "audio/wav" },
});

// Envelope: { status, data: { verdict, z_score, ... } }
console.log(response.data.verdict);
console.log(response.data.z_score, response.data.analysed_seconds);

```

```python voiceCloning_detectWatermark_example
from sarvamai import SarvamAI

client = SarvamAI(
    api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
with open("clip.wav", "rb") as f:
    response = client.voice_cloning.detect_watermark(file=f)
# Envelope: status + data(verdict, z_score, analysed_seconds, ...)
print(response.data.verdict)
print(response.data.z_score, response.data.analysed_seconds)

```

```go voiceCloning_detectWatermark_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sarvam.ai/voices/watermark/detect"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api-subscription-key", "<apiSubscriptionKey>")
	req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby voiceCloning_detectWatermark_example
require 'uri'
require 'net/http'

url = URI("https://api.sarvam.ai/voices/watermark/detect")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-subscription-key"] = '<apiSubscriptionKey>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n"

response = http.request(request)
puts response.read_body
```

```java voiceCloning_detectWatermark_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.sarvam.ai/voices/watermark/detect")
  .header("api-subscription-key", "<apiSubscriptionKey>")
  .header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")
  .asString();
```

```php voiceCloning_detectWatermark_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.sarvam.ai/voices/watermark/detect', [
  'multipart' => [
    [
        'name' => 'file',
        'filename' => 'string',
        'contents' => null
    ]
  ]
  'headers' => [
    'api-subscription-key' => '<apiSubscriptionKey>',
  ],
]);

echo $response->getBody();
```

```csharp voiceCloning_detectWatermark_example
using RestSharp;

var client = new RestClient("https://api.sarvam.ai/voices/watermark/detect");
var request = new RestRequest(Method.POST);
request.AddHeader("api-subscription-key", "<apiSubscriptionKey>");
request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift voiceCloning_detectWatermark_example
import Foundation

let headers = [
  "api-subscription-key": "<apiSubscriptionKey>",
  "Content-Type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
  [
    "name": "file",
    "fileName": "string"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sarvam.ai/voices/watermark/detect")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```