Organization routing

View and edit smart routing for the organization's merchants from the Dashboard — routing profiles and the condition/action rules under each.

These endpoints let the organization view, create and edit each merchant's routing — the routing profiles that decide which connector attempts each charge, and the condition/action rules under each profile — without switching to the merchant's own dashboard.

A routing profile still belongs to a single merchant. The organization edits the same profiles and rules as the merchant's routing screen, so a change made here routes that merchant's next charge. See How Tokeflow works for the orchestration model.

These endpoints power the Tokeflow Dashboard UI at the organization level. They are session-authenticated (JWT bearer) — the token comes from signing in to the Dashboard, not from an sk_/pk_ API key. Requests also carry the x-organization-id header, and the signed-in user must be a member of that organization. Every route except the profile list names its merchant in the x-merchant-id header; the merchant must belong to the organization and must not be deleted.

Who can edit. Every member can read routing. Creating, updating or deleting a profile or a rule needs an owner or admin of the organization — a viewer is refused with 403. Organization API keys are governed by their org:routing:write scope instead. Every change is recorded in the audit trail.

The routing profile object

Returned by the list and retrieve endpoints on this page.

FieldTypeDescription
idstringRouting profile ID.
merchant_idstringMerchant ID.
namestringRouting profile name.
created_atstringRouting profile creation timestamp. (ISO 8601 UTC).
updated_atstringRouting profile last update timestamp. (ISO 8601 UTC).
is_activebooleanWhether the routing profile is active.
versionnumberRouting profile version.
payment_methodstringPayment method scope.
default_merchant_connector_idstring | nullDefault connector ID used when no rule node matches.

Endpoints

GET/api/v1/org/routing/profiles

Org

Auth: Dashboard session (JWT bearer). Organization membership required.

List routing profiles for merchant.

Query parameters

FieldTypeRequiredDescription
pagenumberNoPage number (1-indexed). Default 1, min 1.
limitnumberNoNumber of items per page. Default 20, min 1, max 100.

Example request

curl -G https://api.tokeflow.com/api/v1/org/routing/profiles \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  --data-urlencode "page=1" \
  --data-urlencode "limit=20"

Example response — 200

{
  "data": [
    {
      "id": "rp_123abc...",
      "merchant_id": "mrc_123",
      "name": "Primary Routing Profile",
      "created_at": "2025-11-20T10:00:00Z",
      "updated_at": "2025-11-21T10:00:00Z",
      "is_active": true,
      "version": 1,
      "payment_method": "*",
      "default_merchant_connector_id": "string"
    }
  ],
  "meta": {
    "page": 1,
    "limit": 20,
    "total": 42,
    "total_pages": 3,
    "has_next": true,
    "has_prev": false
  }
}

POST/api/v1/org/routing/profiles

Org

Auth: Dashboard session (JWT bearer). Organization owner or admin required.

Create a new routing profile.

Request fields

FieldTypeRequiredDescription
namestringYesRouting profile name.
is_activebooleanNoWhether the routing profile is active.
payment_methodstringNoPayment method scope. * = catch-all. One of credit_card, debit_card, pix, boleto, wallet, *.
default_merchant_connector_idstringYesDefault connector used when no rule node matches. Cannot be null.

Example request

curl -X POST https://api.tokeflow.com/api/v1/org/routing/profiles \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Default Card Profile",
    "is_active": true,
    "payment_method": "*",
    "default_merchant_connector_id": "mc_6d7b9a0e1f2c3d4e5f6a7b8c9d0e1f2a"
  }'

Example response — 201

{
  "id": "rp_123abc...",
  "merchant_id": "mrc_123",
  "name": "Primary Routing Profile",
  "created_at": "2025-11-20T10:00:00Z",
  "updated_at": "2025-11-21T10:00:00Z",
  "is_active": true,
  "version": 1,
  "payment_method": "*",
  "default_merchant_connector_id": "string"
}

DELETE/api/v1/org/routing/profiles/:profile_id

Org

Auth: Dashboard session (JWT bearer). Organization owner or admin required.

Delete a routing profile.

Path parameters

FieldTypeRequiredDescription
profile_idstringYes—

Example request

curl -X DELETE https://api.tokeflow.com/api/v1/org/routing/profiles/rpf_5f6a7b8c \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9"

Example response — 204 No Content

An empty body is returned on success.


GET/api/v1/org/routing/profiles/:profile_id

Org

Auth: Dashboard session (JWT bearer). Organization membership required.

Get routing profile by ID.

Path parameters

FieldTypeRequiredDescription
profile_idstringYes—

Example request

curl https://api.tokeflow.com/api/v1/org/routing/profiles/rpf_5f6a7b8c \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9"

Example response — 200

{
  "id": "rp_123abc...",
  "merchant_id": "mrc_123",
  "name": "Primary Routing Profile",
  "created_at": "2025-11-20T10:00:00Z",
  "updated_at": "2025-11-21T10:00:00Z",
  "is_active": true,
  "version": 1,
  "payment_method": "*",
  "default_merchant_connector_id": "string"
}

PATCH/api/v1/org/routing/profiles/:profile_id

Org

Auth: Dashboard session (JWT bearer). Organization owner or admin required.

Renames a profile, changes its payment method or default connector, or activates or deactivates it. Only one profile per merchant and payment method can be active: activating a profile while another active one covers the same payment method returns 409, unless you send deactivate_conflicting: true to swap them in one step.

Path parameters

FieldTypeRequiredDescription
profile_idstringYesRouting profile ID.

Request fields

FieldTypeRequiredDescription
namestringNoRouting profile name.
is_activebooleanNoWhether the routing profile is active.
deactivate_conflictingbooleanNoWith is_active: true, deactivates the profile currently active for this payment method and activates this one in a single transaction. Ignored when there is no conflict.
payment_methodstringNoPayment method scope. * = catch-all. One of credit_card, debit_card, pix, boleto, wallet, *.
default_merchant_connector_idstringNoDefault connector used when no rule matches. Cannot be null.

Example request

curl -X PATCH https://api.tokeflow.com/api/v1/org/routing/profiles/rpf_5f6a7b8c \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9" \
  -H "Content-Type: application/json" \
  -d '{ "is_active": true, "deactivate_conflicting": true }'

Example response — 200: the updated routing profile.


GET/api/v1/org/routing/profiles/:profile_id/rules

Org

Auth: Dashboard session (JWT bearer). Organization membership required.

Lists every node of the profile's condition/action tree, as { data, total }. Deleted rules, and the rules beneath them, stay in the list with is_active: false; only active nodes are evaluated.

Path parameters

FieldTypeRequiredDescription
profile_idstringYesRouting profile ID.

Example request

curl https://api.tokeflow.com/api/v1/org/routing/profiles/rpf_5f6a7b8c/rules \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9"

POST/api/v1/org/routing/profiles/:profile_id/rules

Org

Auth: Dashboard session (JWT bearer). Organization owner or admin required.

Adds a rule to a profile: a condition node that branches on a field of the charge, or an action node that routes to a connector.

Path parameters

FieldTypeRequiredDescription
profile_idstringYesRouting profile ID.

Request fields

FieldTypeRequiredDescription
node_typestringYescondition or action.
parent_node_idstring | nullNoParent node ID. null for a root node.
branchstring | nullNothen or else. Required when parent_node_id is set.
positionnumberYesPosition among siblings (0-based).
condition_fieldstringNoField to evaluate. Required for condition nodes. One of currency, amount, card_brand, bin_country, is_recurring, math/random, installments.
condition_operatorstringNoRequired for condition nodes. One of eq, neq, gt, gte, lt, lte, in, not_in, regex.
condition_valueanyNoScalar for eq/gt/lt, array for in/not_in, float 0–1 for math/random.
merchant_connector_idstringNoConnector to route to. Required for action nodes.
require_3dsstringNo3DS requirement for an action node. One of never, if_supported, always.
is_activebooleanNoWhether the node is active.

Example request

curl -X POST https://api.tokeflow.com/api/v1/org/routing/profiles/rpf_5f6a7b8c/rules \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9" \
  -H "Content-Type: application/json" \
  -d '{
    "node_type": "condition",
    "parent_node_id": null,
    "position": 0,
    "condition_field": "currency",
    "condition_operator": "eq",
    "condition_value": "BRL"
  }'

Example response — 201

{
  "id": "rn_7c2d9e",
  "routing_profile_id": "rpf_5f6a7b8c",
  "parent_node_id": null,
  "branch": null,
  "position": 0,
  "node_type": "condition",
  "condition_field": "currency",
  "condition_operator": "eq",
  "condition_value": "BRL",
  "merchant_connector_id": null,
  "connector_name": null,
  "require_3ds": null,
  "is_active": true,
  "created_at": "2026-11-04T12:30:00.000Z",
  "updated_at": "2026-11-04T12:30:00.000Z"
}

PATCH/api/v1/org/routing/rules/:rule_id

Org

Auth: Dashboard session (JWT bearer). Organization owner or admin required.

Updates a rule: move it (parent_node_id, branch, position), change its condition or connector, or switch it on or off. Takes the same fields as the create call, except node_type.

Path parameters

FieldTypeRequiredDescription
rule_idstringYesRule (node) ID.

Example request

curl -X PATCH https://api.tokeflow.com/api/v1/org/routing/rules/rn_7c2d9e \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9" \
  -H "Content-Type: application/json" \
  -d '{ "condition_value": "USD" }'

Example response — 200: the updated rule, in the shape above.


DELETE/api/v1/org/routing/rules/:rule_id

Org

Auth: Dashboard session (JWT bearer). Organization owner or admin required.

Deletes a rule and every rule beneath it. Deleted rules stay in the rules list with is_active: false.

Path parameters

FieldTypeRequiredDescription
rule_idstringYesRule (node) ID.

Example request

curl -X DELETE https://api.tokeflow.com/api/v1/org/routing/rules/rn_7c2d9e \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…" \
  -H "x-organization-id: org_4b21e7c3" \
  -H "x-merchant-id: mrc_8a3f12d9"

Example response — 204 No Content


Errors

Errors use the standard envelope. The most common cases here:

HTTPMeaning
400Invalid parameters or a state that does not allow this operation.
401Missing, expired, or invalid Dashboard session token.
403Authenticated, but the signed-in user lacks access to this entity, or is not an owner or admin for a change that needs one (INSUFFICIENT_PERMISSIONS).
404The record does not exist or is not visible to this entity.
409Activating a profile while another active profile covers the same payment method, without deactivate_conflicting.

On this page