Updated on 2026-07-29 GMT+08:00

Creating a Policy

Function

This API is used to create a policy of the specified type. It can be called only from the organization's management account.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    organizations:policies:create

    Write

    -

    • g:RequestTag/<tag-key>

    • g:TagKeys

    -

    organizations:resources:tag

URI

POST /v1/organizations/policies

Request Parameters

Table 1 Request header parameters

Parameter

Mandatory

Type

Description

X-Security-Token

No

String

Definition

Security token (session token) of your temporary security credentials. If a temporary security credential is used, this header is required.

Constraints

N/A

Range

The value contains 0 to 32,768 characters.

Default Value

No default value

X-Language

No

String

Definition

Language of the returned results.

Constraints

Mandatory

Range

None

Default Value

None

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

content

Yes

String

Definition

Policy text content to be added to the new policy.

Constraints

Mandatory

Range

None

Default Value

None

description

Yes

String

Definition

Optional description to be assigned to the policy.

Constraints

Mandatory

Range

The value must comply with the regular expression ^[\s\S]*$.

The value contains 1 to 512 characters.

Default Value

No default value

name

Yes

String

Definition

Name to be assigned to the policy.

Constraints

Mandatory

Range

The value must comply with the regular expression ^[\u4e00-\u9fa5a-zA-Z0-9_- ]+$.

The value contains 1 to 64 characters.

Default Value

No default value

type

Yes

String

Definition

Type of the policy to be created. It can be service_control_policy or tag_policy.

Constraints

Mandatory

Range

Enumerated values: service_control_policy and tag_policy.

Default Value

No default value

tags

No

Array of TagDto objects

Definition

List of tags you want to attach to the new policy.

Constraints

N/A

Range

0 to 20 tags

Default Value

No default value

Table 3 TagDto

Parameter

Mandatory

Type

Description

key

Yes

String

Definition

Identifier or name of the tag key.

Constraints

Mandatory

Range

The value must comply with the regular expression ^((?!sys|\s)[\p{L}\p{Z}\p{N}.:=+-@]*[\p{L}\p{N}.:=+-@])$.

The value contains 1 to 128 characters.

Default Value

None

value

Yes

String

Definition

String value associated with the tag key. You can set the tag value to an empty string, but cannot set it to NULL.

Constraints

Mandatory

Range

The value must comply with the regular expression ^([\p{L}\p{Z}\p{N}_.:/=+-@]*)$.

The value contains 0 to 255 characters.

Default Value

None

Response Parameters

Status code: 201

Table 4 Response body parameters

Parameter

Type

Description

policy

PolicyDto object

Definition

Policy details.

Constraints

Mandatory

Range

N/A

Default Value

No default value

Table 5 PolicyDto

Parameter

Type

Description

content

String

Definition

Text content of the policy.

Constraints

Mandatory

Range

The value must comply with the regular expression ^[\s\S]*$.

The value contains 0 to 20,000 characters.

Default Value

None

policy_summary

PolicySummaryDto object

Information about a policy (policy content not included).

Table 6 PolicySummaryDto

Parameter

Type

Description

is_builtin

Boolean

Definition

A boolean value indicating whether the specified policy is a system-defined policy. If the value is true, the policy is a system-defined policy. You can attach the policy to roots, OUs, or accounts, but you cannot edit it.

Constraints

Mandatory

Range

Boolean value: true or false

Default Value

None

description

String

Definition

Policy description.

Constraints

Mandatory

Range

The value must comply with the regular expression ^[\s\S]*$.

The value contains a maximum of 512 characters.

Default Value

No default value

id

String

Definition

Unique ID of a policy.

Constraints

Mandatory

Range

The value must comply with the regular expression ^p-[0-9a-zA-Z_]{8,128}$.

The value contains 1 to 130 characters.

Default Value

No default value

urn

String

Definition

Uniform resource name of the policy.

Constraints

Mandatory

Range

The value contains 1 to 1,500 characters.

Default Value

No default value

name

String

Definition

Policy name.

Constraints

Mandatory

Range

The value must comply with the regular expression ^[\u4e00-\u9fa5a-zA-Z0-9_- ]+$.

The value contains 1 to 64 characters.

Default Value

No default value

type

String

Definition

Policy type. The value can be service_control_policy or tag_policy.

Constraints

Mandatory

Range

The value contains 1 to 64 characters.

Default Value

No default value

Example Requests

Creating a policy

POST https://{endpoint}/v1/organizations/policies

{
  "content" : "{\"Version\":\"5.0\",\"Statement\":[{\"Sid\":\"Statement1\",\"Effect\":\"Allow\",\"Action\":[\"*\"],\"Resource\":[\"*\"]}]}",
  "description" : "auto0923160642938XHxSPolicydesc",
  "name" : "auto092316064293806EYPolicyName",
  "type" : "service_control_policy",
  "tags" : [ {
    "key" : "keystring",
    "value" : "valuestring"
  } ]
}

Example Responses

Status code: 201

Successful.

{
  "policy" : {
    "content" : "{\"Version\":\"5.0\",\"Statement\":[{\"Sid\":\"Statement1\",\"Effect\":\"Allow\",\"Action\":[\"*\"],\"Resource\":[\"*\"]}]}",
    "policy_summary" : {
      "is_builtin" : false,
      "description" : "auto0923160642938XHxSPolicydesc",
      "id" : "p-b4wpejd02o66g0pvfinvsatp4t9krfum",
      "urn" : "organizations::0a6d25d23900d45c0faac010e0fb4de0:policy:o-fhkmi6mek7wlqdp6nideqhb47qwtjdsv/service_control_policy/p-b4wpejd02o66g0pvfinvsatp4t9krfum",
      "name" : "auto092316064293806EYPolicyName",
      "type" : "service_control_policy"
    }
  }
}

Status Codes

Status Code

Description

201

Successful.

Error Codes

See Error Codes.