> ## 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.

# Append Content to File

> Add content to the end of an existing file

# Append Content to File

Adds new content to the end of an existing file without replacing the original content. Perfect for logs, ongoing documents, and incremental updates.

## Use Cases

* **Log files** - Add new log entries to existing logs
* **Data collection** - Append new records to data files
* **Document building** - Add sections to reports or documentation
* **Chat histories** - Add new messages to conversation files

## Example Usage

<CodeGroup>
  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.openfiles.ai/functions/v1/api/files/append/logs/app.log', {
    method: 'PUT',
    headers: {
      'x-api-key': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      content: '\n2024-01-15 10:30:00 INFO User login successful'
    })
  })
  ```

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

  response = requests.put(
      'https://api.openfiles.ai/functions/v1/api/files/append/logs/app.log',
      headers={'x-api-key': API_KEY},
      json={'content': '\n2024-01-15 10:30:00 INFO User login successful'}
  )
  ```

  ```bash cURL theme={null}
  curl -X PUT 'https://api.openfiles.ai/functions/v1/api/files/append/logs/app.log' \
    -H 'x-api-key: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "content": "\n2024-01-15 10:30:00 INFO User login successful"
    }'
  ```
</CodeGroup>


## OpenAPI

````yaml put /files/append/{path}
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/append/{path}:
    put:
      tags:
        - Files
      summary: Append content to file
      description: Add content to the end of an existing file
      operationId: appendFile
      parameters:
        - name: path
          in: path
          required: true
          schema:
            type: string
          description: File path (S3-style, no leading slash)
          example: logs/app.log
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppendFileRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileOperationResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AppendFileRequest:
      type: object
      required:
        - content
      properties:
        content:
          type: string
          minLength: 1
          maxLength: 10485760
    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'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnprocessableEntity:
      description: Business rule violation
      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.

````