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 a new instance to which the specified disk is attached has never been started, 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.
  • When you are creating ECS instances (RunInstances), replacing the system disk (ReplaceSystemDisk) or creating data disks (CreateDisk), snapshots cannot be created because the data initialization has not yet been completed. After creating instances or replacing the system disk, you can create a snapshot one hour later. The time it takes to create a snapshot for a new disk depends on the size of the disk data.
  • If the CreateSnapshot task is not completed, you cannot create another snapshot of the same disk.
  • If the CreateSnapshot task 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.
SnapshotName 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 Description of the snapshot.
  • Can contain [2, 256] characters in length.
  • You cannot start with http:// and https://.
Default: empty
ClientToken String No Guarantees 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.
Tag.n.Key String Yes The key of a tag of which n is from 1 to 20. Once you use this parameter, it cannot be a null string. It can be up to 64 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://".
Tag.n.Value String Yes The value of a tag of which n is a number from 1 to 20. Once you use this parameter, it can be a null string. It can be up to 128 characters in length. It cannot begin with "aliyun", "acs:", "http://", or "https://".

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 information, see API Error Center.

Error code Error message HTTP status code Description
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 specified SnapshotName 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 specified DiskId.
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..
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.