All API resources
API reference

Rules

Rules that act on bank transactions when their conditions match.

Base URL https://app.prosaic.works/api/public/v1. Every request needs an API key or access token; see the overview.

List rules

GET/api/public/v1/rules

SDK: prosaic.rules.list(params)

Returns rules in the workspace associated with the API key. By default returns only active rules.

Query parameters

  • isActivestring

    Filter rules by active status. true (default) returns only active rules, false returns only inactive rules, all returns both.

    One of: all, false, true

  • entityIdstring

    Only rules whose scope reaches this entity: workspace-wide rules, rules on the entity's chart template, rules on the entity itself, and rules on any of its bank accounts.

  • pageinteger

    Default: 1

  • pageSizeinteger

    Default: 50

Responses

200 Successful response

  • dataarray of objectsrequired
    Show 10 child attributes
    • idstringrequired
    • namestringrequired
    • descriptionstringrequirednullable
    • isActivebooleanrequired
    • targetTypestringrequired
    • createdAtstring (date-time)required
    • updatedAtstring (date-time)required
    • conditionsarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • fieldstringrequired
      • operatorstringrequired
      • valuestringrequired
      • secondValuestringrequirednullable
    • actionsarray of objectsrequired
      Show 3 child attributes
      • idstringrequired
      • actionTypestringrequired
      • payloadanyrequired
    • scopesarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • scopeTypestringrequired
      • entityobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • bankAccountobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • accountTemplateobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
  • paginationobjectrequired
    Show 6 child attributes
    • currentPagenumberrequired
    • pageSizenumberrequired
    • totalCountnumberrequired
    • totalPagesnumberrequired
    • hasNextPagebooleanrequired
    • hasPreviousPagebooleanrequired
  • 400 Validation failed
  • 401 Unauthorized
  • 403 Insufficient role
  • 404 Workspace not found, or entityId is not in the workspace
  • 500 Internal server error
Node SDK
const page = await prosaic.rules.list();
curl
curl https://app.prosaic.works/api/public/v1/rules \
  -H "Authorization: Bearer $PROSAIC_API_KEY"

Get a rule by ID

GET/api/public/v1/rules/{ruleId}

SDK: prosaic.rules.retrieve(ruleId)

Path parameters

  • ruleIdstringrequired

Responses

200 Successful response

  • dataobjectrequired
    Show 10 child attributes
    • idstringrequired
    • namestringrequired
    • descriptionstringrequirednullable
    • isActivebooleanrequired
    • targetTypestringrequired
    • createdAtstring (date-time)required
    • updatedAtstring (date-time)required
    • conditionsarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • fieldstringrequired
      • operatorstringrequired
      • valuestringrequired
      • secondValuestringrequirednullable
    • actionsarray of objectsrequired
      Show 3 child attributes
      • idstringrequired
      • actionTypestringrequired
      • payloadanyrequired
    • scopesarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • scopeTypestringrequired
      • entityobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • bankAccountobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • accountTemplateobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
  • 400 Invalid rule ID
  • 401 Unauthorized
  • 403 Insufficient role
  • 404 Rule or workspace not found
  • 500 Internal server error
Node SDK
const { data } = await prosaic.rules.retrieve(ruleId);
curl
curl https://app.prosaic.works/api/public/v1/rules/$RULE_ID \
  -H "Authorization: Bearer $PROSAIC_API_KEY"

Create a rule

POST/api/public/v1/rules

SDK: prosaic.rules.create(params)

Creates a new rule in the workspace associated with the API key.

Request body

application/json

  • namestringrequired
  • conditionsarray of objectsrequired
    Show 4 child attributes
    • fieldstringrequired

      One of: description, type, date, amount, category, merchant

    • operatorstringrequired

      One of: endsWith, startsWith, is, equals, gte, contains, gt, lt, lte, between

    • valuestringrequired
    • secondValuestringnullable
  • actionsarray of objectsrequired
    Show 2 child attributes
    • actionTypestringrequired

      One of: post_journal, tag_dimensions

    • payloadanyrequired
  • scopesarray of objectsrequired
  • descriptionstringnullable
  • isActiveboolean
  • targetTypestring

    One of: bank_transaction

  • sourcestring

    One of: ai, manual, duplicate, transactions_filters, transactions_reconcile, dimension_proposal, demo_seed

Responses

201 Successful response

  • dataobjectrequired
    Show 10 child attributes
    • idstringrequired
    • namestringrequired
    • descriptionstringrequirednullable
    • isActivebooleanrequired
    • targetTypestringrequired
    • createdAtstring (date-time)required
    • updatedAtstring (date-time)required
    • conditionsarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • fieldstringrequired
      • operatorstringrequired
      • valuestringrequired
      • secondValuestringrequirednullable
    • actionsarray of objectsrequired
      Show 3 child attributes
      • idstringrequired
      • actionTypestringrequired
      • payloadanyrequired
    • scopesarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • scopeTypestringrequired
      • entityobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • bankAccountobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • accountTemplateobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
  • 400 Validation failed. Covers both shape errors (missing/invalid fields) and action-payload semantic errors caught by the request schema (e.g. proportion lines must sum to 1).
  • 401 Unauthorized
  • 403 Insufficient role
  • 404 Workspace not found
  • 422 Rule failed service-level validation against workspace data (e.g. unknown tax rate codes, account codes not allowed by the action type). Distinct from 400, which is raised by the request schema before the service is called.
  • 500 Internal server error
Node SDK
const { data } = await prosaic.rules.create({
  name: 'Example Ltd',
  conditions: [
    {
      field: 'description',
      operator: 'endsWith',
      value: 'string',
    },
  ],
  actions: [
    {
      actionType: 'post_journal',
      payload: 'string',
    },
  ],
  scopes: [
    {
      scopeType: 'workspace',
    },
  ],
});
curl
curl -X POST https://app.prosaic.works/api/public/v1/rules \
  -H "Authorization: Bearer $PROSAIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example Ltd",
    "conditions": [
      {
        "field": "description",
        "operator": "endsWith",
        "value": "string"
      }
    ],
    "actions": [
      {
        "actionType": "post_journal",
        "payload": "string"
      }
    ],
    "scopes": [
      {
        "scopeType": "workspace"
      }
    ]
  }'

Update a rule

PATCH/api/public/v1/rules/{ruleId}

SDK: prosaic.rules.update(ruleId, params)

Path parameters

  • ruleIdstringrequired

Request body

application/json

  • namestring
  • descriptionstringnullable
  • isActiveboolean
  • conditionsarray of objects
    Show 4 child attributes
    • fieldstringrequired

      One of: description, type, date, amount, category, merchant

    • operatorstringrequired

      One of: endsWith, startsWith, is, equals, gte, contains, gt, lt, lte, between

    • valuestringrequired
    • secondValuestringnullable
  • targetTypestring

    One of: bank_transaction

  • actionsarray of objects
    Show 2 child attributes
    • actionTypestringrequired

      One of: post_journal, tag_dimensions

    • payloadanyrequired
  • scopesarray of objects

Responses

200 Successful response

  • dataobjectrequired
    Show 10 child attributes
    • idstringrequired
    • namestringrequired
    • descriptionstringrequirednullable
    • isActivebooleanrequired
    • targetTypestringrequired
    • createdAtstring (date-time)required
    • updatedAtstring (date-time)required
    • conditionsarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • fieldstringrequired
      • operatorstringrequired
      • valuestringrequired
      • secondValuestringrequirednullable
    • actionsarray of objectsrequired
      Show 3 child attributes
      • idstringrequired
      • actionTypestringrequired
      • payloadanyrequired
    • scopesarray of objectsrequired
      Show 5 child attributes
      • idstringrequired
      • scopeTypestringrequired
      • entityobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • bankAccountobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
      • accountTemplateobjectrequirednullable
        Show 2 child attributes
        • idstringrequired
        • namestringrequired
  • 400 Validation failed. Covers both shape errors (missing/invalid fields) and action-payload semantic errors caught by the request schema (e.g. proportion lines must sum to 1).
  • 401 Unauthorized
  • 403 Insufficient role
  • 404 Rule or workspace not found
  • 422 Rule failed service-level validation against workspace data (e.g. unknown tax rate codes, account codes not allowed by the action type). Distinct from 400, which is raised by the request schema before the service is called.
  • 500 Internal server error
Node SDK
const { data } = await prosaic.rules.update(ruleId, {
  name: 'Example Ltd',
  description: 'Office supplies',
  isActive: true,
  conditions: [
    {
      field: 'description',
      operator: 'endsWith',
      value: 'string',
    },
  ],
  targetType: 'bank_transaction',
  actions: [
    {
      actionType: 'post_journal',
      payload: 'string',
    },
  ],
  scopes: [
    {
      scopeType: 'workspace',
    },
  ],
});
curl
curl -X PATCH https://app.prosaic.works/api/public/v1/rules/$RULE_ID \
  -H "Authorization: Bearer $PROSAIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example Ltd",
    "description": "Office supplies",
    "isActive": true,
    "conditions": [
      {
        "field": "description",
        "operator": "endsWith",
        "value": "string"
      }
    ],
    "targetType": "bank_transaction",
    "actions": [
      {
        "actionType": "post_journal",
        "payload": "string"
      }
    ],
    "scopes": [
      {
        "scopeType": "workspace"
      }
    ]
  }'

Soft-delete a rule

DEL/api/public/v1/rules/{ruleId}

SDK: prosaic.rules.del(ruleId)

Path parameters

  • ruleIdstringrequired

Responses

200 Successful response

  • dataobjectrequired
    Show 1 child attribute
    • successbooleanrequired

      One of: true

  • 400 Invalid rule ID
  • 401 Unauthorized
  • 403 Insufficient role
  • 404 Rule or workspace not found
  • 500 Internal server error
Node SDK
const { data } = await prosaic.rules.del(ruleId);
curl
curl -X DELETE https://app.prosaic.works/api/public/v1/rules/$RULE_ID \
  -H "Authorization: Bearer $PROSAIC_API_KEY"