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

# Delete box file/dir

> Deletes a file or a directory. If target path doesn't exist, the delete will fail.



## OpenAPI

````yaml delete /boxes/{boxId}/fs
openapi: 3.0.0
info:
  title: GBOX Open API
  description: GBOX Open API Documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://gbox.ai/api/v1
    description: Production Server
security: []
tags: []
paths:
  /boxes/{boxId}/fs:
    delete:
      tags:
        - File System
      summary: Delete box file/dir
      description: >-
        Deletes a file or a directory. If target path doesn't exist, the delete
        will fail.
      operationId: FileSystemController_deleteFile
      parameters:
        - name: boxId
          required: true
          in: path
          description: Box ID
          schema:
            example: c9bdc193-b54b-4ddb-a035-5ac0c598d32d
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteFile'
      responses:
        '200':
          description: Delete file/dir
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteFileResult'
        '404':
          description: File/dir not found
      security:
        - bearer: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import GboxSDK from "gbox-sdk";

            const gboxSDK = new GboxSDK({
              apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
            });

            async function main() {
              const box = await gboxSDK.create({ type: "linux" });
              // prepare: write a file
              await box.fs.write({
                path: "/tmp/example.txt",
                content: "Hello, world!",
              });

              // Delete a file
              const deleteResult = await box.fs.remove({
                path: "/tmp/example.txt",
              });

              console.log("File deleted successfully:", deleteResult.message);
            }

            main();
        - lang: Python
          source: |-
            import os
            from gbox_sdk import GboxSDK

            def main():
                gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])

                box = gbox_sdk.create(type="linux")
                # prepare: write a file
                box.fs.write(
                    path="/tmp/example.txt",
                    content="Hello, world!"
                )

                # Delete a file
                delete_result = box.fs.remove(
                    path="/tmp/example.txt"
                )

                print("File deleted successfully:", delete_result.message)

            if __name__ == "__main__":
                main()
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/gbox/gbox-sdk-go\"\n)\n\nfunc main() {\n\tgboxSDK := gbox.NewGboxSDK(os.Getenv(\"GBOX_API_KEY\"))\n\n\tbox, err := gboxSDK.Create(context.Background(), gbox.CreateOptions{Type: \"linux\"})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create linux box: %v\", err)\n\t}\n\n\t// prepare: write a file\n\t_, err = box.Fs.Write(context.Background(), &gbox.WriteFileRequest{\n\t\tPath:    \"/tmp/example.txt\",\n\t\tContent: \"Hello, world!\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to write file: %v\", err)\n\t}\n\n\t// Delete a file\n\tdeleteResult, err := box.Fs.Remove(context.Background(), &gbox.RemoveFileRequest{\n\t\tPath: \"/tmp/example.txt\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to delete file: %v\", err)\n\t}\n\n\tfmt.Printf(\"File deleted successfully: %s\\n\", deleteResult.Message)\n}"
components:
  schemas:
    DeleteFile:
      type: object
      properties:
        workingDir:
          type: string
          description: >-
            Working directory. If not provided, the file will be read from the
            `box.config.workingDir` directory.
          title: FileSystemBase
          example: /home/user/documents
        path:
          type: string
          description: >-
            Target path in the box. If the path does not start with '/', the
            file/directory will be deleted relative to the working directory. If
            the target path does not exist, the delete will fail.
          title: DeleteFile
          example: /home/user/documents/output.txt
      title: Delete File/Directory
      description: Request parameters for deleting a file/directory
      required:
        - path
    DeleteFileResult:
      type: object
      properties:
        message:
          type: string
          description: Success message
          title: DeleteFileResult
          example: File/Directory deleted successfully
      title: Delete File/Directory Result
      description: Response after deleting file/directory
      required:
        - message
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: >-
        Enter your API Key in the format: Bearer <token>. Get it from
        https://gbox.ai

````