Deployment identifier -- how to get it?

Hi. I am using the Mender API to create a new deployment for a device. That’s working (I can see the deployment in the web UI), but I’d like to monitor the progress in my program.

Show Deployment (Mender API docs) looks good for that, but it requires a “deployment identifier”.

When issuing the Create Deployment (Mender API docs), a response code of 200 is returned on success, but it has no schema. So there’s no response which might include a deployment ID.

There are a number of other API functions which take a deployment ID as a parameter or as part of the URL that you Get/Post as well, including “Abort Deployment” and " List All Devices in Deployment".

The return schema of Get Device Configuration (Mender API docs) indicates deployment_id as one of the fields, but the response to that Get doesn’t actually include it. Rather, with Response code 200, I’m seeing just id (the overall device ID, not deployment_id), configured (empty), reported (empty) and updated_ts.

Where does the deployment ID come from?

Thanks,
Steve

Thanks,
Steve

Hi @sschefter,

You should be able to obtain the deployment ID via the “List deployments” endpoint: Mender API docs

Greetz,
Josef

Thanks Josef.

When I use “List deployments”, I get back information on 20 deployments that I created for my device over the last week (lots of testing). It seems like the latest deployment is the first one. Do you know if I can rely on that?

Regards,
Steve

Unfortunately, it isn’t the case that the first deployment is the latest one. In fact, when I kick off a new deployment, it is not appearing on the received list at all.

I can kick off a new deployment and see it in the Web UI and see it in state “Pending (awaiting devices)”. When I issue a Get at https://hosted.mender.io/api/management/v1/deployments/deployments/devices/3a0297f6-7f8c-4df6-bf80-f54b7e6d8989, I receive a list of 20 deployments for the device. However, the newest one at the top of the list is dated yesterday.

Even more oddly, the deployments in the list are not even for the device ID indicated in the URL:

url = https://hosted.mender.io/api/management/v1/deployments/deployments/devices/3a0297f6-7f8c-4df6-bf80-f54b7e6d8989

My device ID 3a0297f6-7f8c-4df6-bf80-f54b7e6d8989

Response:
ID = “2a25eaa9-ddc0-4c36-be39-60ed3396fbea”
Deployment ID = “3dd39101-b0eb-4c41-b6ea-dda2cc0b8def”
Created = “2024-12-16T21:59:10.375Z”
Status = “finished”
ID = “d283c788-dfae-40c3-bfed-934465151312”
Deployment ID = “058efa84-44cb-4de0-9cee-2476cee643a6”
Created = “2024-12-16T21:04:52.106Z”
Status = “finished”
ID = “8e247c1a-edd1-4264-888c-a6b585f70579”
Deployment ID = “7b67ad96-849b-4f9d-867f-607eb3901c5c”
Created = “2024-12-16T20:38:16.606Z”
Status = “finished”

Regards,
Steve

Hi @sschefter,

I’ve asked the server people, and they suggest to use the response of the “Create Deployment” endpoint call as documented at Mender API docs. According to them this directly gives you the deployment ID. Might that work for you?

Greetz,
Josef

Hi Josef.

That was my first idea as well, but unfortunately that’s not possible. As I noted in my first post, the “Create Deployment” API (Mender API docs) for response code 201 (Created) has no schema. That is, there’s no return data at all and therefore no deployment ID.

Regards,
Steve

Hi @sschefter,

It’s not in the response data, but the location header. Please see the corresponding source code of the Mender Web UI on how it is being used there: mender-server/frontend/src/js/store/deploymentsSlice/thunks.ts at main · mendersoftware/mender-server · GitHub

Greetz,
Josef

Hi Josef.

Awesome, thank you very much.

Regards,
Steve