POST
/
flows
/
{flow}
/
actions
/
{action}
/
rules
curl --request POST \
  --url https://api.{gr4vy_id}.gr4vy.app/flows/{flow}/actions/{action}/rules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "example rule description.",
  "conditions": [
    {
      "name": "currency",
      "operator": "is_one_of",
      "value": [
        "GBP",
        "USD"
      ]
    },
    {
      "name": "country",
      "operator": "is_one_of",
      "value": [
        "GB",
        "US"
      ]
    }
  ],
  "outcome": {
    "type": "list",
    "result": [
      "card",
      "gocardless"
    ]
  }
}'
{
  "type": "rule",
  "id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
  "merchant_account_id": "default",
  "description": "example rule.",
  "flow": "checkout",
  "action": "select-payment-options",
  "conditions": [
    {
      "name": "amount",
      "operator": "less_than",
      "value": {
        "Amount condition value": {
          "value": {
            "description": "example amount value.",
            "currency": "USD",
            "value": 100
          }
        }
      }
    }
  ],
  "outcome": {
    "type": "card-routing",
    "result": [
      {
        "payment_service_id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
        "instrument\"": "network_token",
        "transformations": []
      },
      {
        "payment_service_id": "d88aca32-07fb-46cd-a43f-86da02b73c21",
        "instrument": "pan",
        "transformations": [
          {
            "name": "force_mit"
          }
        ]
      }
    ],
    "version": 2
  },
  "position": 2,
  "created_at": "2013-07-16T19:23:00.000+00:00",
  "updated_at": "2013-07-16T19:23:00.000+00:00"
}

This endpoint requires the flows.write scope.

Authorizations

Authorization
string
headerrequired

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

flow
enum<string>
required

The flow name. This can be one of the following.

  • checkout - Applies during checkout to determine what payment options are shown.
  • card-transaction - Applies when processing a card transaction.
  • non-card-transaction - Applies when processing a gift card only transaction, or a redirect transaction using the decline-early action.
  • redirect-transaction - Applies when processing any other transaction.
Available options:
checkout,
card-transaction,
non-card-transaction,
redirect-transaction
action
enum<string>
required

The flow action.

Available options:
select-payment-options,
decline-early,
route-transaction,
skip-3ds

Body

application/json
description
string

Description of the flow rule.

conditions
object[]

One or more conditions that apply for this rule. Each condition needs to match for this rule to go into effect.

outcome
object

Defines the outcome of a rule in a flow where the result is a boolean.

Response

201 - application/json
type
enum<string>

The type of this resource. Is always rule.

Available options:
rule
id
string

The unique Gr4vy ID for this rule.

merchant_account_id
string

The unique ID for a merchant account.

description
string | null

Description of the flow rule.

flow
enum<string>

The name of the Flow.

Available options:
checkout,
card-transaction,
non-card-transaction,
redirect-transaction
action
enum<string>

Action for the given rule. Actions can only be used in flows that support them.

  • The checkout flow only supports the select-payment-options action.
  • The card-transaction supports the route-transaction, skip-3ds, and decline-early actions.
  • The non-card-transaction flow only supports the decline-early action.
  • The redirect-transaction flow only supports the route-transaction action.
Available options:
select-payment-options,
decline-early,
route-transaction,
skip-3ds
conditions
object[]

One or more conditions that apply for this rule. Each condition needs to match for this rule to go into effect.

outcome
object

Defines the outcome of a rule in a flow where the result is a list of dictionaries that define the payment service, instrument and transformation to be used to process a transaction.

position
number

The position of the rule in the flow.

created_at
string

The date and time when this buyer was created in our system.

updated_at
string

The date and time when this buyer was last updated in our system.