Skip to main content
Version: 2019-05-29 (Current)

Create Routing Rule

Create a new routing group rule for payment routing. Routing rules allow you to control how transactions are processed across different payment providers and acquirers based on various conditions.


Request Parametersโ€‹

Required - 3 fieldsRequired Parameters
โ–ผ
`name`STRING(required)
Human-readable name for the routing rule. Used for identification in dashboards and logs.
Example:"Route high-value cards to Provider A"
`conditions`ARRAY(required)
Array of condition objects that determine when this rule applies. Each condition specifies a field, operator, and value to match against.
Example:[{"field":"amount","operator":"gte","value":100000}]
`provider`STRING(required)
Target payment provider identifier. Transactions matching this rule will be routed to this provider.
Example:"provider_a"
Condition StructureCondition Parameters
โ–ผ
`conditions[].field`STRING(required)
The transaction field to evaluate. Options include amount, currency, card_brand, card_type, card_country, metadata fields.
Example:"amount"
Values:amount, currency, card_brand, card_type, card_country, metadata
`conditions[].operator`STRING(required)
Comparison operator for the condition.
Example:"gte"
Values:eq, neq, gt, gte, lt, lte, in, not_in, contains
`conditions[].value`ANY(required)
The value to compare against. Type depends on the field (number for amount, string for currency, array for "in" operator).
Example:100000
Additional - 5 fieldsAdditional Parameters
Metadata - 1 fieldMetadata Parameters

Responsesโ€‹

200

Rule created successfully

Routing rule created successfully. The rule is immediately active unless enabled is set to false.

Response includes:
  • object - Always returns "routing_group_rule"
  • id - Unique rule identifier
  • name - Rule name
  • conditions - Array of condition objects
  • provider - Target provider identifier
  • priority - Rule priority
  • enabled - Whether rule is active
  • created_at - Creation timestamp

400

Bad request

Request validation failed. Check the error message for details.

Common causes:
  • Missing required fields (name, conditions, provider)
  • Invalid condition structure
  • Unknown provider identifier
  • Invalid operator for field type
  • Condition value type mismatch

401

Unauthorized

Authentication failed. Invalid or missing API key.

Common causes:
  • Missing Authorization header
  • Invalid secret key
  • Using public key instead of secret key
  • Incorrect HTTP Basic Auth format

404

Not found

Referenced resource not found.

Common causes:
  • Invalid provider identifier
  • Routing feature not enabled for account

5xx

Server error

Server-side error occurred. These are rare but should be handled gracefully.

How to handle:

Code samplesโ€‹

curl https://api.omise.co/routing_group_rules \
-u skey_test_5xuy4w91xqz7d1w9u0t: \
-d "name=Route high-value to Provider A" \
-d "provider=provider_a" \
-d "conditions[0][field]=amount" \
-d "conditions[0][operator]=gte" \
-d "conditions[0][value]=100000" \
-d "priority=100"

Error and result codesโ€‹

Common Error Codesโ€‹

CodeDescriptionResolution
bad_requestMissing or invalid parametersCheck all required fields are provided
authentication_failureInvalid API keyVerify your secret key is correct
invalid_conditionCondition structure is invalidCheck field, operator, and value are correct
invalid_providerProvider not foundVerify provider identifier exists
duplicate_ruleRule with same name existsUse a unique rule name

Condition Operatorsโ€‹

OperatorDescriptionValid For
eqEqual toAll fields
neqNot equal toAll fields
gtGreater thanamount
gteGreater than or equalamount
ltLess thanamount
lteLess than or equalamount
inValue in listcurrency, card_brand, card_type
not_inValue not in listcurrency, card_brand, card_type
containsContains substringmetadata fields

Routing Rule Object Fieldsโ€‹

FieldTypeDescription
objectstringAlways returns "routing_group_rule"
idstringUnique rule identifier
namestringHuman-readable rule name
descriptionstringRule description
conditionsarrayArray of condition objects
providerstringTarget provider identifier
priorityintegerRule evaluation priority
match_typestringCondition matching logic (all/any)
weightintegerLoad balancing weight
enabledbooleanWhether rule is active
metadataobjectCustom key-value pairs
created_atstringCreation timestamp (ISO 8601)
updated_atstringLast update timestamp (ISO 8601)

๐Ÿ”‘API Credentials

Try it outโ€‹

Required - 3 fields
โ–ผ
Additional - 6 fields
Your IP: ...Loading...