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

# Delete a file or directory

> Deletes the file, symlink or empty directory at `path`, `204`. A symlink is removed itself, never what it points to. A non-empty directory needs `recursive=true` (else `directory_not_empty`, and nothing is removed), which deletes it with everything under it without following symlinks. Trailing slashes are ignored. A missing path is `404`, a parent that's a file `path_type_mismatch`, and `/`, anything under the reserved `/.telnyx` directory, or a `path` ending in `.` or `..` is `invalid_path`.

**A recursive delete that runs out of time** answers `503`, with part of the tree possibly removed; it goes on in the sandbox. A retry continues it, or, if it has finished meanwhile, answers `404`, even with the same `Idempotency-Key`: a `404` there means the delete is done.

With an `Idempotency-Key`, a retry after the call completed gets the stored `204`, and nothing is deleted again. A retry that overlaps the first call may answer `404` for a path the first one deleted.

`path` is absolute, at most 4096 bytes in UTF-8, and must be valid UTF-8 once percent-decoded; it's taken as the sandbox's kernel resolves it (`.`, `..` and `//` included). A path holding a NUL byte is `invalid_path`.

The sandbox must be running (else `sandbox_not_running`); file calls keep working during the stop's grace period, so you can fetch results from a sandbox that's ending. They run as the sandbox's own user, with its permissions: what that user may not do, or a read-only file system, is `permission_denied`. Another refusal by the sandbox's file system (no space, a name too long, a busy file or mount point, a symlink loop, an I/O error) is `file_operation_failed`, with a fixed text naming the reason. File calls don't count as activity for `idle_timeout`.

Each call has a 64 MiB limit and a time budget of about 12 s for its whole transfer, so a full-size file needs about 5.3 MiB/s between you and the API to read, and about 6.4 MiB/s to write (a write's body must arrive 2 s before the budget ends). Move larger data through Cloud Storage from an exec.



## OpenAPI

````yaml /openapi/source/external/sandboxes/sandboxes.json delete /ai/sandboxes/{sandbox_id}/files
openapi: 3.1.0
info:
  title: Telnyx API
  version: 1.0.0
  description: >-
    Run a container image of your choice on a whole GPU node, each sandbox in
    its own virtual machine, for seconds or indefinitely. Run commands inside
    it, move files in and out, stream its logs, read its metrics, and pay per
    second while it runs.


    ## Preview


    GPU Sandboxes is in an invite-only preview. `GET /ai/sandbox-access` tells
    whether it is enabled for your organization.


    ## Authentication


    All endpoints require a Telnyx API key sent as a Bearer token in the
    `Authorization` header.


    ## Retries


    Every side-effecting endpoint accepts an `Idempotency-Key` header. Send one
    on `POST /ai/sandboxes` and `POST /ai/sandboxes/{sandbox_id}/execs`, so a
    retry after a lost response doesn't start (and bill) a second workload.


    ## Errors


    Errors use the standard Telnyx error body. General errors carry their
    5-digit `code` (e.g. `10009`); Sandboxes-specific errors are identified by
    their name in `title` (e.g. `quota_exceeded`).
  contact:
    email: support@telnyx.com
  x-latency-category: responsive
  x-endpoint-cost: light
servers:
  - url: https://api.telnyx.com/v2
    description: Telnyx API v2
security:
  - bearerAuth: []
tags:
  - name: Sandboxes
    description: >-
      Create, find, wait for, tag and terminate sandboxes, and close the main
      process's stdin.
  - name: Sandbox execs
    description: Run commands in a running sandbox.
  - name: Sandbox files
    description: Read, write, list and delete files inside a running sandbox.
  - name: Sandbox logs
    description: The main process's stored and live output.
  - name: Sandbox metrics
    description: CPU, network, memory, disk and GPU usage.
  - name: Sandbox GPU types
    description: What you can rent, and at what price.
  - name: Sandbox access
    description: Whether Sandboxes is enabled for your organization.
paths:
  /ai/sandboxes/{sandbox_id}/files:
    delete:
      tags:
        - Sandbox files
      summary: Delete a file or directory
      description: >-
        Deletes the file, symlink or empty directory at `path`, `204`. A symlink
        is removed itself, never what it points to. A non-empty directory needs
        `recursive=true` (else `directory_not_empty`, and nothing is removed),
        which deletes it with everything under it without following symlinks.
        Trailing slashes are ignored. A missing path is `404`, a parent that's a
        file `path_type_mismatch`, and `/`, anything under the reserved
        `/.telnyx` directory, or a `path` ending in `.` or `..` is
        `invalid_path`.


        **A recursive delete that runs out of time** answers `503`, with part of
        the tree possibly removed; it goes on in the sandbox. A retry continues
        it, or, if it has finished meanwhile, answers `404`, even with the same
        `Idempotency-Key`: a `404` there means the delete is done.


        With an `Idempotency-Key`, a retry after the call completed gets the
        stored `204`, and nothing is deleted again. A retry that overlaps the
        first call may answer `404` for a path the first one deleted.


        `path` is absolute, at most 4096 bytes in UTF-8, and must be valid UTF-8
        once percent-decoded; it's taken as the sandbox's kernel resolves it
        (`.`, `..` and `//` included). A path holding a NUL byte is
        `invalid_path`.


        The sandbox must be running (else `sandbox_not_running`); file calls
        keep working during the stop's grace period, so you can fetch results
        from a sandbox that's ending. They run as the sandbox's own user, with
        its permissions: what that user may not do, or a read-only file system,
        is `permission_denied`. Another refusal by the sandbox's file system (no
        space, a name too long, a busy file or mount point, a symlink loop, an
        I/O error) is `file_operation_failed`, with a fixed text naming the
        reason. File calls don't count as activity for `idle_timeout`.


        Each call has a 64 MiB limit and a time budget of about 12 s for its
        whole transfer, so a full-size file needs about 5.3 MiB/s between you
        and the API to read, and about 6.4 MiB/s to write (a write's body must
        arrive 2 s before the budget ends). Move larger data through Cloud
        Storage from an exec.
      operationId: DeleteSandboxFile
      parameters:
        - description: Sandbox ID (`sb-…`).
          in: path
          name: sandbox_id
          required: true
          schema:
            maxLength: 64
            minLength: 1
            type: string
          example: sb-0192f1c2-7a4b-7c3e-9d1e-2f3a4b5c6d7e
        - description: >-
            Absolute path inside the sandbox, e.g. `/app/out.txt`, at most 4096
            bytes in UTF-8.
          in: query
          name: path
          required: true
          schema:
            maxLength: 4096
            minLength: 1
            pattern: ^/
            type: string
          example: /app/out/results.json
        - description: Also delete a non-empty directory's contents.
          in: query
          name: recursive
          required: false
          schema:
            default: false
            type: boolean
        - description: >-
            Optional client-chosen key (e.g. a UUID, at most 255 characters)
            that makes the call safe to retry. Within 24 h, the same key with
            the same request returns the stored response instead of acting
            twice; the same key with a different request fails with
            `idempotency_key_reused`; a request with a key that's still being
            processed fails with `request_in_progress`.
          in: header
          name: Idempotency-Key
          required: false
          schema:
            maxLength: 255
            minLength: 1
            type: string
      responses:
        '204':
          description: Deleted.
        '400':
          description: >-
            Validation error: the standard Telnyx validation errors (codes such
            as 10004 missing parameter, 10015 bad request, 10025 invalid string
            length, 10026 invalid type).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
        '401':
          description: Missing or invalid API key (code 10009).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10009'
                    title: Authentication failed
                    detail: Could not find any usable credentials in the request.
        '403':
          description: >-
            - `sandboxes_require_verification`: your account isn't fully
            verified.

            - `sandboxes_not_whitelisted`: Sandboxes isn't enabled for your
            organization (invite-only preview); `GET /ai/sandbox-access` tells
            whether it is.

            - `permission_denied`: the sandbox's user may not do this at the
            path, or its file system is read-only.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: sandboxes_not_whitelisted
                    detail: The organization isn't whitelisted.
        '404':
          description: >-
            Not found (code 10005): the resource doesn't exist or belongs to
            another organization. The detail says what's missing.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10005'
                    title: Resource not found
                    detail: Sandbox not found.
        '409':
          description: >-
            - `request_in_progress`: a request with the same `Idempotency-Key`
            is still being processed; retry later.

            - `sandbox_not_running`: the operation needs a running sandbox.

            - `directory_not_empty`: the directory isn't empty and `recursive`
            is false.

            - `path_type_mismatch`: the path is a directory where a file was
            expected, or the reverse (a parent that's a file included), or
            neither a file nor a directory.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: directory_not_empty
                    detail: The directory isn't empty and `recursive` is false.
        '422':
          description: >-
            - `idempotency_key_reused`: the same `Idempotency-Key` was sent with
            a different request.

            - `invalid_path`: the path holds a NUL byte, or a write or delete
            names the reserved `/.telnyx` directory, ends in a final `.` or
            `..`, or deletes `/`.

            - `file_operation_failed`: the sandbox's file system refused for
            another stated reason: no space, a name too long, a busy file or
            mount point, a symlink loop, or an I/O error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - title: invalid_path
                    detail: The path is reserved.
        '503':
          description: A dependency can't answer right now (code 10037); retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TelnyxErrors'
              example:
                errors:
                  - code: '10037'
                    title: Service unavailable
                    detail: A dependency can't answer right now; retry later.
components:
  schemas:
    TelnyxErrors:
      description: The standard Telnyx error body.
      properties:
        errors:
          description: One or more errors.
          items:
            $ref: '#/components/schemas/TelnyxError'
          type: array
      required:
        - errors
      type: object
    TelnyxError:
      description: One error in the standard Telnyx error body.
      properties:
        code:
          description: >-
            Telnyx error code: a 5-digit string for general errors, e.g.
            `10009`. Sandboxes-specific errors are identified by their name in
            `title`.
          type: string
        detail:
          description: Human-readable explanation.
          type:
            - string
            - 'null'
        meta:
          description: Extra information.
          anyOf:
            - $ref: '#/components/schemas/TelnyxErrorMeta'
            - type: 'null'
        source:
          description: Where the error is.
          anyOf:
            - $ref: '#/components/schemas/TelnyxErrorSource'
            - type: 'null'
        title:
          description: >-
            Short, constant summary of the error. For Sandboxes-specific errors,
            the error's name, e.g. `quota_exceeded`.
          type: string
      required:
        - title
      type: object
    TelnyxErrorMeta:
      description: Extra error information.
      properties:
        url:
          default: null
          description: Documentation page for the error code.
          type:
            - string
            - 'null'
      type: object
    TelnyxErrorSource:
      description: Where in the request the error was found.
      properties:
        parameter:
          default: null
          description: Name of the offending parameter.
          type:
            - string
            - 'null'
        pointer:
          default: null
          description: JSON pointer into the request body, e.g. `/timeout`.
          type:
            - string
            - 'null'
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````