Run Rule
POST /api/v1/rules/:id/run
Execute a rule on transactions that match its conditions. By default, only applies to transactions where type = 'unknown'. Use force_all to apply to all matching transactions.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | Rule ID |
Request Body
| Field | Type | Default | Description |
|---|---|---|---|
| force_all | boolean | false | If true, apply to all matching transactions. If false, only apply to unknown transactions. |
Example: Run on Unknown Transactions (Default)
Applies the rule only to transactions where type = 'unknown':
curl -X POST "https://statements.finopsbricks.com/api/v1/rules/rule123xyz/run" \
-H "api-key: fob_stm_xxxxxxxxxxxx" \
-H "api-secret: xxxxxxxxxxxxxxxx"
Example: Force Run on All
Applies the rule to all transactions matching the conditions, regardless of their current type:
curl -X POST "https://statements.finopsbricks.com/api/v1/rules/rule123xyz/run" \
-H "api-key: fob_stm_xxxxxxxxxxxx" \
-H "api-secret: xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"force_all": true}'
Response
{
"data": {
"matched_count": 150,
"updated_count": 42,
"rule_id": "rule123xyz"
}
}
| Field | Description |
|---|---|
| matched_count | Number of transactions that matched the rule conditions (and type filter if applicable) |
| updated_count | Number of transactions that were actually updated |
| rule_id | The ID of the rule that was executed |
Notes
-
Default behavior (
force_all: false): Only updates transactions wheretype = 'unknown'. This is the safe default that won't overwrite manually categorized transactions. -
Force mode (
force_all: true): Updates all transactions matching the rule conditions. Use with caution as this will overwrite any manual categorizations. -
The rule does not need to be enabled to run it via this endpoint. This allows you to test rules before enabling them for automatic application.
Errors
| Code | Description |
|---|---|
| 400 | Invalid JSON body |
| 401 | Invalid or missing API credentials |
| 403 | API key lacks rules:edit permission |
| 404 | Rule not found |