You can call this operation to create 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 CreatePolicy

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

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

The content of the policy.

It must be 1 to 2,048 bytes in length.

PolicyName String Yes OSS-Administrator

The name of the policy.

The name must be 1 to 128 characters in length, and can contain letters, digits, and hyphens (-).

Description String No OSS administrator

The description of the policy.

The description must be 1 to 1,024 characters in length.

Response parameters

Parameter Type Example Description
Policy N/A N/A

The information about the policy.

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

The time when the policy was created.

DefaultVersion String v1

The default version.

Description String OSS administrator

The description of the policy.

PolicyName String OSS-Administrator

The name of the policy.

PolicyType String Custom

The type of the policy.

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

The ID of the request.

Examples

Sample requests


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

Sample success responses

XML format

<RequestId>9B34724D-54B0-4A51-B34D-4512372FE1BE</RequestId>
<Policy>
    <PolicyName>OSS-Administrator</PolicyName>
    <PolicyType>Custom</PolicyType>
    <Description>OSS administrator</Description>
    <DefaultVersion>v1</DefaultVersion>
    <CreateDate>2015-01-23T12:33:18Z</CreateDate>
</Policy>

JSON format

{
	"Policy":{
		"Description":"OSS administrator",
		"PolicyName":"OSS-Administrator",
		"CreateDate":"2015-01-23T12:33:18Z",
		"DefaultVersion":"v1",
		"PolicyType":"Custom"
	},
	"RequestId":"9B34724D-54B0-4A51-B34D-4512372FE1BE"
}

Error codes

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