# Add Routing Policy - AddRoutePolicy

## Overview

Add Routing Policy






## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `AddRoutePolicy`.                      | **Yes** |
| **PublicKey**  | string  | The user's public key can be obtained from [Console](https://console.genesissai.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 |
|:---|:---|:---|:---|
| **ProjectId** | string | Project ID. Leave it blank for the default project. Sub-accounts must fill in. Please refer to the [GetProjectList API](/docs/api/summary/get_project_list) |**Yes**|
| **UGNID** | string | UGN Instance ID |**Yes**|
| **Policy.Direction** | string | Policy direction, limited values: "In"/"Out |**Yes**|
| **Policy.Priority** | int | Policy priority, range: [1,255], the smaller the value, the higher the priority. In the same direction, policy priorities cannot be duplicated. |**Yes**|
| **Policy.Action** | string | Policy execution action, limited values: "Permit"/"Deny |**Yes**|
| **Policy.Name** | string | Policy Name, limited to 255 characters |No|
| **Policy.SrcNetworks.N.NetworkId** | string | Array of network instance IDs for the routing policy to match |No|
| **Policy.SrcNetworks.N.Prefixes.N** | string | The subnet array under the network instance of the route that the routing policy needs to match |No|
| **Policy.RoutePriority** | int | When the action is set to "Permit", assign a routing priority to the matched routes, with a range of [1,255]. The smaller the value, the higher the priority. |No|
| **Policy.SrcRegions.N** | string | Array of regions where the routing strategy needs to match the route |No|
| **Policy.SrcNetworkTypes.N** | string | The array of network instance types of the routes that need to match the routing policy, limited to the value: "VPC""". |No|
| **Policy.DstNetworkTypes.N** | string | The array of network instance types that the routing policy needs to apply to, limited to the value: "VPC |No|
| **Policy.DstNetworks.N.NetworkId** | string | Array of Network Instance IDs that the Routing Policy Needs to Apply |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|




## Example

### Request Example
    
```
https://api.genesissai.com/?Action=AddRoutePolicy
&ProjectId=uZbfBYYQ
&UGNID=vZHhDhPb
&Policy.Direction=bpBuXVOn
&Policy.Priority=2
&Policy.Action=tMgmjHyq
&Policy.SrcNetworks.n.NetworkId=VPYkZPLu
&Policy.RoutePriority=3
&Policy.SrcRegions.n=4
&Policy.SrcNetworkTypes.n=onIVXCWs
&Policy.SrcNetworks.n.Prefixes.n=JPChaqlb
&Policy.DstNetworkTypes.n=cPCdfaeP
&Policy.DstNetworks.n.NetworkId=qUmfspqL
&Policy.Name=QIfUhxHX
```

### Response Example
    
```json
{
  "Action": "AddRoutePolicyResponse",
  "Policies": [
    {
      "Action": "mGfXwdfC",
      "Direction": "AASlctBC",
      "DstNetworkTypes": [
        "DeFacVGH"
      ],
      "DstNetworks": [
        {
          "NetworkId": "SRLUbPjC",
          "Prefixes": [
            "uhLHTWeo"
          ]
        }
      ],
      "Enabled": true,
      "PolicyId": "KYcefSPo",
      "Priority": 4,
      "Region": 8,
      "RoutePriority": 7,
      "SrcNetworkTypes": [
        "IERCMZjO"
      ],
      "SrcNetworks": [
        {
          "NetworkId": "szhHfNEi",
          "Prefixes": [
            "EUDzQIrc"
          ]
        }
      ],
      "SrcRegions": [
        5
      ]
    }
  ],
  "RetCode": 0
}
```





