Routing Rules API
- Table of Contents
- Overview
- Attributes
- Routing Rules
- Domain Overrides
Overview
Routing Rules contain a default list of VirtualMTAs through which to deliver. It also contains a list of Domain Overrides which will supersede those defaults on a per-domain basis.
Attributes
| routing_rule hash/ required 
 | |||||||||||||||||||||||||||||||||||||
Routing Rules
Get a List of Routing Rules
GET /ga/api/v3/eng/routing_rules
GET /ga/api/v3/eng/routing_rules?page={page}
GET /ga/api/v3/eng/routing_rules?page_token={page_token}
Parameters
| page integer/ optional | The page number to retrieve. Page numbering starts at  | 
| page_token string/ optional | The  | 
Response
| routing_rules array of hashes 
 | |||||||||||
| pagination hash 
 | |||||||||||
Example
GET /ga/api/v3/eng/routing_rules
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
    "routing_rules": [
      {
        "id": 6,
        "name": "rr-1"
      },
      {
        "id": 9,
        "name": "rr-2"
      },
      {
        "id": 11,
        "name": "rr-3"
      }
    ],
    "pagination": {
      "page": 0,
      "per_page": 100,
      "num_pages": 1,
      "num_records": 3,
      "next_page_token": null
    }
  },
  "error_code": null,
  "error_messages": null
}
Get all Details About a single Routing Rule
GET /ga/api/v3/eng/routing_rules/{id}
Response
| routing_rule hash | The attributes for this hash are defined in the Attributes section of this document. | 
Example
GET /ga/api/v3/eng/routing_rules/26
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
    "routing_rule": {
      "id": 26,
      "name": "rr-1",
      "domain_overrides": [
        {
          "id": 11,
          "domains": [
            "domain-1.com",
            "domain-2.com"
          ],
          "randomization_type": "random",
          "deliver_through": [
            {
              "virtual_mta": {
                "id": 22,
                "name": "ipaddr-1"
              },
              "portion_of_mail": 30.0
            },
            {
              "virtual_mta": {
                "id": 23,
                "name": "ipaddr-2"
              },
              "portion_of_mail": 70.0
            }
          ]
        },
        {
          "id": 12,
          "domains": [
            "domain-3.com",
            "domain-4.com"
          ],
          "randomization_type": "random",
          "deliver_through": [
            {
              "virtual_mta": {
                "id": 25,
                "name": "my-relay-1"
              },
              "portion_of_mail": 100.0
            }
          ]
        }
      ],
      "default": {
        "randomization_type": "random",
        "deliver_through": [
          {
            "virtual_mta": {
              "id": 25,
              "name": "my-relay-1"
            },
            "portion_of_mail": 100.0
          }
        ]
      }
    }
  },
  "error_code": null,
  "error_messages": null
}
Create a Routing Rule
POST /ga/api/v3/eng/routing_rules
Payload
The JSON data sent to this endpoint should contain an object as described in the Attributes section of this page.
The data may contain a mixture of required and optional fields. Do not specify read-only fields.
Response
The response will include a routing_rule key containing the full Routing
Rule record as defined in the Routing Rule Attributes section.
Example
POST /ga/api/v3/eng/routing_rules
{
  "routing_rule": {
    "name": "new-routing-rule",
    "domain_overrides": [
      {
        "domains": [
          "new-domain-1.com",
          "new-domain-2.com"
        ],
        "randomization_type": "random",
        "deliver_through": [
          {
            "virtual_mta": {
              "name": "rr-1"
            },
            "portion_of_mail": 29.7712
          },
          {
            "virtual_mta": {
              "id": 32
            },
            "portion_of_mail": "20.2"
          }
        ]
      },
      {
        "domains": [
          "new-domain-3.com",
          "new-domain-4.com"
        ],
        "randomization_type": "random",
        "deliver_through": [
          {
            "virtual_mta": {
              "id": 35,
              "name": "my-relay-1"
            },
            "portion_of_mail": 100.0
          }
        ]
      }
    ],
    "default": {
      "randomization_type": "random",
      "deliver_through": [
        {
          "virtual_mta": {
            "id": 35,
            "name": "my-relay-1"
          },
          "portion_of_mail": 100.0
        }
      ]
    }
  }
}
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
    "routing_rule": {
      "id": 42,
      "name": "new-routing-rule",
      "domain_overrides": [
        {
          "id": 21,
          "domains": [
            "new-domain-1.com",
            "new-domain-2.com"
          ],
          "randomization_type": "random",
          "deliver_through": [
            {
              "virtual_mta": {
                "id": 36,
                "name": "rr-1"
              },
              "portion_of_mail": 59.6
            },
            {
              "virtual_mta": {
                "id": 32,
                "name": "ipaddr-1"
              },
              "portion_of_mail": 40.4
            }
          ]
        },
        {
          "id": 22,
          "domains": [
            "new-domain-3.com",
            "new-domain-4.com"
          ],
          "randomization_type": "random",
          "deliver_through": [
            {
              "virtual_mta": {
                "id": 35,
                "name": "my-relay-1"
              },
              "portion_of_mail": 100.0
            }
          ]
        }
      ],
      "default": {
        "randomization_type": "random",
        "deliver_through": [
          {
            "virtual_mta": {
              "id": 35,
              "name": "my-relay-1"
            },
            "portion_of_mail": 100.0
          }
        ]
      }
    }
  },
  "error_code": null,
  "error_messages": null
}
Update a Routing Rule
PUT /ga/api/v3/eng/routing_rules/{id}
Payload
| routing_rule hash This hash is described in the Attributes section of this page, with the exceptions described below. The data may contain a mixture of required and optional fields. Do not specify read-only fields. Exceptions: 
 | |||||
Response
The response will include a routing_rule key containing the full Routing Rule
record as defined in the Routing Rule Attributes section.
Example
PUT /ga/api/v3/eng/routing_rules/47
{
  "routing_rule": {
    "name": "routing-rule-new-name",
    "domain_overrides_new": [
      {
        "domains": [
          "new-rule-domain.com"
        ],
        "randomization_type": "message_constant",
        "deliver_through": [
          {
            "virtual_mta": {
              "name": "my-relay-2"
            },
            "portion_of_mail": 100
          }
        ]
      }
    ]
  }
}
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
    "routing_rule": {
      "id": 47,
      "name": "routing-rule-new-name",
      "domain_overrides": [
        {
          "id": 24,
          "domains": [
            "domain-1.com",
            "domain-2.com"
          ],
          "randomization_type": "random",
          "deliver_through": [
            {
              "virtual_mta": {
                "id": 43,
                "name": "ipaddr-1"
              },
              "portion_of_mail": 30.0
            },
            {
              "virtual_mta": {
                "id": 44,
                "name": "ipaddr-2"
              },
              "portion_of_mail": 70.0
            }
          ]
        },
        {
          "id": 25,
          "domains": [
            "domain-3.com",
            "domain-4.com"
          ],
          "randomization_type": "random",
          "deliver_through": [
            {
              "virtual_mta": {
                "id": 46,
                "name": "my-relay-1"
              },
              "portion_of_mail": 100.0
            }
          ]
        },
        {
          "id": 29,
          "domains": [
            "new-rule-domain.com"
          ],
          "randomization_type": "message_constant",
          "deliver_through": [
            {
              "virtual_mta": {
                "id": 48,
                "name": "my-relay-2"
              },
              "portion_of_mail": 100.0
            }
          ]
        }
      ],
      "default": {
        "randomization_type": "random",
        "deliver_through": [
          {
            "virtual_mta": {
              "id": 46,
              "name": "my-relay-1"
            },
            "portion_of_mail": 100.0
          }
        ]
      }
    }
  },
  "error_code": null,
  "error_messages": null
}
Delete a Routing Rule
DELETE /ga/api/v3/eng/routing_rules/{id}
Routing Rules that are currently used by other records may not be deleted. Use the VirtualMTAs API to get a list of such records.
References made to Routing Rules from GreenArrow Studio will not prevent deletion of the Routing Rule, but may in the future. Deleting a Routing Rule that is used in GreenArrow Studio by a scheduled/in-progress campaign will cause the campaign to either not send or send with the Default Virtual MTA.
Example
DELETE /ga/api/v3/eng/routing_rules/102
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
  },
  "error_code": null,
  "error_messages": null
}
Domain Overrides
Create a Domain Override
POST /ga/api/v3/eng/routing_rules/{routing_rule_id}/domain_overrides
| routing_rule_id integer/ required | The  | 
Payload
| domain_override hash/ required | The structure of this hash is the same as the entries defined in the
 All required fields must be present. Do not specify read-only fields. | 
Response
| domain_override hash/ required | The structure of this hash is the same as the entries defined in the
 | 
Example
POST /ga/api/v3/eng/routing_rules/6/domain_overrides
{
  "domain_override": {
    "domains": [
      "new-domain-1.com",
      "new-domain-2.com",
      "[*.]new-domain-3.com",
      "*.new-domain-4.com"
    ],
    "randomization_type": "email_address_constant",
    "deliver_through": [
      {
        "virtual_mta": {
          "id": 2
        },
        "portion_of_mail": 100
      },
      {
        "virtual_mta": {
          "name": "IPADDR-2"
        },
        "portion_of_mail": 25
      }
    ]
  }
}
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
    "domain_override": {
      "id": 5,
      "domains": [
        "new-domain-1.com",
        "new-domain-2.com",
        "[*.]new-domain-3.com",
        "*.new-domain-4.com"
      ],
      "randomization_type": "email_address_constant",
      "deliver_through": [
        {
          "virtual_mta": {
            "id": 2,
            "name": "ipaddr-1"
          },
          "portion_of_mail": 80.0
        },
        {
          "virtual_mta": {
            "id": 3,
            "name": "ipaddr-2"
          },
          "portion_of_mail": 20.0
        }
      ]
    }
  },
  "error_code": null,
  "error_messages": null
}
Update a Domain Override
PUT /ga/api/v3/eng/routing_rules/{routing_rule_id}/domain_overrides/{override_id}
| routing_rule_id integer/ required | The  | 
| override_id integer/ required | The  | 
Payload
| domain_override hash/ required | The structure of this hash is the same as the entries defined in the
 | 
Response
| domain_override hash/ required | The structure of this hash is the same as the entries defined in the
 | 
Example
PUT /ga/api/v3/eng/routing_rules/20/domain_overrides/10
{
  "domain_override": {
    "domains": [
      "new-domain-1a.com",
      "new-domain-2a.com"
    ],
    "randomization_type": "email_address_constant",
    "deliver_through": [
      {
        "virtual_mta": {
          "id": 17
        },
        "portion_of_mail": 100
      },
      {
        "virtual_mta": {
          "name": "IPADDR-1"
        },
        "portion_of_mail": 300
      }
    ]
  }
}
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
    "domain_override": {
      "id": 10,
      "domains": [
        "new-domain-1a.com",
        "new-domain-2a.com"
      ],
      "randomization_type": "email_address_constant",
      "deliver_through": [
        {
          "virtual_mta": {
            "id": 16,
            "name": "ipaddr-1"
          },
          "portion_of_mail": 75.0
        },
        {
          "virtual_mta": {
            "id": 17,
            "name": "ipaddr-2"
          },
          "portion_of_mail": 25.0
        }
      ]
    }
  },
  "error_code": null,
  "error_messages": null
}
Delete a Domain Override
DELETE /ga/api/v3/eng/routing_rules/{routing_rule_id}/domain_overrides/{override_id}
Example
DELETE /ga/api/v3/eng/routing_rules/102
HTTP/1.1 200 OK
{
  "success": true,
  "data": {
  },
  "error_code": null,
  "error_messages": null
}
