---
title: "Create a merchant rule for this customer"
method: POST
path: "/accountant/companies/{customerId}/merchant-rules"
tags: ["Accountant Portal"]
---

# Create a merchant rule for this customer

`POST /accountant/companies/{customerId}/merchant-rules`

## Request

- Base URL: `https://api.medianfi.com/api/v1`
- URL: `https://api.medianfi.com/api/v1/accountant/companies/{customerId}/merchant-rules`
- Auth: HTTP bearer

#3039. Accountant login only: the service token is refused. Creates a company rule, which outranks a global rule for the same merchant. glAccountCode must be an active account in this customer's chart (422 otherwise); the rule's account name and type are taken from that account. merchantPattern needs at least 3 characters, cannot contain %, _, a backslash or a control character, and cannot consist only of generic words such as fee or payment (422). A pattern and match field another rule of this customer already has is 409. Rows already categorized are not changed; rows still in needs_review with no category are categorized by it on the next sync, and an exact rule with a Revenue target releases that customer's held Stripe revenue on the next posting attempt. Writes an audit_logs row (entity_type merchant_rule, action create).

## Request body

- object
  - `merchantPattern` string, required
  - `matchField` 'merchant_name' | 'description'
  - `glAccountCode` string, required
  - `priority` integer

## Response `201`

The created rule

- object
  - `success` boolean
  - `data` object

## Other responses

- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `409`: Another rule of this customer already has that pattern and match field
- `422`: Request failed validation

---

[API](https://skmtc.dev/medianfi/apis/median-api.md) · [All operations](https://skmtc.dev/medianfi/apis/median-api/llms.txt) · [OpenAPI document](https://skmtc.dev/medianfi/apis/median-api/revisions/20090ea32b0d?raw)
