Creates a policy.

Debug

Use OpenAPI Explorer to perform debug operations and generate SDK code examples.

Request parameters

Parameter Type Required? Example value Description
Action String Yes CreatePolicy

The name of this action.

Value: CreatePolicy

PolicyDocument String Yes {"Statement":[{"Action":["oss:*"],"Effect":"Allow","Resource":["acs:oss:*:*:*"]}],"Version":"1"} The policy text. It can be up to 2048 bytes.
PolicyName String Yes OSS-Administrator

The policy name. It must be 1 to 128 characters in length.

Pattern: ^[a-zA-Z0-9\-]+$

Description String No OSS administrator The policy description. It must be 1 to 1,024 characters in length.

Response parameters

Parameter Type Example value Description
Policy N/A N/A The information about the policy.
CreateDate String 2015-01-23T12:33:18Z The date and time when the policy was created.
DefaultVersion String v1 The default version.
Description String OSS administrator The policy description.
PolicyName String OSS-Administrator The policy name.
PolicyType String Custom The policy type.
RequestId String 9B34724D-54B0-4A51-B34D-4512372FE1BE The request ID.

Example

Request example

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

Response example

XML format

<CreatePolicyResponse>
  <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>
</CreatePolicyResponse>

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"
}

Errors

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