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

# Move file

> Moves or renames a file from the current path to a new path specified in the `new_path` parameter.

**Requirements:**
- The `ref_id` must be a workspace ID
- Requires a client ID header

**Validation:**
Both paths are normalized and validated before the operation.

**Returns:**
- `404 Not Found` if the source path doesn't exist
- `202 Accepted` on successful move




## OpenAPI

````yaml patch /repos/{repo_id}/files/{ref_id}/{path}
openapi: 3.0.3
info:
  title: Diversion Core API
  description: >-
    Definition of the Core API used to access low-level functionality of
    Diversion
  version: 0.2.0
servers:
  - url: https://api.diversion.dev/v0
    description: Base endpoint
security: []
paths:
  /repos/{repo_id}/files/{ref_id}/{path}:
    parameters:
      - $ref: '#/components/parameters/RepoParam'
      - $ref: '#/components/parameters/RefParam'
      - $ref: '#/components/parameters/PathParam'
    patch:
      tags:
        - File Mutation
      summary: Move a file to a different path
      operationId: src.handlersv2.files.move_file
      parameters:
        - name: new_path
          in: query
          schema:
            type: string
            format: path
            example: /path/to/file
          required: true
          description: The new path to where the file has moved
        - $ref: '#/components/parameters/ClientIDParam'
      responses:
        '202':
          description: File moved
        '404':
          $ref: '#/components/responses/NotFound'
        default:
          $ref: '#/components/responses/Error'
      security:
        - OAuth2:
            - coreapi/write
components:
  parameters:
    RepoParam:
      in: path
      name: repo_id
      required: true
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      description: >-
        The repo ID of the repository. Repo _name_ can be used instead of the
        ID, but usage of ID for permanent linking and API requests is preferred.
    RefParam:
      in: path
      name: ref_id
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      required: true
      description: An ID of a workspace, branch or commit.
    PathParam:
      in: path
      name: path
      schema:
        type: string
        format: path
        example: /path/to/file
      required: true
      description: A path to a file inside the repository.
    ClientIDParam:
      in: header
      name: X-DV-Client-ID
      description: The unique id of the client making this request
      required: true
      schema:
        type: string
  responses:
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error:
      description: An error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
          example: 403
        detail:
          type: string
          example: User not authorized to perform the requested action on the resource
        title:
          type: string
        type:
          type: string
      required:
        - status
        - detail
  securitySchemes:
    OAuth2:
      type: oauth2
      x-tokenInfoFunc: src.token_info.token_auth
      description: This API uses OAuth 2 with the implicit grant flow
      flows:
        implicit:
          authorizationUrl: https://auth.diversion.dev/oauth2/authorize
          scopes:
            coreapi/read: Operations with no possible side-effects
            coreapi/write: Modifying operations
            coreapi/admin: >-
              Organizational operations like adding a repo or changing repo
              properties

````