Skip to main content

snapshots

Creates, updates, deletes, gets or lists a snapshots resource.

Overview​

Namesnapshots
TypeResource
Iddigitalocean.compute.snapshots

Fields​

The following fields are returned by SELECT queries:

A JSON object with a key called snapshot.

NameDatatypeDescription
idstringThe unique identifier for the snapshot. (example: 6372321)
namestringA human-readable name for the snapshot. (example: web-01-1595954862243)
resource_idstringThe unique identifier for the resource that the snapshot originated from. (example: 200776916)
created_atstring (date-time)A time value given in ISO8601 combined date and time format that represents when the snapshot was created. (example: 2020-07-28T16:47:44Z)
min_disk_sizeintegerThe minimum size in GB required for a volume or Droplet to use this snapshot.
regionsarrayAn array of the regions that the snapshot is available in. The regions are represented by their identifying slug values.
resource_typestringThe type of resource that the snapshot originated from. (droplet, volume) (example: droplet)
size_gigabytesnumber (float)The billable size of the snapshot in gigabytes.
tagsarrayAn array of Tags the snapshot has been tagged with.

Requires tag:read scope.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
snapshots_getselectsnapshot_idTo retrieve information about a snapshot, send a GET request to
/v2/snapshots/$SNAPSHOT_ID.

The response will be a JSON object with a key called snapshot. The value of
this will be an snapshot object containing the standard snapshot attributes.
snapshots_listselectper_page, page, resource_typeTo list all of the snapshots available on your account, send a GET request to
/v2/snapshots.

The response will be a JSON object with a key called snapshots. This will be
set to an array of snapshot objects, each of which will contain the standard
snapshot attributes.

### Filtering Results by Resource Type

It's possible to request filtered results by including certain query parameters.

#### List Droplet Snapshots

To retrieve only snapshots based on Droplets, include the resource_type
query parameter set to droplet. For example, /v2/snapshots?resource_type=droplet.

#### List Volume Snapshots

To retrieve only snapshots based on volumes, include the resource_type
query parameter set to volume. For example, /v2/snapshots?resource_type=volume.
snapshots_deletedeletesnapshot_idBoth Droplet and volume snapshots are managed through the /v2/snapshots/
endpoint. To delete a snapshot, send a DELETE request to
/v2/snapshots/$SNAPSHOT_ID.

A status of 204 will be given. This indicates that the request was processed
successfully, but that no response body is needed.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
snapshot_idEither the ID of an existing snapshot. This will be an integer for a Droplet snapshot or a string for a volume snapshot. (example: 6372321)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)
resource_typestringUsed to filter snapshots by a resource type. (example: droplet)

SELECT examples​

To retrieve information about a snapshot, send a GET request to
/v2/snapshots/$SNAPSHOT_ID.

The response will be a JSON object with a key called snapshot. The value of
this will be an snapshot object containing the standard snapshot attributes.

SELECT
id,
name,
resource_id,
created_at,
min_disk_size,
regions,
resource_type,
size_gigabytes,
tags
FROM digitalocean.compute.snapshots
WHERE snapshot_id = '{{ snapshot_id }}' -- required
;

DELETE examples​

Both Droplet and volume snapshots are managed through the /v2/snapshots/
endpoint. To delete a snapshot, send a DELETE request to
/v2/snapshots/$SNAPSHOT_ID.

A status of 204 will be given. This indicates that the request was processed
successfully, but that no response body is needed.

DELETE FROM digitalocean.compute.snapshots
WHERE snapshot_id = '{{ snapshot_id }}' --required
;