# Clone a voice

> POST https://api.nabrah.ai/api/ext/tts/clone_voice

Group: Text to speech. Page: https://www.nabrah.ai/en/docs/api-reference/text-to-speech/clone-a-voice

Clone a voice from an uploaded audio sample. This is a multipart/form-data upload that starts a background cloning job and returns immediately with a `voice_id`. The voice is not usable right away — it becomes available once its `is_ready` flag turns `true`. Poll GET /api/ext/tts/voices or GET /api/ext/tts/voices/{voice_id} to check readiness before using the new voice for TTS or agents.

## Multipart form fields

Send the request as multipart/form-data (not JSON).

- **file**: The audio sample to clone, uploaded as a WAV file.
- **name**: A human-readable display name for the new voice.

## Response & next steps

On success the endpoint returns the cloning job result.

- **voice_id**: The id of the newly created private voice. Use this to poll for readiness and, once ready, as the `voice` field in TTS generation.
- **success / message**: Status flag and human-readable message describing the outcome of starting the cloning job. Fields: `success`, `message`.

Cloning runs in the background. The new voice will report `is_ready: false` until processing completes — poll GET /api/ext/tts/voices/{voice_id} until it is `true`.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Body (multipart/form-data)

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "success": false,
  "message": "string",
  "voice_id": "string"
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request POST \
  --url 'https://api.nabrah.ai/api/ext/tts/clone_voice' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/tts/clone_voice"
headers = {"X-API-Key": "<your-api-key>"}

response = requests.post(url, headers=headers)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const form = new FormData();

const response = await fetch("https://api.nabrah.ai/api/ext/tts/clone_voice", {
  method: "POST",
  headers: { "X-API-Key": "<your-api-key>" },
  body: form,
});

const data = await response.json();
console.log(data);
```

### Go

```go
// Send multipart/form-data with mime/multipart:
// POST https://api.nabrah.ai/api/ext/tts/clone_voice
```
