> ## Documentation Index
> Fetch the complete documentation index at: https://speshu.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Удалить файл

> DELETE /api/v1/storage/{id} — удаление файла из хранилища

Удаляет файл из хранилища. Объект удаляется, запись помечается удалённой, и файл сразу пропадает из списка.

## Пример

<CodeGroup>
  ```bash cURL theme={null} theme={null}
  curl -X DELETE https://speshu.ai/api/v1/storage/0199abc-... \
    -H "Authorization: Bearer $SPESHU_API_KEY"
  ```

  ```python Python theme={null} theme={null}
  import requests

  response = requests.delete(
      "https://speshu.ai/api/v1/storage/0199abc-...",
      headers={"Authorization": "Bearer sk-ваш-ключ"},
  )

  print(response.json())  # {"success": true, "asset_id": "0199abc-..."}
  ```
</CodeGroup>

## Ответ

`200 OK`:

```json theme={null} theme={null}
{ "success": true, "asset_id": "0199abc-..." }
```

| Поле | Тип | Описание |
| - | - | - |
| `success` | boolean | Всегда `true` при успехе |
| `asset_id` | string | Идентификатор удалённого файла |

## Что происходит после удаления

* `GET /api/v1/storage/{id}` по этому идентификатору начинает отдавать `404`.
* Файл исчезает из выдачи `GET /api/v1/storage`.
* Ссылка `url` перестаёт отдавать содержимое.

<Warning>
  Отменить удаление нельзя. Отдельного маршрута восстановления у хранилища на `/api/v1` нет — если нужна страховка, держите копию файла у себя.
</Warning>

## Чужие файлы

<Warning>
  Файл, принадлежащий другому пользователю, возвращает `404`, а не `403`. По коду ответа нельзя определить, что идентификатор существует, но принадлежит другому владельцу.
</Warning>

## Ошибки

| Код | Причина |
| - | - |
| `401` | Ключ не передан или недействителен |
| `404` | Файл не найден, уже удалён или принадлежит другому пользователю |
| `500` | Внутренняя ошибка |

<Info>
  Формат тела ошибки такой же, как у остальных эндпоинтов хранилища: `{"error": {"message": "...", "type": "invalid_request"}}` — без полей `param` и `code`, которые есть у OpenAI-формата. Подробности — на странице [Ошибки](/docs/errors).
</Info>

## Что дальше

<CardGroup cols={2}>
  <Card title="Список файлов" icon="list" href="/docs/api-reference/storage/list">
    Проверить, что файл исчез
  </Card>

  <Card title="Загрузить файл" icon="upload" href="/docs/api-reference/storage/upload">
    Загрузить файл заново
  </Card>

  <Card title="Метаданные файла" icon="magnifying-glass" href="/docs/api-reference/storage/get">
    Один файл по идентификатору
  </Card>

  <Card title="Ошибки" icon="triangle-exclamation" href="/docs/errors">
    Полная таблица кодов
  </Card>
</CardGroup>


## OpenAPI

````yaml api-reference/openapi.json DELETE /api/v1/storage/{id}
openapi: 3.1.0
info:
  title: SpeShu.AI API
  version: 1.0.0
  description: >-
    Единый OpenAI-совместимый API для текстовых моделей, генерации изображений,
    видео, аудио и музыки.


    ## Аутентификация


    Все запросы, кроме `GET /api/v1/models` и `GET /api/v1/media/models`,
    требуют API-ключ. Ключ передаётся в заголовке `Authorization: Bearer <ключ>`
    или `X-Api-Key: <ключ>`.


    ## Ошибки


    Текстовые эндпоинты (`/chat/completions`, `/responses`, `/messages`) и
    `/balance` возвращают ошибки в формате OpenAI:


    ```json

    { "error": { "message": "...", "type": "invalid_request_error", "param":
    null, "code": "invalid_request" } }

    ```


    Эндпоинты медиа используют собственный конверт:


    ```json

    { "code": 422, "msg": "...", "data": null }

    ```


    Подробности — на странице [Ошибки](/errors).
servers:
  - url: https://speshu.ai
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Текст
    description: Генерация текста и диалог
  - name: Медиа
    description: Асинхронные задачи генерации изображений, видео, аудио и музыки
  - name: Хранилище
    description: Файлы пользователя
  - name: Справочник
    description: Каталог моделей и баланс
paths:
  /api/v1/storage/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
    delete:
      tags:
        - Хранилище
      summary: Удалить файл
      description: >-
        Удаляет файл из хранилища. Запись о файле помечается удалённой и больше
        не отображается в списке. Восстановить файл через API нельзя.
      operationId: deleteFile
      responses:
        '200':
          description: Файл удалён.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  asset_id:
                    type: string
                required:
                  - success
                  - asset_id
        '401':
          $ref: '#/components/responses/OpenAIError'
        '404':
          $ref: '#/components/responses/StorageError'
        '500':
          $ref: '#/components/responses/StorageError'
components:
  responses:
    OpenAIError:
      description: Ошибка в формате OpenAI.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OpenAIError'
    StorageError:
      description: Ошибка хранилища.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StorageError'
  schemas:
    OpenAIError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              examples:
                - invalid_request_error
              description: >-
                `authentication_error` при 401, `rate_limit_error` при 429,
                `permission_error` при 403, в остальных случаях
                `invalid_request_error`, `api_error` или `internal_error`.
            param:
              type:
                - string
                - 'null'
            code:
              type:
                - string
                - 'null'
              examples:
                - invalid_request
              description: >-
                Машиночитаемый код: `invalid_api_key`, `unauthorized`,
                `insufficient_quota`, `rate_limit_exceeded`,
                `token_limit_exceeded`, `content_too_large`, `limit_exceeded`,
                `model_not_found`, `no_providers`, `service_unavailable`,
                `provider_error`, `invalid_request`, `context_length_exceeded`,
                `internal_error`.
          required:
            - message
            - type
      required:
        - error
    StorageError:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              examples:
                - invalid_request
          required:
            - message
            - type
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        API-ключ в формате `sk-...`. Альтернативно — заголовок `X-Api-Key:
        sk-...` (совместимо с Anthropic SDK).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.