# Update a repository

> Change a repository's description, website, topics and default branch, whether its default branch is protected, and whether it is private.

<div class="g1t-endpoint"><span class="g1t-method" data-method="patch">PATCH</span><code>/repos/{owner}/{name}</code></div>

Only the fields given are changed. Its description, website and topics, and protecting its default branch, need the Maintain role or higher; making it public or private and changing its default branch need the Admin role, and a free workspace takes a private repository only while its private storage has room. A protected branch refuses pushes and changes only by merging a pull request. A new default branch must already exist; open pull requests then merge into it.

Only the fields given change. `website` gets `https://` when no scheme is given; an empty string clears it. `default_branch` must name a branch that exists (`422` otherwise); it is changed after the other fields. `description`, `website`, `topics` and `protected` need the Maintain role or higher, and `private` and `default_branch` the Admin role (`403` otherwise, saying which role). Changing `private` here needs no confirmation; `POST /repos/{owner}/{name}/visibility` asks for one. Making it private is refused with `402` when a free workspace's private storage has no room for it. See [Managing a repository](/guides/managing-repositories/) and [Access and roles](/guides/access-and-roles/).

- **Authentication:** Required. Send an [access token](/reference/api/#authentication) as `Authorization: Bearer`.
- **MCP tool:** [`repository`](/reference/mcp/#repository) with `action` `update`, and the same inputs
- **Scope:** An access token needs [`repo:write`](/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 |
| --- | --- | --- | --- |
| `description` | string | No | An empty string clears it. |
| `private` | boolean | No |  |
| `protected` | boolean | No | Refuse pushes to the default branch, so that it changes only by merging a pull request. |
| `topics` | array of strings | No | Replaces its topics, which search and Explore show: lowercase letters, digits and hyphens, at most 20. An empty list clears them. |
| `website` | string | No | Its home page, an http or https address shown beside its description; https:// is added when no scheme is given. An empty string clears it. |
| `default_branch` | string | No | Make this existing branch the default: the one clones check out and pull requests merge into. |

## Example request

```sh
curl -X PATCH https://api.g1t.sh/repos/flagon-io/hello \
  -H "Authorization: Bearer $G1T_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Says hello, politely.",
    "website": "hello.g1t.page",
    "default_branch": "trunk",
    "protected": true
  }'
```

## Example response

A successful request answers `200` with:

```json
{
  "id": "rep_01m3m5q6p0e2qaw6mmjahk0qrr",
  "namespace": "flagon-io",
  "name": "hello",
  "description": "Says hello, politely.",
  "is_private": false,
  "owner_id": "usr_01kkntcg1eeb98j62xjm7eh09p",
  "default_branch": "trunk",
  "fork_of": null,
  "protected": true,
  "created_at": "2026-09-28T14:11:52.640Z",
  "topics": [
    "http",
    "example"
  ],
  "website": "https://hello.g1t.page",
  "archived_at": null
}
```

## 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. |
| 402 | `payment_required` | The workspace cannot start this work: it needs the g1t plan or a card check, or it is at a limit. See [usage and billing](/guides/usage-and-billing/#when-work-is-stopped). |
| 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. |
