Skip to main content
POST
/
v1
/
businesses
/
{businessId}
/
categorization-rules
Create categorization rule
curl --request POST \
  --url https://sandbox.layerfi.com/v1/businesses/{businessId}/categorization-rules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "category": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "suggestion_1": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "suggestion_2": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "suggestion_3": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "apply_retroactively": false,
  "external_id": "<string>",
  "created_by_suggestion_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "merchant_type_filter": "<string>",
  "transaction_description_filter": "<string>",
  "counterparty_filter": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "bank_transaction_type_filter": "REVENUE",
  "bank_direction_filter": "MONEY_IN",
  "amount_min_filter": 123,
  "amount_max_filter": 123
}
'
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "business_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "name": "<string>",
  "category": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "suggestion_1": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "suggestion_2": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "suggestion_3": {
    "type": "AccountId",
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  },
  "merchant_type_filter": "<string>",
  "transaction_description_filter": "<string>",
  "counterparty_filter": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "name": "<string>",
    "logo_url": "<string>",
    "website": "<string>"
  },
  "bank_transaction_type_filter": "REVENUE",
  "bank_direction_filter": "MONEY_IN",
  "amount_min_filter": 123,
  "amount_max_filter": 123
}

Documentation Index

Fetch the complete documentation index at: https://docs.layerfi.com/llms.txt

Use this file to discover all available pages before exploring further.

Rules are applied to matching transactions based on the specified filters. At least one filter must be specified (merchant_type_filter, transaction_description_filter, counterparty_filter, bank_transaction_type_filter).

Applying categorization rules retroactively

The rule can optionally be applied retroactively to existing uncategorized transactions via the apply_retroactively flag. If apply_retroactively is true, the rule will be applied to existing uncategorized transactions when the rule is created. If false, the rule will only apply to future matching transactions and the preview is informational only.

Authorizations

Authorization
string
header
required

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

Headers

Content-Type
string

Content-Type must be set to application/json.

Path Parameters

businessId
string<uuid>
required

The UUID of the business.

Body

application/json

Parameters for creating or updating a categorization rule. At least one filter must be specified.

name
string

Optional name for the rule.

category
Account ID · object
suggestion_1
Account ID · object
suggestion_2
Account ID · object
suggestion_3
Account ID · object
apply_retroactively
boolean
default:false

Whether to apply this rule to existing uncategorized transactions.

external_id
string

External identifier for idempotency. Used for create/upsert operations.

created_by_suggestion_id
string<uuid>

UUID of the suggestion that created this rule (if applicable).

merchant_type_filter
string

Regex pattern to match against merchant type (minimum 7 characters).

Minimum string length: 7
transaction_description_filter
string

Regex pattern to match against transaction description (minimum 7 characters).

Minimum string length: 7
counterparty_filter
string<uuid>

UUID of a specific counterparty (merchant/vendor) to match.

bank_transaction_type_filter
enum<string>

Type of bank transaction.

Available options:
REVENUE,
LOAN_DISBURSEMENT,
REFUND_RECEIVED,
INCOMING_P2P_TRANSFER,
INTRA_ACCOUNT_TRANSFER_IN,
CHECK_WITHDRAWAL,
ATM_DEPOSIT,
BANK_DEPOSIT,
BANK_VERIFICATION_TRIAL_CREDIT,
REVERSAL_IN,
CREDIT_CARD_REWARD,
CREDIT_CARD_PAYMENT_IN,
INTEREST_EARNED,
GOVERNMENT_OR_OTHER_GRANT,
TAX_REFUND,
PURCHASE,
REFUND_GIVEN,
OUTGOING_P2P_TRANSFER,
INTRA_ACCOUNT_TRANSFER_OUT,
CHECK_DEPOSIT,
CREDIT_CARD_PAYMENT_OUT,
ATM_WITHDRAWAL,
BANK_WITHDRAWAL,
BANKING_FEE,
PAYMENT_PROCESSING_FEE,
BANK_VERIFICATION_TRIAL_DEBIT,
REVERSAL_OUT,
LOAN_PAYMENT,
TAX_PAYMENT,
NOT_ENOUGH_INFORMATION
bank_direction_filter
enum<string>

Transaction direction to match.

Available options:
MONEY_IN,
MONEY_OUT
amount_min_filter
integer<int64>

Minimum transaction amount in cents.

amount_max_filter
integer<int64>

Maximum transaction amount in cents.

Response

Categorization rule created successfully.

A categorization rule that automatically categorizes transactions matching specified filters.

id
string<uuid>
required

Unique identifier for the rule.

business_id
string<uuid>
required

The business this rule belongs to.

created_at
string<date-time>
required

When the rule was created.

updated_at
string<date-time>
required

When the rule was last updated.

name
string

Name of the rule.

category
Account ID · object
suggestion_1
Account ID · object
suggestion_2
Account ID · object
suggestion_3
Account ID · object
merchant_type_filter
string

Regex pattern matching merchant type.

transaction_description_filter
string

Regex pattern matching transaction description.

counterparty_filter
object

Information about a transaction counterparty (merchant/vendor).

bank_transaction_type_filter
enum<string>

Type of bank transaction.

Available options:
REVENUE,
LOAN_DISBURSEMENT,
REFUND_RECEIVED,
INCOMING_P2P_TRANSFER,
INTRA_ACCOUNT_TRANSFER_IN,
CHECK_WITHDRAWAL,
ATM_DEPOSIT,
BANK_DEPOSIT,
BANK_VERIFICATION_TRIAL_CREDIT,
REVERSAL_IN,
CREDIT_CARD_REWARD,
CREDIT_CARD_PAYMENT_IN,
INTEREST_EARNED,
GOVERNMENT_OR_OTHER_GRANT,
TAX_REFUND,
PURCHASE,
REFUND_GIVEN,
OUTGOING_P2P_TRANSFER,
INTRA_ACCOUNT_TRANSFER_OUT,
CHECK_DEPOSIT,
CREDIT_CARD_PAYMENT_OUT,
ATM_WITHDRAWAL,
BANK_WITHDRAWAL,
BANKING_FEE,
PAYMENT_PROCESSING_FEE,
BANK_VERIFICATION_TRIAL_DEBIT,
REVERSAL_OUT,
LOAN_PAYMENT,
TAX_PAYMENT,
NOT_ENOUGH_INFORMATION
bank_direction_filter
enum<string>

Transaction direction that this rule matches.

Available options:
MONEY_IN,
MONEY_OUT
amount_min_filter
integer<int64>

Minimum amount in cents.

amount_max_filter
integer<int64>

Maximum amount in cents.