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

# Write file

> Create a new file or new version of existing file



## OpenAPI

````yaml post /files
openapi: 3.0.0
info:
  title: OpenFiles SDK API
  description: >-
    AI-native file storage platform with create, read, write operations, version
    control, and semantic search.
  version: 2.0.0
  contact:
    name: OpenFiles Support
    url: https://openfiles.ai
servers:
  - url: https://api.openfiles.ai/functions/v1/api
    description: Production
  - url: http://localhost:54321/functions/v1/api
    description: Local Development
security: []
tags:
  - name: System
    description: System health and status operations
  - name: Files
    description: File storage operations with version control
paths:
  /files:
    post:
      tags:
        - Files
      summary: Write file
      description: Create a new file or new version of existing file
      operationId: writeFile
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WriteFileRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileOperationResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          $ref: '#/components/responses/Conflict'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    WriteFileRequest:
      type: object
      required:
        - path
        - content
      properties:
        path:
          type: string
          minLength: 1
          example: src/app.py
        content:
          type: string
          maxLength: 10485760
          example: print('Hello World')
        contentType:
          type: string
          enum:
            - text/markdown
            - text/plain
            - text/javascript
            - text/typescript
            - application/json
            - text/html
            - text/css
            - text/x-python
            - text/x-java-source
            - text/x-c++src
            - text/x-csrc
            - application/xml
            - application/yaml
            - text/csv
            - image/jpeg
            - image/png
            - image/gif
            - image/webp
            - image/bmp
            - image/svg+xml
            - application/pdf
            - application/zip
            - audio/mpeg
            - video/mp4
            - video/x-msvideo
            - video/quicktime
            - application/octet-stream
          example: text/x-python
          description: MIME type of the file content. Must be one of the supported types.
        isBase64:
          type: boolean
          default: false
    FileOperationResponse:
      type: object
      required:
        - success
        - data
        - operation
        - message
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/FileMetadata'
        operation:
          type: string
          example: write_file
        message:
          type: string
          example: File created successfully, version 1
    FileMetadata:
      type: object
      properties:
        id:
          type: string
          format: uuid
        path:
          type: string
        version:
          type: integer
          minimum: 1
        mimeType:
          type: string
        size:
          type: integer
          minimum: 0
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
        operation:
          type: string
        details:
          type: object
          additionalProperties: true
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Authentication required or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: Resource conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication. Get your API key from the console.

````