> ## Documentation Index
> Fetch the complete documentation index at: https://docs.equated.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a rule



## OpenAPI

````yaml /openapi.json post /api/automations/rules
openapi: 3.1.0
info:
  title: Equated API
  version: 1.0.0
  description: >-
    Agent-facing accounting API. Authenticate with a bearer token issued from
    Settings → API Tokens, or via the in-app session cookie when called from the
    web client.
servers:
  - url: https://app.equated.co
    description: API server
security: []
paths:
  /api/automations/rules:
    post:
      tags:
        - Automations
      summary: Create a rule
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AutomationRuleInput'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  rule:
                    $ref: '#/components/schemas/AutomationRule'
        '400':
          description: Invalid rule
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
      security:
        - bearerAuth: []
components:
  schemas:
    AutomationRuleInput:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 255
        description:
          type: string
          nullable: true
          maxLength: 500
        subjectType:
          type: string
          enum:
            - RECEIPT
            - TRANSACTION
        triggerEvent:
          type: string
          enum:
            - RECEIPT_PARSED
            - TRANSACTION_INGESTED
            - TRANSACTION_UPDATED
            - MANUAL_PREVIEW
            - MANUAL_APPLY
        priority:
          type: integer
        stopProcessing:
          type: boolean
        conditions:
          $ref: '#/components/schemas/AutomationConditionGroup'
        effects:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - SET_CURRENCY
                  currency:
                    type: string
                    minLength: 3
                    maxLength: 10
                  sortOrder:
                    type: integer
                    minimum: 0
                required:
                  - kind
                  - currency
                  - sortOrder
              - type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - SET_ACCOUNT
                  accountId:
                    type: integer
                    minimum: 0
                    exclusiveMinimum: true
                  sortOrder:
                    type: integer
                    minimum: 0
                required:
                  - kind
                  - accountId
                  - sortOrder
              - type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - SET_MERCHANT
                  orgMerchantId:
                    type: integer
                    minimum: 0
                    exclusiveMinimum: true
                  sortOrder:
                    type: integer
                    minimum: 0
                required:
                  - kind
                  - orgMerchantId
                  - sortOrder
              - type: object
                properties:
                  kind:
                    type: string
                    enum:
                      - AUTO_POST
                  sortOrder:
                    type: integer
                    minimum: 0
                required:
                  - kind
                  - sortOrder
          minItems: 1
      required:
        - name
        - subjectType
        - triggerEvent
        - conditions
        - effects
    AutomationRule:
      nullable: true
    AutomationConditionGroup:
      type: object
      properties:
        combinator:
          type: string
          enum:
            - AND
            - OR
        conditions:
          type: array
          items:
            anyOf:
              - type: object
                properties:
                  field:
                    anyOf:
                      - type: string
                        enum:
                          - receipt.fileName
                          - receipt.sourceEmail
                          - receipt.sourceSubject
                      - type: string
                        enum:
                          - transaction.name
                          - transaction.merchantName
                  operator:
                    type: string
                    enum:
                      - EQ
                      - CONTAINS
                      - REGEX
                      - IN
                  value:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                required:
                  - field
                  - operator
                  - value
              - type: object
                properties:
                  field:
                    type: string
                    enum:
                      - transaction.search
                  operator:
                    type: string
                    enum:
                      - CONTAINS
                  value:
                    type: string
                required:
                  - field
                  - operator
                  - value
              - type: object
                properties:
                  field:
                    type: string
                    enum:
                      - transaction.amount
                  operator:
                    type: string
                    enum:
                      - EQ
                      - GT
                      - GTE
                      - LT
                      - LTE
                      - BETWEEN
                  value:
                    anyOf:
                      - type: number
                      - type: array
                        items:
                          type: number
                required:
                  - field
                  - operator
                  - value
              - type: object
                properties:
                  field:
                    type: string
                    enum:
                      - transaction.orgMerchantId
                  operator:
                    type: string
                    enum:
                      - EQ
                  value:
                    type: integer
                    minimum: 0
                    exclusiveMinimum: true
                required:
                  - field
                  - operator
                  - value
              - type: object
                properties:
                  field:
                    type: string
                    enum:
                      - transaction.orgMerchantId
                  operator:
                    type: string
                    enum:
                      - IN
                  value:
                    type: array
                    items:
                      type: integer
                      minimum: 0
                      exclusiveMinimum: true
                    minItems: 1
                required:
                  - field
                  - operator
                  - value
              - type: object
                properties:
                  field:
                    type: string
                    enum:
                      - transaction.accountId
                  operator:
                    type: string
                    enum:
                      - EQ
                      - IN
                  value:
                    anyOf:
                      - type: integer
                      - type: array
                        items:
                          type: integer
                required:
                  - field
                  - operator
                  - value
              - type: object
                properties:
                  field:
                    type: string
                    enum:
                      - transaction.direction
                  operator:
                    type: string
                    enum:
                      - EQ
                      - IN
                  value:
                    anyOf:
                      - type: string
                        enum:
                          - IN
                          - OUT
                      - type: array
                        items:
                          type: string
                          enum:
                            - IN
                            - OUT
                required:
                  - field
                  - operator
                  - value
              - type: object
                properties:
                  field:
                    type: string
                    enum:
                      - transaction.isoCurrencyCode
                  operator:
                    type: string
                    enum:
                      - EQ
                      - IN
                  value:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                required:
                  - field
                  - operator
                  - value
      required:
        - combinator
        - conditions
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API token issued from the Equated app under Settings → API Tokens.

````