---
title: "Create a push mirror"
method: POST
path: "/api/v4/projects/{id}/remote_mirrors"
tags: ["remote_mirrors"]
---

# Create a push mirror

`POST /api/v4/projects/{id}/remote_mirrors`

## Request

- Base URL: `https://gitlab.com`
- URL: `https://gitlab.com/api/v4/projects/{id}/remote_mirrors`
- Auth: none declared

Creates a push mirror.

## Path parameters

- `id` string, required

## Request body

- PostApiV4ProjectsIdRemoteMirrors: Create a push mirror
  - `url` string, required: The URL for a remote mirror
  - `enabled` boolean: Determines if the mirror is enabled
  - `auth_method` 'ssh_public_key' | 'password': Determines the mirror authentication method
  - `keep_divergent_refs` boolean: Determines if divergent refs are kept on the target
  - `only_protected_branches` boolean: Determines if only protected branches are mirrored
  - `mirror_branch_regex` string: Determines if only matched branches are mirrored
  - `host_keys` string[]: SSH host keys in bare format (ssh-ed25519 AAAA...) or full known_hosts format (hostname ssh-ed25519 AAAA...). Bare keys use the hostname from the mirror URL.

## Response `201`

Create a push mirror

- APIEntitiesRemoteMirror: API_Entities_RemoteMirror model
  - `id` integer, required
  - `enabled` boolean, required
  - `url` string, required
  - `update_status` string, required
  - `last_update_at` string, date-time, required
  - `last_update_started_at` string, date-time, required
  - `last_successful_update_at` string, date-time, required
  - `last_error` string, required
  - `only_protected_branches` boolean, required
  - `keep_divergent_refs` boolean, required
  - `auth_method` string, required
  - `host_keys` APIEntitiesMirrorHostKey[], required
    - `fingerprint_sha256` string, required
  - `mirror_branch_regex` string, required

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `404`: Not found

---

[API](https://skmtc.dev/gitlab/apis/gitlab-api.md) - [All operations](https://skmtc.dev/gitlab/apis/gitlab-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitlab/apis/gitlab-api/revisions/b234947ef3f2?raw)
