'A pull request already exists for foo:master': Respond with URL



Trying to do some automation around Pull Requests. If I have a bot to open up a bunch of pull requests which then dumps them into a slack channel, I’d like to run it again to return the same links to the pull requests. The issue is that v3 api currently returns ‘A pull request already exists for foo:master.’, with no link or url to the existing PRs. Would be great to get a link for it?


Hi @CHR15 :wave:. This doesn’t seem like a question related to the GitHub Apps feature – it’s a more general question that’s related to the API itself, did I understand correctly? For questions about the REST API, please contacts GitHub Support via the “Support” link at the bottom of this page (and use this forum only for questions about the GitHub Apps feature and associated APIs):


As for your specific question – you’re observing expected behavior and we wouldn’t consider changing that behavior because it would probably break existing API consumers relying on the current behavior.

If you’d like to check if a pull request exists for a specific base and head branch, you can use a different API endpoint for that (notice the available parameters):


So, before creating a pull request – you can check to see if one already exists and return the link for that. Hope this helps!