Redeploy a branch in a site with the latest git commit using Netlify API

I use Gridsome for Static Site Generation and I integrated Bitbucket with Netlify, so when I add a new commit it directly redeploys my site with the latest commit.
Sometimes I need to redeploy without any changes in the project files, just to get the latest changes in the Database.

I want to add a button to my site when click, it uses Netlify API for redeploying with the latest Git commit, How can I do that with Netlify API?

Hey @Mina_Nasser,

For branch deploys, you’d have to use the retry deploy endpoint for a previous deploy for that branch. Currently, there’s no way to trigger a build for a branch via the API.

Hey @hrishikesh Do you have any updates on this one? Is it now possible to trigger a build via API? Like the one in Netlify UI?

Btw, I don’t see any retry deploy endpoint in the getDeploy response Netlify API documentation. Can you point me to correct location if I’m looking into wrong part of the documentation?

Hi, @burakslt. You can make the same API call that the UI does. There is a support guide about how to copy the API calls the UI makes here:

What @hrishikesh is saying is that the API call the UI makes takes a deploy id as a parameter to deploy the same branch again. You would need to know the deploy ids of a previous deploy of that same branch to use that workflow.

I do have another suggestion that might meet your requirements. That would be to use a webhook to trigger deploys as documented here:

With that webhook workflow, you can tell it what branch to trigger the build for using a parameter in the webhook URL:

If the webhooks don’t meet your requirements or if there are other questions, please let us know.