# move_site_code_to_github

Source: https://modulify.ai/docs/api/code/move-site-code-to-github

Copies the repository of a site into a connected GitHub account, after which Modulify edits and publishes from there.

- Title: Move the code of a site into your GitHub
- Scope: `code:write`
- Access: Destructive
- Endpoint: `POST /v1/move_site_code_to_github`

This is the **Move to your GitHub** row of the site's **Repository** section, covered in [Move a site's repository](https://modulify.ai/docs/editor/move-code-to-github#move-a-sites-repository). The code moves with its full history, and Modulify keeps editing and publishing from the new repository for as long as the Modulify app can reach it. It needs a paid plan and the **Transfer projects** permission, and it is refused while an AI edit or a publish is running.

Without `existing`, Modulify creates a new private repository in that account: always in an organisation, and in a personal account once its `list_github_accounts` row has `Granted_At`, which verifying the account sets. With `existing` set to `true`, the code goes into a repository you already have, in an organisation or a personal account, and every branch and tag that was in it is deleted and replaced, which Modulify cannot bring back. That repository has to be one the Modulify app can reach, not archived, without protected branches and not already holding another Modulify site. See [Move into an existing repository](https://modulify.ai/docs/editor/move-code-to-github#move-into-an-existing-repository).

The response only says the copy started, with the repository in `pending`. Editing and publishing pause until it finishes, which usually takes a few seconds and can take minutes for a large history, so read `get_site_repository` until `Status` is `connected`, or `failed` with the reason. A copy still unfinished 45 minutes after it started is given up. A failed move leaves the site with Modulify and removes a repository Modulify created for it, while a repository you picked keeps whatever the copy had already changed. The messages are listed in [If the move is refused or fails](https://modulify.ai/docs/editor/move-code-to-github#if-the-move-is-refused-or-fails).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/move_site_code_to_github`, sending the inputs below as a JSON object. The token needs the `code:write` scope.

> **Warning**
>
> This method is marked destructive: it deletes or overwrites data. Check the inputs before you call it, and send an [Idempotency-Key](https://modulify.ai/docs/api/idempotency) header whenever you might retry it.

```bash
curl -X POST https://api.modulify.ai/v1/move_site_code_to_github \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","installationId":"INSTALLATION_ID"}'
```

Over MCP, the same method is the [move_site_code_to_github tool](https://modulify.ai/docs/mcp/code/move-site-code-to-github).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `installationId` | string | Yes | The `_id` of a verified GitHub account from the `Installations` of `get_site_repository`, not the number GitHub gives the installation. |
| `repositoryName` | string | No | For a new repository, its name in letters, numbers, hyphens, underscores and dots, which defaults to the subdomain of the site. With `existing` set to `true`, the name of the repository to replace in that account. |
| `existing` | boolean | No | `true` to replace a repository you already have instead of creating a new one. Every branch and tag already in it is deleted. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.