How to know if the deployment on Netlify is done via API?


I successfully deployed a site from my web app using Netlify API, but I don’t know how to get the info that if the deployment is done or not.

I thought the response from get-deploy can be the answer, especially the summary.status of that response.

I tried to keep calling the /api/v1/sites/:site_id/deploys/:deploy_id endpoint every 5 sec and watching summary.status, however, the value of summary.status has never changed from building even after the deployment has been done.

How can I get this kind of data?

Thank you.

Hi, @taishi. That API call is the correct one. The deploy in this case experienced some error and never completed. It is still running now:

If you cancel the build (via API or in the web UI), the state will change.

You can also check the state value returned by the API call for deploy status. Both summary.status and state will become “ready” for a successful build and deploy.

Hi, @luke. Thank you for your reply!

Is it an encouraged way to call the API every a few seconds to know when the deploy is done?
Or do you have a better idea?

Thank you.

Hi, @luke.

For another site has already been deployed, but the API still returns building
Deploy id is 5f7c05ebae4c38f13eda59dc.

How can I solve this?

"summary": {
  "status": "building",
  "messages": []

Thank you.

Hi, @taishi. The API is correct and working as designed. The build you linked to never completed:

There was some error during that deploy. It is still in progress. The API is correctly returning the state.

The site is published because of an earlier deploy which was successful and has a state value of “ready”, the deploy below:

The first deploy is still in state “new”.