Bitbucket Data Center API Client
    Preparing search index...

    Class RepositoryResource

    Represents a Bitbucket repository resource with chainable async methods.

    Implements PromiseLike<BitbucketRepository> so it can be awaited directly to fetch repository info, while also exposing sub-resource methods.

    // Await directly to get repository info
    const repo = await bbClient.project('PROJ').repo('my-repo');

    // Get pull requests
    const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });

    // Navigate into a specific pull request
    const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();

    // Get commits
    const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });

    Implements

    Index

    Methods

    • Downloads an archive (zip/tar) of this repository's content at a given ref.

      GET /rest/api/latest/projects/{key}/repos/{slug}/archive

      Parameters

      • Optionalparams: ArchiveParams

        Optional: at, format ('zip' default, 'tar', 'tar.gz', 'tgz'), filename, path (one or many, to archive a subset), prefix

      Returns Promise<ArrayBuffer>

      The archive's raw bytes; wrap with Buffer.from(...) in Node.js to write it to disk

      const archive = await bbClient.project('PROJ').repo('my-repo').archive({ format: 'tgz' });
      await fs.promises.writeFile('my-repo.tgz', Buffer.from(archive));
    • Browses the contents of a directory or file in this repository.

      GET /rest/api/latest/projects/{key}/repos/{slug}/browse/{srcPath}

      Parameters

      • OptionalsrcPath: string

        Path to browse (e.g., 'src' or 'src/index.ts'). Omit to browse the root.

      • Optionalparams: BrowseParams

        Optional: at (branch/tag/commit), type, blame, noContent, limit, start

      Returns Promise<BitbucketBrowseResponse>

      The browse response with path info and children

    • Creates a new branch in this repository.

      POST /rest/api/latest/projects/{key}/repos/{slug}/branches

      Parameters

      • data: CreateBranchData

        name and startPoint (commit SHA or ref), plus an optional message

      Returns Promise<BitbucketBranch>

      The created branch

    • Creates a ref restriction (branch permission) on this repository.

      POST /rest/branch-permissions/latest/projects/{key}/repos/{slug}/restrictions

      Parameters

      Returns Promise<BitbucketRefRestriction>

      The created restriction

      Sends a single restriction as application/json. The endpoint also supports bulk creation of several restrictions in one call with the application/vnd.atl.bitbucket.bulk+json media type, which this client does not wrap — issue one call per restriction instead.

    • Creates a new tag in this repository.

      POST /rest/git/latest/projects/{key}/repos/{slug}/tags

      Parameters

      • data: CreateTagData

        name and startPoint (commit SHA or ref); include message for an annotated tag

      Returns Promise<BitbucketTag>

      The created tag

    • Deletes all default tasks from this repository.

      DELETE /rest/default-tasks/latest/projects/{key}/repos/{slug}/tasks

      Returns Promise<void>

    • Deletes this repository's auto-decline settings, falling back to the project-level (or instance-level) setting.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/settings/auto-decline

      Returns Promise<void>

    • Deletes this repository's pull request auto-merge settings, falling back to the project-level (or instance-level) setting.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/settings/auto-merge

      Returns Promise<void>

    • Deletes a branch from this repository.

      DELETE /rest/branch-utils/latest/projects/{key}/repos/{slug}/branches

      Parameters

      • data: DeleteBranchData

        name of the branch to delete, plus an optional dryRun flag

      Returns Promise<void>

    • Deletes a ref restriction from this repository.

      DELETE /rest/branch-permissions/latest/projects/{key}/repos/{slug}/restrictions/{id}

      Parameters

      • id: number

        The restriction's numeric id

      Returns Promise<void>

    • Deletes a default reviewer condition from this repository.

      DELETE /rest/default-reviewers/latest/projects/{key}/repos/{slug}/condition/{id}

      Parameters

      • id: number

        The condition's numeric id

      Returns Promise<void>

    • Deletes a default task from this repository.

      DELETE /rest/default-tasks/latest/projects/{key}/repos/{slug}/tasks/{taskId}

      Parameters

      • taskId: number

        The task's numeric id

      Returns Promise<void>

    • Deletes a required-builds merge check condition from this repository.

      DELETE /rest/required-builds/latest/projects/{key}/repos/{slug}/condition/{id}

      Parameters

      • id: number

        The condition's numeric id

      Returns Promise<void>

    • Deletes a reviewer group from this repository.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/settings/reviewer-groups/{id}

      Parameters

      • id: number

        The reviewer group's numeric id

      Returns Promise<void>

    • Deletes a tag from this repository.

      DELETE /rest/git/latest/projects/{key}/repos/{slug}/tags/{name}

      Parameters

      • tagName: string

        Short name of the tag to delete (e.g., 'v1.0.0')

      Returns Promise<void>

    • Deletes a webhook from this repository.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/webhooks/{webhookId}

      Parameters

      • webhookId: number

        The webhook's numeric id

      Returns Promise<void>

    • Lists the paths of all files in this repository (recursively) at a given ref.

      GET /rest/api/latest/projects/{key}/repos/{slug}/files[/{path}]

      Parameters

      • Optionalpath: string

        Directory to list; omit to list from the repository root

      • Optionalparams: FilesParams

        Optional limit, start, and at (branch/tag/commit)

      Returns Promise<PagedResponse<string>>

      A paged response of file paths

    • Fetches the settings stored for a repository hook on this repository.

      GET /rest/api/latest/projects/{key}/repos/{slug}/settings/hooks/{hookKey}/settings

      Parameters

      • hookKey: string

        The hook's module key

      Returns Promise<HookSettings>

      The hook's settings (shape defined by the hook itself)

    • Fetches the raw content of a file in this repository.

      GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}

      Parameters

      • filePath: string

        Path to the file (e.g., 'src/index.ts')

      • Optionalparams: RawFileParams

        Optional: at (branch, tag, or commit SHA)

      Returns Promise<string>

      The raw file content as a string

    • Revokes all of a group's permissions on this repository.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/permissions/groups?name={name}

      Parameters

      • name: string

        The group's name

      Returns Promise<void>

    • Removes a label from this repository.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/labels/{labelName}

      Parameters

      • name: string

        The label name

      Returns Promise<void>

    • Revokes all of a user's permissions on this repository.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/permissions/users?name={name}

      Parameters

      • name: string

        The user's username/slug

      Returns Promise<void>

    • Fetches the members of a reviewer group who are licensed and hold REPO_READ permission on this repository.

      GET /rest/api/latest/projects/{key}/repos/{slug}/settings/reviewer-groups/{id}/users

      Parameters

      • id: number

        The reviewer group's numeric id

      Returns Promise<BitbucketUser[]>

      An array of users (not paged)

    • Sets the default branch of this repository.

      PUT /rest/api/latest/projects/{key}/repos/{slug}/default-branch

      Parameters

      • branch: SetDefaultBranchData

        The full ref ID to set as default (e.g., { id: 'refs/heads/main' })

      Returns Promise<void>

    • Grants or changes a group's permission level on this repository.

      PUT /rest/api/latest/projects/{key}/repos/{slug}/permissions/groups?name={name}&permission={permission}

      Parameters

      • name: string

        The group's name

      • permission: RepositoryPermission

        'REPO_READ', 'REPO_WRITE', or 'REPO_ADMIN'

      Returns Promise<void>

    • Grants or changes a user's permission level on this repository.

      PUT /rest/api/latest/projects/{key}/repos/{slug}/permissions/users?name={name}&permission={permission}

      Parameters

      • name: string

        The user's username/slug

      • permission: RepositoryPermission

        'REPO_READ', 'REPO_WRITE', or 'REPO_ADMIN'

      Returns Promise<void>

    • Fetches the size of this repository.

      GET /rest/api/latest/projects/{key}/repos/{slug}/sizes

      Returns Promise<BitbucketRepositorySize>

      The repository size object

      This endpoint is not part of the official Bitbucket Data Center REST API documentation. It is a well-known internal endpoint used by the Bitbucket UI and may change or be removed without notice in future versions.

    • Manually synchronizes a ref of this fork with upstream, resolving a diverged or orphaned state with the given action.

      POST /rest/sync/latest/projects/{key}/repos/{slug}/synchronize

      Parameters

      • data: RefSyncRequest

        refId and action ('MERGE', 'REBASE', or 'DISCARD'), plus optional context.commitMessage for merges

      Returns Promise<SyncRef | undefined>

      The ref if it could not be synchronized cleanly, or undefined on success

    • Fetches the fork synchronization status of this repository.

      GET /rest/sync/latest/projects/{key}/repos/{slug}

      Parameters

      • Optionalat: string

        Optional ref id to restrict the status to (e.g. 'refs/heads/main')

      Returns Promise<RefSyncStatus>

      The synchronization status

    • Fetches tags associated with a list of commits.

      POST /rest/api/latest/projects/{key}/repos/{slug}/tags

      Parameters

      • commits: string[]

        Array of commit SHAs to look up tags for

      • Optionaloptions: { apiPath?: string }

        Optional overrides (e.g. apiPath to target a different API version)

      Returns Promise<PagedResponse<BitbucketTag>>

      A paged response of tags

    • Removes the authenticated user as a watcher of this repository.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/watch

      Returns Promise<void>

    • Replaces the settings stored for a repository hook on this repository.

      PUT /rest/api/latest/projects/{key}/repos/{slug}/settings/hooks/{hookKey}/settings

      Parameters

      • hookKey: string

        The hook's module key

      • settings: HookSettings

        The full replacement settings object

      Returns Promise<HookSettings>

      The stored settings

    • Adds the authenticated user as a watcher of this repository.

      POST /rest/api/latest/projects/{key}/repos/{slug}/watch

      Returns Promise<void>