# Update

`PATCH /workspaces/:workspace/projects/:project_name/repository/branches/:name`

Updates the access permissions of a branch

**Required Scopes:** `REPOSITORY_WRITE`

## URL Parameters

```typescript
interface URLParameters {
  /** The human-readable ID of the workspace */
  workspace: string; // Example: "my-company"
  /** The human-readable ID of the project */
  project_name: string; // Example: "my-project"
  /** The name of the branch */
  name: string; // Example: "main"
}
```

## Body Parameters

```typescript
interface BodyParameters {
  /** Access permissions configuration */
  permissions?: PermissionsView;
}
```

## Response Body

```typescript
interface ResponseBody {
  /** API endpoint to GET this object */
  url?: string;
  /** Web URL to view this object in Buddy.works */
  html_url?: string;
  /** The name of the branch */
  name?: string;
  /** The commit containing the revision field */
  commit?: ShortCommitView;
  /** The description of the branch */
  description?: string;
  /** Access permissions configuration */
  permissions?: PermissionsView;
  /** Indicates whether this branch is default branch in the repository */
  default?: boolean;
}
```

## Type Definitions

```typescript
interface PermissionsView {
  /** Access level for other workspace members */
  others?: "DENIED" | "READ_ONLY" | "USE_ONLY" | "BLIND" | "RUN_ONLY" | "READ_WRITE" | "MANAGE" | "DEFAULT" | "ALLOWED" | "STAGE" | "COMMIT";
  /** List of specific users with their access levels */
  users?: UserPermissionView[];
  /** List of user groups with their access levels */
  groups?: GroupPermissionView[];
}

interface UserPermissionView {
  /** The ID of the user */
  id?: number;
  /** The access level for the user */
  access_level?: "DENIED" | "READ_ONLY" | "USE_ONLY" | "BLIND" | "RUN_ONLY" | "READ_WRITE" | "MANAGE" | "DEFAULT" | "ALLOWED" | "STAGE" | "COMMIT";
}

interface GroupPermissionView {
  /** The ID of the group */
  id?: number;
  /** The access level for the group */
  access_level?: "DENIED" | "READ_ONLY" | "USE_ONLY" | "BLIND" | "RUN_ONLY" | "READ_WRITE" | "MANAGE" | "DEFAULT" | "ALLOWED" | "STAGE" | "COMMIT";
}

interface ShortCommitView {
  /** API endpoint to GET this object */
  url?: string;
  /** Web URL to view this object in Buddy.works */
  html_url?: string;
  /** The full SHA hash of the commit */
  revision?: string;
  /** The date when the commit was authored */
  author_date?: string;
  /** The date when the commit was committed */
  commit_date?: string;
  /** The short SHA hash of the commit (first 7 characters) */
  short_revision?: string;
  /** The commit message */
  message?: string;
  /** User/member reference */
  committer?: MemberView;
  /** User/member reference */
  author?: MemberView;
}

interface MemberView {
  /** API endpoint to GET this object */
  url?: string;
  /** Web URL to view this object in Buddy.works */
  html_url?: string;
  /** The ID of the user */
  id?: number;
  /** The name of the user */
  name?: string;
  /** The unique username of the user */
  username?: string;
  /** The avatar URL of the user */
  avatar_url?: string;
  /** The email address of the user */
  email?: string;
  /** Whether the user has admin privileges */
  admin?: boolean;
  /** Whether the user is workspace owner */
  workspace_owner?: boolean;
}

```

## Request Example

```bash
curl -X PATCH "https://api.buddy.works/workspaces/:workspace/projects/:project_name/repository/branches/:name" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
  "permissions": {
    "others": "READ_ONLY",
    "users": [
      {
        "id": 42,
        "access_level": "READ_WRITE"
      }
    ],
    "groups": [
      {
        "id": 15,
        "access_level": "READ_ONLY"
      }
    ]
  }
}'
```

## Response Example

**Status:** `200 OK`

```json
{
  "url": "https://api.buddy.works/workspaces/my-workspace/projects/my-project/repository/branches/master",
  "html_url": "https://app.buddy.works/my-workspace/my-project/repository/branch/master",
  "name": "master",
  "commit": {
    "url": "https://api.buddy.works/workspaces/my-workspace/projects/my-project/repository/commits/a089d82fe56335c8abd8790859bba925ad10f9d1",
    "html_url": "https://app.buddy.works/my-workspace/my-project/repository/commit/a089d82fe56335c8abd8790859bba925ad10f9d1",
    "revision": "a089d82fe56335c8abd8790859bba925ad10f9d1",
    "author_date": "2025-10-10T04:23:04Z",
    "commit_date": "2025-10-10T04:23:04Z",
    "message": "Added vitest-output.xml",
    "committer": {
      "url": "https://api.buddy.works/workspaces/my-workspace/members/1",
      "html_url": "https://app.buddy.works/my-workspace/-/profile/1",
      "id": 1,
      "name": "John Doe",
      "avatar_url": "https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/32/32/AVATAR.png?ts=1760014081477",
      "email": "john.doe@company.com",
      "admin": true,
      "workspace_owner": true
    },
    "author": {
      "url": "https://api.buddy.works/workspaces/my-workspace/members/1",
      "html_url": "https://app.buddy.works/my-workspace/-/profile/1",
      "id": 1,
      "name": "John Doe",
      "avatar_url": "https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/32/32/AVATAR.png?ts=1760014081477",
      "email": "john.doe@company.com",
      "admin": true,
      "workspace_owner": true
    }
  },
  "description": "",
  "default": true
}
```

---
Original source: https://buddy.works/docs/api/version-control/branches/update