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

# Onboard a GitLab project

> Add a GitLab project to Gitar and configure webhooks for code review. This endpoint is idempotent — calling it for an already-connected project returns success with status `already_connected`.

## Idempotent Behavior

This endpoint is safe to call multiple times for the same project. If the project is already connected to Gitar, the response will return `"status": "already_connected"` instead of creating a duplicate.

## Project Identification

You can identify the project to onboard using either:

* **`project_id`** — the numeric GitLab project ID (e.g. `12345`)
* **`project_path`** — the full path of the project (e.g. `"my-group/my-project"`)

If both are provided, `project_id` takes precedence.

<Tip>
  You can find a project's numeric ID on its GitLab settings page, or via the GitLab API at `GET /api/v4/projects/:id`.
</Tip>

## Prerequisites

The Gitar service account must be a **Maintainer** (or higher) on the project you want to onboard. If the service account doesn't have access, the request will fail. See [Connect GitLab](/connecting-code/gitlab) for setup instructions.

## What This Endpoint Does

When you onboard a project, Gitar will:

1. **Verify** the project exists in your connected GitLab instance
2. **Register** the project for Gitar code review
3. **Configure** a project-level webhook so Gitar receives push and merge request events


## OpenAPI

````yaml post /external/gitlab/projects
openapi: 3.1.0
info:
  title: Gitar External API
  description: API for managing your Gitar installation and integrations
  contact:
    name: Gitar
    url: https://gitar.ai
    email: noreply@gitar.ai
  license:
    name: ''
  version: 1.0.0
servers:
  - url: https://api.gitar.ai/v1
security: []
paths:
  /external/gitlab/projects:
    post:
      tags:
        - GitLab Projects
      summary: Onboard a GitLab project
      description: >-
        Add a GitLab project to Gitar and configure webhooks for code review.
        This endpoint is idempotent — calling it for an already-connected
        project returns success with status `already_connected`.
      operationId: onboardGitlabProject
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OnboardGitlabProjectApiRequest'
        required: true
      responses:
        '200':
          description: Project onboarded successfully or already connected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OnboardGitlabProjectApiResponse'
        '400':
          description: Bad request (missing project_id and project_path)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
        '403':
          description: Insufficient scopes
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
        '404':
          description: GitLab integration not found for this organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
      security:
        - bearerAuth: []
components:
  schemas:
    OnboardGitlabProjectApiRequest:
      type: object
      description: |-
        Request to onboard a single GitLab project via the external API.

        One of `project_id` or `project_path` must be provided.
        If both are present, `project_id` takes precedence.
      properties:
        project_id:
          type:
            - integer
            - 'null'
          format: int64
          description: GitLab project numeric ID (e.g. 12345)
          minimum: 0
        project_path:
          type:
            - string
            - 'null'
          description: GitLab project path (e.g. "group/subgroup/project")
    OnboardGitlabProjectApiResponse:
      type: object
      description: Response from onboarding a single GitLab project via the external API.
      required:
        - success
        - project_path
        - status
        - webhook_configured
      properties:
        error:
          type:
            - string
            - 'null'
        project_id:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
        project_path:
          type: string
        status:
          $ref: '#/components/schemas/OnboardProjectStatus'
        success:
          type: boolean
        webhook_configured:
          type: boolean
    ResponseFailure:
      type: object
      required:
        - message
      properties:
        error_code:
          type:
            - string
            - 'null'
        message:
          type: string
    OnboardProjectStatus:
      type: string
      description: Status of an individual project onboard operation.
      enum:
        - onboarded
        - already_connected
        - failed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````