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

# Get Gitar's blocking status for a GitLab MR

> Returns the current Gitar blocking status for a GitLab merge request. Intended for use in CI pipelines: fail the job when `blocked == "yes"` and mark it required for merge.

Organizations with a single connected GitLab instance can omit `host`. On a multi-instance organization, pass `host` to say which instance the project id belongs to — GitLab project ids are only unique within one instance.

Read the latest stored review status for a GitLab MR. A CI job can use the result to fail on important or critical findings.

> [!NOTE]
>
> This endpoint does not compare the review's commit with the MR's current commit or report a temporary review hold. The CI example passes for `pending`. Use the [GitLab review hold](https://docs.gitar.ai/features/code-review/block-merge.md#require-gitar-before-merging) where enforced approval rules are available.

## Blocking status values

The `blocked` field reflects the stored review verdict and any recorded human override, independently of the configured finding threshold.

| Value | Meaning |
| - | - |
| `yes` | The stored review has important or critical findings, with no recorded override. |
| `no` | The stored verdict is approved or approved with suggestions, or a human override released the block. |
| `pending` | No stored review exists for this MR. |

## Prerequisites

| Requirement | Setup |
| - | - |
| Connected project | [Connect GitLab](https://docs.gitar.ai/connecting-code/gitlab.md) to Gitar. |
| API token | Store a Gitar API token with `integrations:read` scope in the project's CI/CD variables as `GITAR_TOKEN`. |

## Setting up the CI job

Add this job to `.gitlab-ci.yml`. It fails when the `blocked` field is `yes`:

```yaml theme={null}
gitar-check:
  stage: test
  script:
    - |
      BLOCKED=$(curl -sf --get \
        -H "Authorization: Bearer $GITAR_TOKEN" \
        --data-urlencode "project_id=$CI_PROJECT_ID" \
        --data-urlencode "mr_iid=$CI_MERGE_REQUEST_IID" \
        "https://api.gitar.ai/v1/external/gitlab/mr_status" \
        | python3 -c "import sys,json; print(json.load(sys.stdin)['blocked'])")
      echo "Gitar blocking status: $BLOCKED"
      if [ "$BLOCKED" = "yes" ]; then
        echo "Resolve the Gitar findings or apply an authorized override, then retry this job."
        exit 1
      fi
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
```

Enable **Settings -> Merge requests -> Merge checks -> Pipelines must succeed** in the GitLab project. A failing `gitar-check` job then prevents merging on any GitLab tier. Other failing jobs also block the merge, as this setting applies to the whole pipeline.

GitLab provides `CI_PROJECT_ID`, `CI_MERGE_REQUEST_IID`, `CI_SERVER_URL` and `CI_PIPELINE_SOURCE`. Only `GITAR_TOKEN` needs to be added.

## Multiple GitLab instances

If the organization has multiple GitLab instances connected to Gitar, include `host` to identify the instance, because project IDs can repeat across instances. Organizations with one connected instance can omit it.

The CI example omits `host`. For organizations with multiple connected instances, add `--data-urlencode "host=$CI_SERVER_URL"` to the request.

A project connected before Gitar recorded its GitLab host can return 404 for a host-qualified request. Reconnect the project to restore host-qualified lookups. Omit `host` for legacy compatibility only when one GitLab instance is connected.

## Bypassing a block

When the [unblock command](https://docs.gitar.ai/commands.md#unblock) is enabled, comment `gitar unblock` on the MR to request an override. After Gitar records the override, rerun the failed CI job to read the changed status. Other pipeline failures and merge requirements still apply.


## OpenAPI

````yaml get /external/gitlab/mr_status
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/mr_status:
    get:
      tags:
        - GitLab MR Status
      summary: Get Gitar's blocking status for a GitLab MR
      description: >-
        Returns the current Gitar blocking status for a GitLab merge request.
        Intended for use in CI pipelines: fail the job when `blocked == "yes"`
        and mark it required for merge.


        Organizations with a single connected GitLab instance can omit `host`.
        On a multi-instance organization, pass `host` to say which instance the
        project id belongs to — GitLab project ids are only unique within one
        instance.
      operationId: getGitlabMrStatus
      parameters:
        - name: project_id
          in: query
          description: GitLab project ID
          required: true
          schema:
            type: integer
            format: int64
            minimum: 0
        - name: mr_iid
          in: query
          description: GitLab merge request IID
          required: true
          schema:
            type: integer
            format: int64
            minimum: 0
        - name: host
          in: query
          description: >-
            GitLab instance the project lives on (e.g. https://gitlab.com).
            Required on multi-instance organizations when the project id is
            ambiguous.
          required: false
          schema:
            type: string
      responses:
        '200':
          description: MR blocking status returned successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MrStatusResponse'
        '400':
          description: Invalid query parameters
          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: Project not connected to this org
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
        '409':
          description: >-
            The organization has several GitLab instances and `host` did not
            identify one
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure'
      security:
        - bearerAuth: []
components:
  schemas:
    MrStatusResponse:
      type: object
      description: Pipeline-friendly MR status returned to SoFi's CI job.
      required:
        - blocked
      properties:
        blocked:
          $ref: '#/components/schemas/MrBlockedStatus'
          description: >-
            `yes` → CI job should fail; `no` → approved or human bypass, pass;
            `pending` → no review yet, pass.
    ResponseFailure:
      type: object
      required:
        - message
      properties:
        error_code:
          type:
            - string
            - 'null'
        message:
          type: string
    MrBlockedStatus:
      type: string
      enum:
        - 'yes'
        - 'no'
        - pending
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.