Creates a snapshot for a specified disk device. 

Description

When you call this interface, consider the following:

  • The maximum number of snapshots you can create for a disk is 64.

  •  The ECS instance to which the specified disk is attached must be in the Stopped (Stopped) or Running (Running) status.

  • The disk must be attached to an instance.

  • If an instance to which the specified disk is attached has never been started after creation, you cannot create a snapshot.

  • If the specified instance is locked, and the OperationLocks of the instance indicates LockReason: "security", a snapshot cannot be created.

  • Create a new ECS  (RunInstances), replace the system tray (ReplaceSystemDisk) alternatively, you cannot create a snapshot because the data load has not yet been completed, depending on the snapshot's new data tray  (CreateDisk). Create a new ECS instance or you can create a snapshot after you replace the system tray for about 1 hour. The time it takes to add a data disk to create a snapshot depends on the size of the disk data.

  • If snapshot creation is not completed, you cannot create another snapshot of the same disk.

  • If snapshot creation is not completed, this snapshot cannot be used to create a custom image  (CreateImage).

Request parameters

Name Type Required Description
Action String Yes The name of this interface. Value: CreateSnapshot
DiskId String Yes Disk ID.
SnapshopName String No The name of a snapshot.
  • Length: [2, 128] English letters or Chinese characters.
  • Must begin with an uppercase or lowercase English letter. Can contain digits, underscores (_), colons (:), or hyphens (-).
  • Cannot begin with auto , because snapshot names starting with auto are recognized as automatic  snapshots.
  • Cannot begin with http:// or https://.
Description String No Cannot begin with http:// or https://.
  • Can contain [2, 256] characters in length.
  • You cannot start with http: // and https.
Default: empty
ClientToken String No Used to guarantee the idempotence of the request. The value is generated by a client. It must be unique among all requests and contain a maximum of 64 ASCII characters. For more information, see How to ensure idempotence.

Return parameters

Name Type Description
SnapshotId String The snapshot ID.

Example

Request example
https://ecs.aliyuncs.com/?Action=CreateSnapshot
&DiskId=1033-60053321
&<Common request parameter>
Response sample

XML format

<CreateSnapshotResponse>
        <RequestId>C8B26B44-0189-443E-9816-D951F59623A9</RequestId>
        <SnapshotId>s-923FE2BF0</SnapshotId>
</CreateSnapshotResponse>
JSON format
{
    "RequestId": "C8B26B44-0189-443E-9816-D951F59623A9",
    "SnapshotId": "s-923FE2BF0"
}

Error codes

Error codes specific to this interface are as follows. For more error codes, see API Error Center.

Error code Error message HTTP status code Note
DiskCategory.OperationNotSupported The operation is not supported to the specified disk due to its disk Category 400 You cannot create a snapshot for the specified disk because of its category.
IncorrectInstanceStatus The current status of the resource does not support this operation. 400 The instance of disk Mount must be in Stopped (Stopped), or Running (Running) status.
InvalidSnapshotName.Malformed The specified SnapshotName is wrongly formed. 400 The specifiedSnapshotName is invalid.
CreateSnapshot.Failed The process of creating snapshot failed. 403 Snapshot creation has failed.
DiskId.ValueNotSupported The specified parameter diskid is not supported. 403 You cannot create snapshots for the specifiedDiskId.
DiskInArrears The specified operation is denied as your disk has expired. 403 The disk has an overdue payment. Try again after your clear your overdue payment.
IncorrectDiskStatus The current disk status does not support this operation. 403 The specified disk must be in the In_use (In_use) status.
IncorrectDiskStatus.CreatingSnapshot A previous snapshot creation is in process. 403 A snapshot for the specified disk is being created.  Please try again later.
IncorrectDiskStatus.NeverAttached The specified disk has never been attached to any instance. 403 The disk must have been attached to an instance.
IncorrectDiskStatus.NeverUsed The specified disk has never been used after creating. 403 The disk has not been used and the snapshot cannot be created.
InstanceLockedForSecurity The disk attached instance is locked due to security. 403 The specified instance has been locked for security.
InvalidAccountStatus.NotEnoughBalance Your account does not have enough balance. 403 You registered credit card is invalid. Or insufficient balance in your PayPal account.  You have an overdue payment.
InvalidAccountStatus.SnapshotServiceUnavailable Snapshot service has not been opened yet. 403 You have not activated the service. Please open a ticket to activate it .
QuotaExceed.Snapshot The maximum number of snapshots is exceeded. 403  You have exceeded the snapshot creation limit. The maximum number of snapshots you can create for a disk is 64.
InvalidDescription.Malformed The specified description is wrongly formed. 404 The specified target image Description is invalid.
InvalidDiskId.NotFound The specified DiskId does not exist. 404 The specified disk does not exist.