# Voice routes: clone, retire

URL: /code/api/voice/verbs · Id: `page:code/api/voice/verbs`

> The Voice Verbs clone, retire as api.sb routes, with inputs, result, refusals and an example.

Reference for [Voice](/business/nouns/voice), one group of [Voice routes](/code/api/voice).

### Voice.clone
Clone trains a Voice from a real speaker’s recordings after the speaker records Consent in that same voice. [Verb page](/business/nouns/voice/clone?interface=api).

```text
POST /{namespace}/voices/clone
```

Body, as JSON: the inputs. Emits [`Voice.cloned`](/business/events/Voice.cloned).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `speaker` | [Person](/business/nouns/person) | Yes | The person whose voice it is. |
| `samples` | list of [File](/business/nouns/file) | Yes | Recordings of the speaker. |
| `consent` | [Consent](/business/nouns/consent) | Yes | The speaker’s Consent, spoken in the voice being cloned. |
| `scope` | `string` | Yes | Who may speak in it. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `voice` | [Voice](/business/nouns/voice) | Yes | The Voice, `training` until the upstream finishes. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The Consent is missing, withdrawn, or not spoken by the speaker | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/voices/clone \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"speaker":"person_sLqbXbW683","samples":["file_V1AuhyCTsH"],"consent":"consent_lMkrg7nUGY","scope":"studio"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "voice": {
    "$id": "https://api.sb/leaseline.app/voices/voice_s6Qb8KW683",
    "$type": "Voice",
    "origin": "cloned",
    "scope": "studio",
    "status": "training"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Voice.clone",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Voice.retire
Retire deletes a Voice’s trained copy at the upstream and refuses new speech in it, keeping the record and every File made. [Verb page](/business/nouns/voice/retire?interface=api).

```text
POST /{namespace}/voices/{voice}/retire
```

Path: `voice`. Body, as JSON: the other inputs. Emits [`Voice.retired`](/business/events/Voice.retired).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `voice` | [Voice](/business/nouns/voice) | Yes | The Voice to retire. |
| `reason` | `text` | No | Why, such as Consent withdrawn. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `voice` | [Voice](/business/nouns/voice) | Yes | The Voice, now `retired`. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/voices/voice_s6Qb8KW683/retire \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "voice": {
    "$id": "https://api.sb/leaseline.app/voices/voice_s6Qb8KW683",
    "$type": "Voice",
    "origin": "cloned",
    "scope": "studio",
    "status": "training"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Voice.retire",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```