Deployments API Endpoint

Hello! I am interested in retrieving the deployments I perform in order to compute some DORA metrics for them. Until now I have managed to find an API endpoint to do so, which is /deployments, however I see that the response is missing some key details which are of interest such as a finished_at timestamp or a state property which indicates for example whether the deployment was a success, a failure or was cancelled. Am I looking at the wrong endpoint for gathering this information? Thanks!

Hey there @user6 - thanks for reaching out!

I want to make sure I understand the total scope of what you’re looking for, so I can get you the best resources to help you accomplish what you’re after.

First things first - if you’re looking at retrieving this data and forming calculations solely from the API, you’ll need one additional call to get the deployment details you need. If you look at the response from /api/deployments/{DeploymentID}, you’ll notice a key in the response body called TaskId - it’s also available in a handy preformed URL in the Links collection at the bottom of the API response, pointing to "/api/tasks/{ServerTaskID}".

If you take that information and query the tasks endpoint, you’ll see the data you requested - the API response from that tasks endpoint returns values for IsCompleted, FinishedSuccessfully, StartTime, CompletedTime, and a whole host of other entries to help you reason about the behavior and actions taken for the server task associated with completing the deployment.

That said, I wanted to point out some additional reporting resources that we have for OCtopus that may allow you to get at some of the data you’re interested in without having to make API calls for each bit that you’re looking for. We have two great blog posts from last year with differing technologies:

Wrapping up the non-API route, there’s a great page in our documentation around the reporting methods available - Reporting - Octopus Deploy

The tasks endpoint should help you get the data you need to calculate your DORA metrics, and hopefully the additional resources provided can offer some more insight into other avenues to pursue for retrieving that data. Feel free to reach out if you run into any other issues or questions, happy to help however I can!

1 Like

Hi, Cory! Thank you very much for your swift and detailed response. This is exactly what I was looking for! The extra resources are very much appreciated as well!