Creates a version for a policy.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreatePolicyVersion

The operation that you want to perform. Set the value to CreatePolicyVersion.

PolicyDocument String Yes {"Statement":[{"Action":["oss:*"],"Effect":"Allow","Resource":["acs:oss:*:*:*"]}],"Version":"1"}

The script of the policy. The content can be up to 2,048 bytes in length.

PolicyName String Yes OSS-Administrator

The name of the policy.

RotateStrategy String No None

The rotation strategy of the policy. You can use this parameter to delete an early policy version.

Valid values:

  • None: indicates no rotation strategy is set.
  • DeleteOldestNonDefaultVersionWhenLimitExceeded: indicates that the earliest non-active version is deleted if the number of versions exceeds the limit.

Default value: None.

SetAsDefault Boolean No false

Specifies whether to set the version as the default version of the policy. Default value: false.

Response parameters

Parameter Type Example Description
PolicyVersion

The information of the policy version.

CreateDate String 2015-01-23T12:33:18Z

The time when the policy version was created.

IsDefaultVersion Boolean false

Indicates whether the version is the default version of the policy.

PolicyDocument String { "Statement": [{ "Action": ["oss:*"], "Effect": "Allow", "Resource": ["acs:oss:*:*:*"]}], "Version": "1"}

The script of the policy.

VersionId String v3

The ID of the policy version.

RequestId String 9B34724D-54B0-4A51-B34D-4512372FE1BE

The ID of the request.

Examples

Sample requests


https://ram.aliyuncs.com/?Action=CreatePolicyVersion
&PolicyName=OSS-Administrator
&PolicyDocument={"Statement":[{"Action":["oss:*"],"Effect":"Allow","Resource":["acs:oss:*:*:*"]}],"Version":"1"}
&<Common request parameters>

Sample success responses

XML format

<CreatePolicyVersionResponse>
      <RequestId>9B34724D-54B0-4A51-B34D-4512372FE1BE</RequestId>
      <PolicyVersion>
            <VersionId>v3</VersionId>
            <IsDefaultVersion>false</IsDefaultVersion>
            <CreateDate>2015-01-23T12:33:18Z</CreateDate>
            <PolicyDocument>{ "Statement": [{ "Action": ["oss:*"], "Effect": "Allow", "Resource": ["acs:oss:*:*:*"]}], "Version": "1"}</PolicyDocument>
      </PolicyVersion>
</CreatePolicyVersionResponse>

JSON format

{
	"RequestId":"9B34724D-54B0-4A51-B34D-4512372FE1BE",
	"PolicyVersion":{
		"IsDefaultVersion":false,
		"VersionId":"v3",
		"PolicyDocument":"{ \"Statement\": [{ \"Action\": [\"oss:*\"], \"Effect\": \"Allow\", \"Resource\": [\"acs:oss:*:*:*\"]}], \"Version\": \"1\"}",
		"CreateDate":"2015-01-23T12:33:18Z"
	}
}

Error codes

For a list of error codes, visit the API Error Center.