# rename_publish_branch

Source: https://modulify.ai/docs/api/code/rename-publish-branch

Renames the GitHub branch every publish of a site writes to and builds from.

- Title: Rename the publish branch of a site
- Scope: `code:write`
- Access: Makes changes
- Endpoint: `POST /v1/rename_publish_branch`

This is the **Publish branch** row of the site's **Repository** section, covered in [Rename the publish branch](https://modulify.ai/docs/editor/move-code-to-github#rename-the-publish-branch). The branch is `production` until it is renamed. It only works once the code lives in your GitHub, and it needs a paid plan and the **Transfer projects** permission.

Modulify renames the existing branch on GitHub rather than creating a new one, so its history moves with it and the old name is free for a branch of your own. A name holds letters, numbers, hyphens, underscores and dots, starts with a letter or number and runs to 100 characters. It cannot have two dots in a row or end with a dot or `.lock`, and `preview` and `HEAD` are reserved.

It is refused while a publish is running and when a branch with the new name already exists. When the publish branch was renamed on GitHub itself, pass the name it has now: Modulify switches to it without renaming anything, as long as it is still the default branch of the repository. Anything outside GitHub that still uses the old name, such as a deploy pipeline, has to be changed by you.

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/rename_publish_branch`, 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/rename_publish_branch \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","branch":"BRANCH"}'
```

Over MCP, the same method is the [rename_publish_branch tool](https://modulify.ai/docs/mcp/code/rename-publish-branch).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `branch` | string | Yes | The new name of the publish branch. |

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