# Delete an older version of a v2 avatar

URL: https://www.atmee.ai/docs/v2/api/reference/avatars/deleteAvatarVersion

`DELETE /v1/avatars/{avatarId}/versions/{versionId}`

Deletes every take of an older version and the files only that
version uses: its takes' sink latents and preview clips, and its
portrait, voice sample, voice clone, prime clip and bundle unless a
kept take or the current inputs still use them. Files that any kept
take or the current inputs reference are never deleted. The version
cannot be restored afterwards. The current version, and a version
holding the serving or selected take, cannot be deleted; nor can a
version whose capture is still running (retry when it ends). When
storage cannot delete the files now, the takes are still gone and
`pendingFiles` counts what is left: repeat the DELETE to retry.
Deleting the avatar deletes all of its files, every version's
included.

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `avatarId` | path | yes |  |
| `versionId` | path | yes | A `versionId` from `GET /candidates`. |

## Responses

| Status | Description | Schema |
| --- | --- | --- |
| `200` | Deleted. | `VersionDeleteResponse` |
| `401` | Missing or invalid credentials -- or a user token that is invalid, anonymous, or of a user who may act for no account (invalid_login) | none |
| `403` | insufficient_scope \| avatar_not_allowed \| account_not_allowed (a user token whose X-Account-Id names an account the user may not act for) \| v2_access_required (engine v2 is invite-only and this account has not been let in yet) | none |
| `404` | avatar_not_found \| version_not_found | none |
| `409` | not_v2_avatar \| version_in_use (the current version, or it holds the serving or selected take) \| version_busy (a capture of it is still running) \| account_ambiguous (a user token of several accounts without X-Account-Id) | none |
| `503` | engine_unavailable | none |

## `200` response fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `versionId` | string | yes |  |
| `deletedCandidateIds` | array of string | yes | The takes this request deleted (empty on a retry of files only). |
| `deletedFiles` | integer | yes | How many files were deleted from storage by this request. |
| `pendingFiles` | integer | yes | How many files could not be deleted now; repeat the DELETE to retry them. 0 when everything is gone. |
