Trigger pipelines on forked pull requests with CircleCI API v2

By default, CircleCI will not build a pull request (PR) from a forked repository on your project. However, your team can enable this by visiting Project Settings>Advanced on your project and set the Build forked pull requests option to On.

Forked PRs built on CircleCI will appear to automatically have the branch name pull/x, where x is the PR number.

However, if you would like to trigger a pipeline on this branch with the API, you will have to use a slightly different branch name: pull/x/head.

So for example, you can trigger a pipeline with a POST request to our API as follows:

curl \
-X POST --header "Content-Type: application/json" \
-d '{ "branch": "pull/${PR_BRANCH_NUM}/head" }' \{VCS}/{ORG}/{PROJECT}/pipeline

Replacing the following with the appropriate values:


PR_BRANCH_NUM = The pull request number, seen as the number in the branch as pull/x

VCS = gh or bb

ORG = VCS organization

PROJECT = VCS repository name

Was this article helpful?
1 out of 3 found this helpful



Please sign in to leave a comment.