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

# /v1/apps/{appId}/files/create

> This endpoint creates a directory, or creates or overwrites a text file of an application.

> [!WARNING]
>
> This endpoint has a rate limit of 1 request every 3 seconds, shared with the other endpoints that change files (upload, delete, rename, move and create).

> [!WARNING]
>
> An existing file with the same name is overwritten without confirmation.

> [!NOTE]
>
> The request body is limited to 100 KB and the content is saved as UTF-8 text. For binary or larger files, send a `.zip` to the upload endpoint.

> [!TIP]
>
> To edit a file: read it with `GET /v1/apps/{appId}/files?path=...`, send the new content to this endpoint, then restart the application so it loads the change.


## OpenAPI

````yaml POST /v1/apps/{appId}/files/create
openapi: 3.1.0
info:
  title: CamposCloud API Documentation
  description: >-
    This documentation provides an overview of the CamposCloud API, including
    authentication, endpoints, and data structures. It is designed to help
    developers integrate with the CamposCloud platform effectively.
  version: 1.0.0
servers:
  - url: https://api.camposcloud.com
security:
  - bearerAuth: []
paths:
  /v1/apps/{appId}/files/create:
    post:
      tags:
        - File System
      description: >-
        Creates a directory, or creates a text file with the given content. **If
        the file already exists it is overwritten**, which makes this the
        endpoint to save a single text file. Missing parent directories are
        created for directories, but not for files. The owner of the application
        must have an active plan. For team applications the
        `canEditApplicationFiles` permission is required.


        The content is written as UTF-8 text and the whole request body is
        limited to 100 KB. Use the upload endpoint for binary or larger files.


        The application is not restarted: restart it to make it load the new
        file.


        Paths are relative to the root of the application; a leading `/` is
        optional. A path must have 1 to 1024 characters and must not contain
        `..` segments, backslashes, control characters or any of `< > : " | ?
        *`.
      parameters:
        - name: appId
          in: path
          required: true
          description: ID of the application.
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - path
                - name
                - isDirectory
              properties:
                path:
                  type: string
                  minLength: 1
                  maxLength: 1024
                  description: >-
                    Directory in which the item is created. Use `/` for the
                    application root.
                  example: src
                name:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    Name of the file or directory, without any directory. It
                    must not contain `/`, must not be `.` or `..`, must not
                    start or end with a space and must not end with a dot.
                  example: config.json
                isDirectory:
                  type: boolean
                  description: >-
                    `true` to create a directory, `false` to create or overwrite
                    a file.
                  example: false
                content:
                  type: string
                  description: >-
                    Text content of the file. Required when `isDirectory` is
                    `false` (an empty string creates an empty file). Ignored for
                    directories.
                  example: '{ "debug": false }'
      responses:
        '200':
          description: The file or directory was created (or the file was overwritten).
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: File created successfully
        '400':
          description: >-
            `appId` is not a valid ID, the body is invalid, `path` or `name` is
            not allowed, or `content` is missing for a file.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: '''content'' must be a string when ''isDirectory'' is false.'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            You are not allowed to edit files of the application (team
            applications require the `canEditApplicationFiles` permission), or
            the owner of the application has no active plan. Also returned when
            the path resolves outside the application folder.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  You do not have permission to perform this action on this
                  application.
        '404':
          description: Application not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  Application not found or you do not have permission to access
                  it.
        '429':
          description: >-
            A rate limit was exceeded. This endpoint accepts 1 request every 3
            seconds. The counter is shared by upload, delete, rename, move and
            create.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: File upload limit reached, please try again later
        '500':
          description: >-
            Unexpected error. Also returned when the directory given in `path`
            does not exist and a file is being created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  Error from worker: Erro ao criar arquivo: ENOENT: no such file
                  or directory
components:
  schemas:
    Error:
      type: object
      description: >-
        Every error returned by the API has this shape. The message can be in
        English or in Portuguese depending on the endpoint.
      required:
        - error
      properties:
        error:
          type: string
          description: Human readable description of the error.
          example: Application not found.
  responses:
    Unauthorized:
      description: >-
        The `Authorization` header is missing or malformed, or the API token is
        invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Invalid developer token
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your CamposCloud API token, sent as `Authorization: Bearer <token>`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.