# Add a remote

> Link a repository to a remote on another g1t or any git host over HTTPS (GitHub repositories are linked by importing them through g1t's GitHub App).

<div class="g1t-endpoint"><span class="g1t-method" data-method="post">POST</span><code>/repos/{owner}/{name}/mirror/remotes</code></div>

`role` `follower`: g1t leads and pushes to it. `role` `leader`: this repository becomes its mirror; only an empty repository can, and it is filled from the remote. `url` is its https clone address, `token` a token that can read and push (kept sealed, never returned), `username` the user it is sent as. Needs the Admin role; agents' tokens are refused.

The token is never returned. A remote that refused it, or could not be reached, is still added, with `last_error` saying why.

- **Authentication:** Required. Send an [access token](/reference/api/#authentication) as `Authorization: Bearer`.
- **MCP tool:** [`repository`](/reference/mcp/#repository) with `action` `mirror_add_remote`, and the same inputs
- **Scope:** An access token needs [`repo:admin`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `owner` | string | Yes | The workspace that owns the repository. |
| `name` | string | Yes | The repository's name. |

## Body parameters

Send a JSON object. Names are `snake_case`, as in responses; the `camelCase` spelling is accepted too.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `provider` | string | Yes | Another g1t (g1t.sh or your own), or any git host. One of `g1t`, `git`. |
| `role` | string | Yes | follower: g1t leads and pushes to it. leader: this empty repository becomes its mirror. One of `follower`, `leader`. |
| `url` | string | Yes | Its https clone address, such as https://g1t.sh/acme/web.git. |
| `username` | string | No | The user the token is sent as. x-access-token when left out. |
| `token` | string | Yes | A token that can read and push. Kept sealed; never returned. |

## Example request

```sh
curl -X POST https://api.g1t.sh/repos/acme/web/mirror/remotes \
  -H "Authorization: Bearer $G1T_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "g1t",
    "role": "follower",
    "url": "https://git.acme.internal/acme/web.git",
    "username": "deploy",
    "token": "g1t_…"
  }'
```

## Example response

A successful request answers `200` with:

```json
{
  "id": "rmt_01kp4b3c4d5e6f7g8h9j0k1m2n",
  "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
  "repo": "acme/web",
  "provider": "g1t",
  "role": "follower",
  "name": "git.acme.internal/acme/web",
  "url": "https://git.acme.internal/acme/web",
  "state": "following",
  "state_since": "2026-10-08T13:58:00.000Z",
  "state_by": "syntaqx",
  "reachable": true,
  "unreachable_since": null,
  "synced_at": "2026-10-08T13:57:42.000Z",
  "last_error": null,
  "checks_problem": null,
  "settings": {
    "notify": "banner",
    "take_over_after": null,
    "hand_back": "when_clean",
    "keep_ci_warm": false,
    "github_workflows": true,
    "hold_deploys": true,
    "report_checks": true,
    "remote_pushes": "adopt"
  },
  "created_at": "2026-10-05T10:00:00.000Z"
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change or an agent token outside its repository. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 409 | `conflict` | The request conflicts with the current state. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
