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

# Create or update a file or directory

> Create or update a file or directory.

Idempotent: an existing file is overwritten (truncated, not appended to) and an existing directory is kept, so retrying the same request is safe.

Send either a JSON body (FileRequest) or `multipart/form-data` for binary files. Multipart fields, in any order: `file` (required, the file content), `permissions` (optional octal mode such as `0755`, applied when the file is created, default `0644`; an existing file keeps its mode), `path` (optional, ignored: the target is always the URL path).



## OpenAPI

````yaml /reference/sandbox-api/openapi.json put /filesystem/{path}
openapi: 3.0.0
info:
  description: API for manipulating filesystem, processes and network.
  title: Sandbox API
  contact: {}
  version: 0.0.1
servers:
  - url: https://{sandbox_host}
    description: >-
      Host from the sandbox's returned url, without the scheme or trailing
      slash.
    variables:
      sandbox_host:
        default: sandbox.example.com
security:
  - BearerAuth: []
paths:
  /filesystem/{path}:
    put:
      tags:
        - filesystem
      summary: Create or update a file or directory
      description: >-
        Create or update a file or directory.


        Idempotent: an existing file is overwritten (truncated, not appended to)
        and an existing directory is kept, so retrying the same request is safe.


        Send either a JSON body (FileRequest) or `multipart/form-data` for
        binary files. Multipart fields, in any order: `file` (required, the file
        content), `permissions` (optional octal mode such as `0755`, applied
        when the file is created, default `0644`; an existing file keeps its
        mode), `path` (optional, ignored: the target is always the URL path).
      parameters:
        - description: File or directory path
          name: path
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileRequest'
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: File content.
                permissions:
                  type: string
                  description: Octal file mode, applied when the file is created.
                path:
                  type: string
                  description: Ignored; the target is the URL path.
        description: File or directory details
        required: true
      responses:
        '200':
          description: Success message
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    FileRequest:
      type: object
      properties:
        content:
          type: string
          example: file contents here
        isDirectory:
          type: boolean
          example: false
        permissions:
          type: string
          example: '0644'
    SuccessResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: File created successfully
        path:
          type: string
          example: /path/to/file
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Error message
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Sandbox access token created through POST /v1/token.

````