---
title: "Edit one of this customer's merchant rules"
method: PATCH
path: "/accountant/companies/{customerId}/merchant-rules/{id}"
tags: ["Accountant Portal"]
---

# Edit one of this customer's merchant rules

`PATCH /accountant/companies/{customerId}/merchant-rules/{id}`

## Request

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

#3039. Accountant login only: the service token is refused, because a repointed rule categorizes every later matching row at 99% without review. Only a rule that belongs to this customer can be edited; another company's rule and a global rule are 404. When glAccountCode is sent it must be an active account in this customer's chart (400 otherwise), and the rule's glAccountName and glAccountType are taken from that account; values sent for those two fields are ignored. 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 otherwise); a pattern and match field another rule of this customer already has is 409. A non-UUID path id is 422. Writes an audit_logs row (entity_type merchant_rule, action update) with the rule before and after; a PATCH that changes nothing writes none.

## Request body

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

## Response `200`

The updated rule

- object
  - `success` boolean
  - `data` object
    - `id` string, uuid
    - `companyId` string, uuid, nullable: null for a global rule
    - `merchantPattern` string
    - `matchField` 'merchant_name' | 'description'
    - `glAccountCode` string
    - `glAccountName` string
    - `glAccountType` string
    - `scope` 'company' | 'global'
    - `priority` integer

## Other responses

- `400`: glAccountCode is not an active account in this customer's chart
- `401`: Authentication required
- `403`: Insufficient permissions or not a company member
- `404`: Resource not found
- `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)
