# Update a Routing

Replaces the routing's full configuration. The body has the same shape as [Create a Routing](/reference/organizations/routing/create-routing) — the new `default_route` and `condition_sets[]` entirely supersede the previous live state. **There is no field-level merge.**

`account_id` and `payment_method` are sticky to the `routing_id` — they're set at creation and cannot be changed by `PATCH`.

### Path Parameters

<ParamField path="routing_id" type="string" required>
  The id returned by [Create a Routing](/reference/organizations/routing/create-routing).
</ParamField>

### Body

<ParamField body="name" type="string" required>
  Free-form label.
</ParamField>

<ParamField body="default_route" type="object" required>
  The route used when no `condition_sets[]` matches.
  <Expandable title="properties">
    <ParamField body="steps" type="object[]" required>
      Each step is one provider attempt. `index` values are contiguous starting at 1.
      <Expandable title="item">
        <ParamField body="index" type="integer" required>
            Step ordinal.
        </ParamField>
        <ParamField body="provider_id" type="string" required>
            Must match the provider of the connection.
        </ParamField>
        <ParamField body="connection_id" type="UUID" required>
            Must be `ACTIVE` and support the `payment_method`.
        </ParamField>
        <ParamField body="output" type="object[]">
          Defines how to handle each possible outcome of this step.
          <Expandable title="item">
            <ParamField body="status" type="string" required>
              The outcome status that triggers this rule (e.g., `APPROVED`, `DECLINED`, `DECLINE_GROUP`, `TIMEOUT`, `INTERNAL_ERROR`).
            </ParamField>
            <ParamField body="decline_types" type="string[]">
              Required when `status` is `DECLINE_GROUP`. Specifies which decline subtypes trigger this rule (e.g., `INSUFFICIENT_FUNDS`, `DECLINED_BY_BANK`).
            </ParamField>
            <ParamField body="next" type="integer">
              The `index` of the next step to execute. Omit if no fallback is needed.
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="condition_sets" type="object[]">
  Optional. Ordered by `sort_number` — first matching set wins.
  <Expandable title="item">
    <ParamField body="sort_number" type="integer" required>
        Priority of the condition set.
    </ParamField>
    <ParamField body="name" type="string" required>
        Label for the set.
    </ParamField>
    <ParamField body="conditions" type="object[]" required>
        List of [Conditions](/reference/organizations/routing/routing-conditions) that must match.
    </ParamField>
    <ParamField body="route" type="object" required>
        The steps to execute if this set matches.
    </ParamField>
  </Expandable>
</ParamField>

### Response

<ResponseField name="id" type="string">
  Unique identifier for the routing.
</ResponseField>
<ResponseField name="account_id" type="string">
  Unique identifier for the account.
</ResponseField>
<ResponseField name="payment_method" type="enum">
  The payment method this routing applies to (e.g., `CARD`).
</ResponseField>
<ResponseField name="name" type="string">
  Label for the routing.
</ResponseField>
<ResponseField name="default_route" type="object">
  The default routing logic.
</ResponseField>
<ResponseField name="condition_sets" type="object[]">
  Optional conditional logic.
</ResponseField>
<ResponseField name="created_at" type="string">
  ISO 8601 timestamp.
</ResponseField>
<ResponseField name="updated_at" type="string">
  ISO 8601 timestamp.
</ResponseField>

<CodeGroup>
```bash cURL
curl -X PATCH 'https://api.whitelabel.com/v1/routing/r_8f2c1d3e-4b5a-6c7d-8e9f-0a1b2c3d4e5f' \
  -H 'public-api-key: <YOUR_PUBLIC_KEY>' \
  -H 'private-secret-key: <YOUR_SECRET_KEY>' \
  -H 'Content-Type: application/json' \
  -H 'X-Idempotency-Key: <UUID>' \
  -d '{
    "payment_method": "CARD",
    "name": "Card routing v2 — adds BR installments rule",
    "default_route": {
      "steps": [
        {
          "index": 1,
          "provider_id": "STRIPE",
          "connection_id": "f1a3c4d5-7b8e-4a2c-9d1e-3f4a5b6c7d8e",
          "output": [
            { "status": "DECLINED", "next": 2 }
          ]
        },
        {
          "index": 2,
          "provider_id": "ADYEN",
          "connection_id": "b2c4d5e6-1a2b-3c4d-5e6f-7a8b9c0d1e2f"
        }
      ]
    },
    "condition_sets": [
      {
        "sort_number": 1,
        "name": "Brazil — BRL 300 to 600 via Adyen",
        "description": "BR card transactions between BRL 300 and 600 go to Adyen directly",
        "conditions": [
          { "condition_type": "COUNTRY", "conditional": "EQUAL",   "values": ["BR"] },
          { "condition_type": "AMOUNT",  "conditional": "BETWEEN", "values": ["300.00", "600.00"], "currency": "BRL" }
        ],
        "route": {
          "steps": [
            { "index": 1, "provider_id": "ADYEN", "connection_id": "b2c4d5e6-..." }
          ]
        }
      }
    ]
  }'
```

```json 200 OK — Updated
{
  "id": "r_8f2c1d3e-4b5a-6c7d-8e9f-0a1b2c3d4e5f",
  "account_id": "acc-uuid",
  "payment_method": "CARD",
  "name": "Card routing v2 — adds BR installments rule",
  "default_route": {
    "steps": [
      {
        "index": 1,
        "provider_id": "STRIPE",
        "connection_id": "f1a3c4d5-7b8e-4a2c-9d1e-3f4a5b6c7d8e",
        "output": [ { "status": "DECLINED", "next": 2 } ]
      },
      { "index": 2, "provider_id": "ADYEN", "connection_id": "b2c4d5e6-..." }
    ]
  },
  "condition_sets": [
    {
      "sort_number": 1,
      "name": "Brazil — BRL 300 to 600 via Adyen",
      "conditions": [
        { "condition_type": "COUNTRY", "conditional": "EQUAL", "values": ["BR"] }
      ],
      "route": { "steps": ["..."] }
    }
  ],
  "created_at": "2026-05-12T14:30:00Z",
  "updated_at": "2026-05-13T09:18:42Z"
}
```

```json 400 — Immutable Payment Method
{
  "code": "ROUTING_PAYMENT_METHOD_IMMUTABLE",
  "messages": ["payment_method cannot be changed on an existing routing"]
}
```
</CodeGroup>

### Errors

<div className="code-nowrap-table dense-table">

| HTTP | `code` |
| --- | --- |
| `404` | `ROUTING_NOT_FOUND`<br />Unknown `routing_id`, or id belongs to a different account. |
| `400` | `ROUTING_VALIDATION_FAILED`<br />Schema or rule violation. |
| `400` | `ROUTING_PROVIDER_NOT_AVAILABLE`<br />A step references an inactive/unknown connection. |
| `400` | `ROUTING_PAYMENT_METHOD_IMMUTABLE`<br />Body's `payment_method` doesn't match the routing's `payment_method`. |
| `409` | `ROUTING_VERSION_CONFLICT`<br />Another concurrent `PATCH` won the publish race. |
| `401` | `NOT_AUTHENTICATED`<br />Missing `public-api-key` or `private-secret-key` header. |
| `401` | `INVALID_CREDENTIALS`<br />Wrong key pair, or a Dashboard **Customized API key** was used. Use an account key or organization key instead. |

</div>

**PATCH** `/routing/{routing_id}`

Base URL: `https://api-sandbox.whitelabel.com/v1`

Replaces the routing's full configuration.

## Authorization

- PUBLIC-API-KEY (apiKey in header)
- PRIVATE-SECRET-KEY (apiKey in header)

## Header parameters

- `X-Idempotency-Key` (string, required)

## Path parameters

- `routing_id` (string, required)

## Responses

### 200

OK

- `id` (string)
- `account_id` (string)
- `payment_method` (string)
- `name` (string)
- `default_route` (object)
  - `steps` (object[])
    - `index` (integer)
    - `provider_id` (string)
    - `connection_id` (string)
- `condition_sets` (object[])
  - `sort_number` (integer)
  - `name` (string)
  - `conditions` (object[])
  - `route` (object)
- `created_at` (string<date-time>)
- `updated_at` (string<date-time>)

Example:

```json
{
  "id": "r_8f2c1d3e-4b5a-6c7d-8e9f-0a1b2c3d4e5f",
  "account_id": "acc-uuid",
  "payment_method": "CARD",
  "name": "Updated Card routing v2",
  "default_route": {
    "steps": [
      {
        "index": 1,
        "provider_id": "STRIPE",
        "connection_id": "f1a3c4d5-..."
      }
    ]
  },
  "condition_sets": [
    {
      "sort_number": 1,
      "name": "Updated Card routing",
      "conditions": [
        {}
      ],
      "route": {}
    }
  ],
  "created_at": "2026-05-12T14:30:00Z",
  "updated_at": "2026-05-12T14:30:00Z"
}
```

### 400

Bad Request

- `code` (string)
- `messages` (string[])

Example:

```json
{
  "code": "ROUTING_VALIDATION_FAILED",
  "messages": [
    "Validation failed for update"
  ]
}
```

### 401

Unauthorized

- `code` (string)
- `messages` (string[])

Example:

```json
{
  "code": "NOT_AUTHENTICATED",
  "messages": [
    "Not authenticated"
  ]
}
```

### 404

Not Found

- `code` (string)
- `messages` (string[])

Example:

```json
{
  "code": "ROUTING_NOT_FOUND",
  "messages": [
    "Routing '...' was not found"
  ]
}
```

### 409

Conflict

- `code` (string)
- `messages` (string[])

Example:

```json
{
  "code": "ROUTING_VERSION_CONFLICT",
  "messages": [
    "Another concurrent PATCH won the publish race"
  ]
}
```