diff --git a/doc/api/repositories.md b/doc/api/repositories.md
index bc6ca70aa50064045cdd836797a07e1a7abbb50c..fd0ef1f53eb51aa218630828367d741097091aeb 100644
--- a/doc/api/repositories.md
+++ b/doc/api/repositories.md
@@ -79,6 +79,9 @@ Parameters:
 }
 ```
 
+Will return status code `200` on success or `404 Not found` if the branch is not available.
+
+
 ## Protect a project repository branch
 
 Protect a single project repository branch.
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 5e4c564c14b120bb7fc30274bea215a5af15a62a..d416121a78a9366fff1f332d7c98d3ee72e8b9ab 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -230,7 +230,7 @@ module Gitlab
       #   GET /projects/:id/repository/branches/:branch
       get ":id/repository/branches/:branch" do
         @branch = user_project.repo.heads.find { |item| item.name == params[:branch] }
-        error!("Branch does not exist", 404) if @branch.nil?
+        not_found!("Branch does not exist") if @branch.nil?
         present @branch, with: Entities::RepoObject, project: user_project
       end