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

# Rename repository

> Change the name of a repository



## OpenAPI

````yaml post /repos/{repo_id}/rename
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}/rename:
    parameters:
      - $ref: '#/components/parameters/RepoParam'
    post:
      tags:
        - Repository Manipulation
      summary: Rename repository
      description: Change the name of a repository
      operationId: src.handlersv2.repo.rename
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RenameRepoRequest'
      responses:
        '200':
          description: Repository renamed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Repo'
        '400':
          description: Invalid repository name
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Only repository owner can rename
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Repository not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Repository name already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        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.
  schemas:
    RenameRepoRequest:
      type: object
      properties:
        new_name:
          type: string
          description: The new name for the repository
          pattern: ^\S.*\S$|^\S$
          minLength: 1
          maxLength: 128
      required:
        - new_name
    Repo:
      allOf:
        - $ref: '#/components/schemas/NewRepo'
        - type: object
          properties:
            repo_id:
              type: string
              example: example_id
            default_branch_id:
              type: string
            default_branch_name:
              type: string
            size_bytes:
              type: number
              format: float
            owner_user_id:
              type: string
            created_timestamp:
              type: integer
              description: Seconds since epoch UTC
              format: int64
            sync_git_repo_url:
              type: string
              description: Optional URL of the git repository being synced with the repo
            sync_git_level:
              $ref: '#/components/schemas/GitSyncLevel'
            digest_method:
              type: string
              description: The method used to calculate the digest of BLOBs in the repo.
              enum:
                - sha1
                - md5
            def_auto_forwarding_enabled:
              type: boolean
          required:
            - repo_name
            - repo_id
            - size_bytes
            - owner_user_id
            - created_timestamp
    Error:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
        detail:
          type: string
        title:
          type: string
        type:
          type: string
      required:
        - status
        - detail
    NewRepo:
      type: object
      properties:
        repo_name:
          type: string
          example: repo-name
          pattern: ^\S.*\S$|^\S$
          minLength: 1
          maxLength: 128
        description:
          type: string
        organization_id:
          type: string
          description: >-
            The ID of the organization to associate the repo with. If not
            provided, the system will use the user's organization if they belong
            to exactly one.
      required:
        - repo_name
    GitSyncLevel:
      type: integer
      enum:
        - 1
        - 2
        - 3
        - 4
      default: 4
      description: >-
        One of: 1 - latest commit of default branch, 2 - default branch with
        history, 3 - full repo with history, 4 - full repo with history and sync
        [default]
      x-ogen-enum-naming:
        '1': GitSyncLevel_LatestCommit
        '2': GitSyncLevel_DefaultBranch
        '3': GitSyncLevel_FullRepo
        '4': GitSyncLevel_FullRepoWithSync
  responses:
    Error:
      description: An error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  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

````