If a request timeout or internal server error is encountered when calling the CreateInstance interface to create an ECS in the ECS, the client might try to resend the request. At this time, the client can prevent the server from creating more instances than expected by providing the optional ClientToken parameter. Providing the ClientTokenparameter will also ensure the idempotence of the request. ClientToken is a unique, case sensitive string generated by the client that cannot exceed 64 ASCII characters.

If a user uses the same ClientToken value to call the CreateInstance interface, the server will return identical request results, including the same InstanceId. Therefore, when the user encounters an error and tries again, providing the same ClientToken value can ensure that the ECS creates only one instance and obtains this InstanceId.

If the user provides a ClientToken that has already been used, but with different request parameters, the ECS will return the IdempotentParameterMismatch error code. However, you must note that the SignatureNonce, Timestamp, and Signature parameters must be changed when trying to submit the request again. Because the ECS uses SignatureNonce to prevent replay attacks and Timestamp to mark the time of each request, the duplicate request must provide different SignatureNonce and Timestamp parameter values. This will also produce a different Signature value.

Generally, clients will only need to retry an operation if they encounter a 500 (InternalErrorInternalError) or (ServiceUnavailable) error or cannot receive a response. When 200 is returned, retrying the operation will give you the same results as the last time, but will not have any effect on the server status. When a 4xx error code is returned, unless the message explicitly indicates "try it later", retrying the operation will usually not be successful.