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

Hi.

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:

https://app.netlify.com/sites/lucid-meitner-859e79/deploys/5f7bb62f4c79058a744a4f32

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 boring-hoover-febc29.netlify.app 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:

https://app.netlify.com/sites/boring-hoover-febc29/deploys/5f7c05ebae4c38f13eda59dc

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:

https://app.netlify.com/sites/boring-hoover-febc29/deploys/5f7c05ea8651132ab34e552c

The first deploy is still in state “new”.