> ## 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/rename

> This endpoint renames a file or directory 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).


## OpenAPI

````yaml PATCH /v1/apps/{appId}/files/rename
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/rename:
    patch:
      tags:
        - File System
      description: >-
        Renames a file or directory of an application, keeping it in the same
        directory. The owner of the application must have an active plan. For
        team applications the `canEditApplicationFiles` permission is required.


        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:
                - filePath
                - newName
              properties:
                filePath:
                  type: string
                  minLength: 1
                  maxLength: 1024
                  description: >-
                    Current path of the file or directory. Must not be the
                    application root.
                  example: src/old-name.js
                newName:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: >-
                    New name only, 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: new-name.js
      responses:
        '200':
          description: The file or directory was renamed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Renamed successfully
        '400':
          description: >-
            `appId` is not a valid ID, the body is invalid, `filePath` or
            `newName` is not allowed, or something with the new name already
            exists in that directory.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  Error from worker: A file or folder with the new name already
                  exists in this location.
        '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 `filePath` does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: >-
                  Error from worker: Failed to rename: 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.