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

# Create Rule API

> Create a Breezing automation rule with conditions and actions to categorize new crypto transactions automatically across accounting workflows.



## OpenAPI

````yaml POST /rules
openapi: 3.1.0
info:
  title: Breezing Public API
  version: 1.0.0
  description: >-
    Crypto accounting API for programmatic access and AI agents. Authenticate
    with an API key using the Authorization header: `Bearer brz_...`
servers:
  - url: https://api.breezing.io/v1
security:
  - BearerAuth: []
paths:
  /rules:
    post:
      tags:
        - Rules
      summary: Create a rule
      description: >-
        Create an automation rule. The rule is stored but does NOT automatically
        apply to existing transactions. Call POST /rules/apply with the new
        rule's id to retroactively apply it.
      parameters:
        - schema:
            type: string
            description: >-
              Organization ID. Use GET /v1/companies to discover available
              org/company pairs.
            example: '1'
          required: true
          description: >-
            Organization ID. Use GET /v1/companies to discover available
            org/company pairs.
          name: orgId
          in: query
        - schema:
            type: string
            description: >-
              Company ID. Use GET /v1/companies to discover available companies
              and their access levels.
            example: '1'
          required: true
          description: >-
            Company ID. Use GET /v1/companies to discover available companies
            and their access levels.
          name: companyId
          in: query
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRuleBody'
      responses:
        '200':
          description: Rule created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      id:
                        type: number
                    required:
                      - id
                required:
                  - success
                  - data
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '403':
          description: >-
            API key has no access to this company, has read-only access where
            write was required, or the company subscription is inactive
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - false
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                    required:
                      - code
                      - message
                required:
                  - success
                  - error
      security:
        - BearerAuth: []
components:
  schemas:
    CreateRuleBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 127
        description:
          type: string
          nullable: true
          maxLength: 255
        conditions:
          nullable: true
          description: >-
            Opaque JSON conditions object. Required. Mirror the shape produced
            by the Breezing rule-builder UI.
        actions:
          type: array
          items:
            nullable: true
          description: Opaque JSON actions array. Required.
        conditionsLength:
          type: integer
          minimum: 0
          description: >-
            Number of distinct conditions in `conditions`. Used by the UI; pass
            the count.
        actionsLength:
          type: integer
          minimum: 0
          description: Number of actions in `actions`. Used by the UI; pass the count.
        isActive:
          type: boolean
          default: true
        order:
          type: integer
          minimum: 0
          default: 0
          description: >-
            Apply priority. 0 is the highest priority; rules apply in ascending
            order.
      required:
        - name
        - actions
        - conditionsLength
        - actionsLength

````