GitHub: Rename a branch
GitHub repos.reposRenameBranch: arguments, response, policy and SDK examples.
← Repos operations · Get started
Operation github.repos_rename_branch
Provider route: POST /repos/{owner}/{repo}/branches/{branch}/rename. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/github with npm, or alter-sdk-github with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { GitHubIntegration } from "@alter-ai/github";
async function execute(input: Parameters<GitHubIntegration["repos"]["reposRenameBranch"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new GitHubIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.repos.reposRenameBranch(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_github import GitHubIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = GitHubIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.repos.repos_rename_branch(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.owner | string | Required within parent | |
path.repo | string | Required within parent | |
path.branch | string | Required within parent | |
body | object | Required within parent | |
body.new_name | string | Required within parent | The new name of the branch. |
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Get a branch — response body |
Referenced models: Get a branch — response body
Schemas
Section titled “Schemas”12 more schemas are linked from the tables above, on the schema pages.
Get a branch — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Branch With Protection |
_links | object | Required within parent | |
_links.html | string | Required within parent | |
_links.self | string | Required within parent | Format: uri |
commit | Model | Required within parent | Expand Get a commit — response body |
name | string | Required within parent | |
pattern | string | Optional | |
protected | boolean | Required within parent | |
protection | Model | Required within parent | Expand Get branch protection — response body |
protection_url | string | Required within parent | Format: uri |
required_approving_review_count | JSON | Optional | |
required_approving_review_count (anyOf 1) | integer | Alternative | |
required_approving_review_count (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
Referenced models: Get branch protection — response body, Get a commit — response body
Get branch protection — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Branch Protection |
allow_deletions | object | Optional | |
allow_deletions.enabled | boolean | Optional | |
allow_force_pushes | object | Optional | |
allow_force_pushes.enabled | boolean | Optional | |
allow_fork_syncing | object | Optional | Whether users can pull changes from upstream when the branch is locked. Set to `true` to allow fork syncing. Set to `false` to prevent fork syncing. |
allow_fork_syncing.enabled | boolean | Optional | Default: false |
block_creations | object | Optional | |
block_creations.enabled | boolean | Optional | |
enabled | boolean | Optional | |
enforce_admins | Model | Optional | Expand Get admin branch protection — response body |
lock_branch | object | Optional | Whether to set the branch as read-only. If this is true, users will not be able to push to the branch. |
lock_branch.enabled | boolean | Optional | Default: false |
name | string | Optional | |
protection_url | string | Optional | |
required_conversation_resolution | object | Optional | |
required_conversation_resolution.enabled | boolean | Optional | |
required_linear_history | object | Optional | |
required_linear_history.enabled | boolean | Optional | |
required_pull_request_reviews | Model | Optional | Expand Get pull request review protection — response body |
required_signatures | object | Optional | |
required_signatures.enabled | boolean | Required within parent | |
required_signatures.url | string | Required within parent | Format: uri |
required_status_checks | Model | Optional | Expand Get branch protection — response body — required status checks |
restrictions | Model | Optional | Expand Get access restrictions — response body |
url | string | Optional |
Referenced models: Get access restrictions — response body, Get admin branch protection — response body, Get pull request review protection — response body, Get branch protection — response body — required status checks
Get a commit — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Commit |
author | JSON | Required within parent | |
author (anyOf 1) | JSON | Alternative | |
author (anyOf 1) (anyOf 1) | Model | Alternative | Expand List users — response body — item |
author (anyOf 1) (anyOf 2) | Model | Alternative | Expand Re-run a workflow — response body |
author (anyOf 2) | null | Alternative | |
comments_url | string | Required within parent | Format: uri |
commit | object | Required within parent | |
commit.author | Model | Required within parent | Expand Get a commit — response body — commit author |
commit.comment_count | JSON | Required within parent | |
commit.comment_count (anyOf 1) | integer | Alternative | |
commit.comment_count (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
commit.committer | Model | Required within parent | Expand Get a commit — response body — commit author |
commit.message | string | Required within parent | |
commit.tree | object | Required within parent | |
commit.tree.sha | string | Required within parent | |
commit.tree.url | string | Required within parent | Format: uri |
commit.url | string | Required within parent | Format: uri |
commit.verification | Model | Optional | Expand Get a tag — response body — verification |
committer | JSON | Required within parent | |
committer (anyOf 1) | JSON | Alternative | |
committer (anyOf 1) (anyOf 1) | Model | Alternative | Expand List users — response body — item |
committer (anyOf 1) (anyOf 2) | Model | Alternative | Expand Re-run a workflow — response body |
committer (anyOf 2) | null | Alternative | |
files | array | Optional | |
files[] | Model | Each item | Expand List pull requests files — response body — item |
html_url | string | Required within parent | Format: uri |
node_id | string | Required within parent | |
parents | array | Required within parent | |
parents[] | object | Each item | |
parents[].html_url | string | Optional | Format: uri |
parents[].sha | string | Required within parent | |
parents[].url | string | Required within parent | Format: uri |
sha | string | Required within parent | |
stats | object | Optional | |
stats.additions | JSON | Optional | |
stats.additions (anyOf 1) | integer | Alternative | |
stats.additions (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
stats.deletions | JSON | Optional | |
stats.deletions (anyOf 1) | integer | Alternative | |
stats.deletions (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
stats.total | JSON | Optional | |
stats.total (anyOf 1) | integer | Alternative | |
stats.total (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
url | string | Required within parent | Format: uri |
Referenced models: List pull requests files — response body — item, Re-run a workflow — response body, Get a commit — response body — commit author, List users — response body — item, Get a tag — response body — verification
Get admin branch protection — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Protected Branch Admin Enforced |
enabled | boolean | Required within parent | |
url | string | Required within parent | Format: uri |
Get branch protection — response body — required status checks
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Protected Branch Required Status Check |
checks | array | Required within parent | |
checks[] | object | Each item | |
checks[].app_id | JSON | Required within parent | |
checks[].app_id (anyOf 1) | JSON | Alternative | |
checks[].app_id (anyOf 1) (anyOf 1) | integer | Alternative | |
checks[].app_id (anyOf 1) (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
checks[].app_id (anyOf 2) | null | Alternative | |
checks[].context | string | Required within parent | |
contexts | array | Required within parent | |
contexts[] | string | Each item | |
contexts_url | string | Optional | |
enforcement_level | string | Optional | |
strict | boolean | Optional | |
url | string | Optional |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: github.repos_rename_branch. Catalog operation: repos/rename-branch. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.
Pinned headers: {"X-GitHub-Api-Version": "2026-03-10", "User-Agent": "Alter", "Accept": "application/vnd.github+json"}