edit-icon download-icon

Ensure Idempotency

Last Updated: Mar 12, 2018

If a request times out or an internal server error occurs when calling an Alibaba Cloud API to create an instance, the client may attempt to resend the request. This may cause more instances to be created than was intended.

This situation can be avoided by specifying the ClientToken parameter to ensure that the request is idempotent. A client token is a unique, case-sensitive string generated by the client, and cannot exceed 64 ASCII characters.

If the same client token is used to call an API to create an instance, the same response with the same InstanceId will be returned. Therefore, you can provide the same client token when the request is resent to guarantee that only one instance is created.

Note: The values for the parameters including SignatureNonce, TimeStamp, and Signature cannot be the same each time a request is resent. Alibaba Cloud signs the request to guarantee the security of the API calling.

Generally, a client will make a retry when a 500 (InternalError) or 503 (ServiceUnAvailable) error occurs or it does not receive a response. When the HTTP status code 200 is returned, a same response as the last time is returned without any effect on the server. However, a retry also cannot resolve the error of HTTP status code 4xx.

Note: The IdempotentParameterMismatch error will be returned if a client token, that has been used previously, is provided even though other parameters may be different.

Thank you! We've received your feedback.