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

# Import Git repository

> Import a Git repo with all history from a Git URL. {repo_id} must have no commits and no branches, or be already marked as synced with the same git_url. The git repo URL must have http credentials embedded or otherwise hosted on Github and the owner has the Diversion Github app integration set up.



## OpenAPI

````yaml post /repos/{repo_id}/import
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}/import:
    parameters:
      - $ref: '#/components/parameters/RepoParam'
    post:
      tags:
        - Repository Manipulation
      summary: Import a Git repo into this Diversion repo
      description: >-
        Import a Git repo with all history from a Git URL. `repo_id` must have
        no commits and no branches, or be already marked as synced with the same
        `git_url`. The git repo URL must have http credentials embedded or
        otherwise hosted on Github and the owner has the Diversion Github app
        integration set up.
      operationId: src.handlers.integrations.git_import.import_in_background
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GitRepoImport'
      responses:
        '202':
          description: >-
            Import started asynchronously. Poll the repo until it shows a
            default branch.
        '409':
          $ref: '#/components/responses/Error'
          description: Repo is not empty or is already synced with another URL.
        '422':
          $ref: '#/components/responses/Error'
          description: Repo credentials are not set and therefore it cannot be imported.
        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:
    GitRepoImport:
      description: Details of a git repo to import into Diversion
      type: object
      properties:
        git_url:
          description: URL to the git repo. May be omitted if repo_id already has it set.
          type: string
    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
  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

````