# move_site_code_to_modulify

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

Copies the code of a site that lives in your GitHub back into a repository Modulify manages.

- Title: Move the code of a site back to Modulify
- Scope: `code:write`
- Access: Makes changes
- Endpoint: `POST /v1/move_site_code_to_modulify`

This is the **Move back to Modulify** row of the site's **Repository** section, covered in [Move the code back to Modulify](https://modulify.ai/docs/editor/move-code-to-github#move-the-code-back-to-modulify). Modulify edits and publishes from its own repository again once the copy is confirmed. It works on every plan, including Free, and needs the **Transfer projects** permission.

It brings back the `preview` branch, the publish branch, which comes back as `production` if it was renamed, and Modulify's own `modulify/` backup branches, except the `modulify/chat-` branches of its chats. Branches and tags you created yourself stay only in your GitHub. A repository Modulify created in your organisation is archived once the copy is confirmed, and one you picked as an existing repository is left as it is.

It is refused while an AI edit or a publish is running, while the code is still being copied into your GitHub or is already moving back, and while Modulify cannot reach the repository. The response only says the copy started, with the repository in `returning`. Editing and publishing pause until it finishes, so read `get_site_repository` until `CustomerOwned` is `false`.

## Request

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

It makes changes, so send an [Idempotency-Key](https://modulify.ai/docs/api/idempotency) header whenever you might retry it. A retry with the same key gets the first answer back instead of running again.

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

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

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |

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