# Create Security Group Rule - CreateSecGroupRule

## Overview








## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `CreateSecGroupRule`.                      | **Yes** |
| **PublicKey**  | string  | The user's public key can be obtained from [Console](https://console.nubexcloud.com/uaccount/api_manage)                                             | **Yes** |
| **Signature**  | string  | User signature generated based on public key and API command, see [Signature Algorithm](/docs/api/summary/signature.md)  | **Yes** |

### Request Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Region** | string | Region. See [Region and Availability Zone List](/docs/api/summary/regionlist) |**Yes**|
| **ProjectId** | string | Project ID. Leave blank for the default project; sub-accounts must fill in. Please refer to the [GetProjectList API](/docs/api/summary/get_project_list) |No|
| **SecGroupId** | string | Security group resource ID that needs to add rules. |**Yes**|
| **Rule.N.Direction** | string | Ingress/Egress, Inbound Rules/Outbound Rules |**Yes**|
| **Rule.N.IPRange** | string | IP address information, comma-separated. |**Yes**|
| **Rule.N.Priority** | int | Rule Priority. Range in [1,200] |**Yes**|
| **Rule.N.ProtocolType** | string | Protocol Type. "TCP", "UDP", "ICMP", "ICMPv6", "ALL |**Yes**|
| **Rule.N.DstPort** | string | Destination port. Comma separated, such as "80,443", "443,2000-10000 |**Yes**|
| **Rule.N.RuleAction** | string | Action of rule. "Accept" or "Drop" |**Yes**|
| **Rule.N.Remark** | string | Remark of rule |**Yes**|
| **Rule.N.IPVersion** | string | IP version, such as "IPv4". Deprecated after IPv6 support |No|

### Response Field

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **RetCode** | int | Return status code. If it is 0, it means successful return. If it is not 0, it means failure. |**Yes**|
| **Action** | string | Operation command name. |**Yes**|
| **Message** | string | Returns an error message, providing detailed description when `RetCode` is non-zero. |No|
| **RuleId** | array[string] | Rule ID |**Yes**|




## Example

### Request Example
    
```
https://api.nubexcloud.com/?Action=CreateSecGroupRule
&Region=cn-zj
&ProjectId=ALLXrNsN
&SecGroupId=sTCHnCkb
&Rule.n=qJSdTFWU
&Rule.n.IPRange=hfqrGIBI
&Rule.n.Priority=8
&Rule.n.ProtocolType=VrzyUOTd
&Rule.n.DstPort=ziuMdiRW
&Rule.n.RuleAction=HMYwyODF
&Rule.n.Remark=QPIwNwmO
&Rule.N.IPVersion=ApHhfJSH
```

### Response Example
    
```json
{
  "Action": "CreateSecGroupRuleResponse",
  "RetCode": 0,
  "RuleId": [
    "HTZtyZHF"
  ]
}
```





