Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Add a reviewer to a PR using the REST API and Forge

Every pull request needs a reviewer but who is the right person seems to be one of the most complicated questions to answer in tech :wink:. Every company and developer has a different opinion but everybody wants to automate the PR assignment.


This is why I want to show you how to assign a PR to a reviewer in a programmatic way using Forge.

Here is the function that can be used to add a reviewer:

const assignPR = async (workspaceUuid, repoUuid, pullRequestId, reviewer) => {
    const bodyData = {
        "reviewers": [{"account_id": reviewer}]

    try {
        const res = await api
        .requestBitbucket(route`/2.0/repositories/${workspaceUuid}/${repoUuid}/pullrequests/${pullRequestId}`, {
            method: 'PUT',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            body: JSON.stringify(bodyData)
        const data = await res.json();
        return data;
    } catch (error) {
        throw error;


It uses the PUT Update a pull request REST API endpoint and it takes as input the pull request details, including its workspace and repository, as well as the Atlassian Account ID (also knows as AAID) of the reviewer.


The PR author cannot be a reviewer

In Bitbucket, the PR author author cannot be added as a reviewer so you’ll need to make sure that they are not passed as parameter to the request.

If that happens, the request fails with a 400 status code and a "reviewers: Caterina Curti is the author and cannot be included as a reviewer." error message.


The reviewer must have access to the repository

If the reviewer doesn’t have access to the repository, the request fails with a 400 status code and a "reviewers: Malformed reviewers list error message".

Check that all users who might be set as reviewers have access to the repository by reviewing the Repository permissions.


New to Forge? Want to check a real-life example?

If you would like to try this logic out in a fully working app, I’ve created this one for assigning reviewers automatically when creating a PR. The list of reviewers is defined in each repository via a configuration file that the apps read.

And if you want to read more, check out the documentation and the getting started example.




Log in or Sign up to comment
AUG Leaders

Atlassian Community Events