Is it possible to tag a snapshot using the API?

December 3, 2019 191 views
DigitalOcean API and CLI (doctl)

I see that in the snapshots API, there is a list of “tags” per snapshot.

Is it possible to add a tag to a snapshot using the API?
Also, is it possible to fetch all the snapshots with a certain tag?

1 comment
  • To specify, I’d like to tag a droplet snapshot. A volume snapshot would be fine if it’s possible to take a snapshot of the default volume of a droplet (I don’t have any additional ones)

3 Answers

Hi @firedragondol, sorry for the confusion. You can tag Droplet Snapshots via the API - they’re considered an image, so you would pass “resource_type”:“image”

Hope this helps!

Hello,

As far as I can see this is supported. According to the official documentation currently tagging of Droplets, Images, Volumes, and Volume Snapshots is supported.

You could take a look at this part of the API documentation in order to see the exact request that you need in order to do that:

https://developers.digitalocean.com/documentation/v2/#tag-a-resource

Regarding retrieving by tag, you could take a look at this part of the documentation:

https://developers.digitalocean.com/documentation/v2/#retrieve-a-tag

Hope that this helps!
Regards,
Bobby

  • Hey @bobbyiliev I wasn’t precise enough in my question: Can I tag a droplet snapshot?

    I see I can tag volume snapshots, I’m not sure if I can create a snapshot of the default volume of a droplet (I don’t have any additional volume on the droplet beside the default one)

Hey, yes you can do it for Volumes and Snapshots of Volumes but not for Droplet Snapshot at this moment.

A Tag is a label that can be applied to a resource (currently Droplets, Images, Volumes, Volume Snapshots, and Database clusters) in order to better organize or facilitate the lookups and actions on it.

https://developers.digitalocean.com/documentation/v2/#tags

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!