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

# Create One Rule

> Create a new rule



## OpenAPI

````yaml /api-reference/openapi.json post /api/rest/rules
openapi: 3.1.0
info:
  description: >-
    Upwell is Accounts Receivable automation software for the logistics
    industry. We serve freight brokers, carriers, factors, and anyone who needs
    to get transportation invoices paid.


    Learn more at:


    - [Upwell.com](https://upwell.com)
  title: Upwell REST API
  version: 3.30.2
  termsOfService: https://upwell.com/legal
  contact:
    name: Upwell
    url: https://upwell.com
    email: contact@upwell.com
servers:
  - url: https://api.upwell.com
    description: Production server
  - url: https://staging.api.upwell.com
    description: Staging server
security: []
tags:
  - name: Invoice Approval
    description: Endpoints for managing customer invoice approval workflow
paths:
  /api/rest/rules:
    post:
      tags:
        - Rules
      summary: Create One Rule
      description: Create a new rule
      parameters:
        - description: >-
            Your API key will be used for authentication of the request.
            `Authorization: YOUR_API_KEY`
          in: header
          name: authorization
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                input:
                  $ref: '#/components/schemas/RulesInsertInput'
              type: object
        description: >-
          Query parameters can also be provided in the request body as a JSON
          object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  createRule:
                    description: Rules used for matching, document requirements, etc
                    nullable: true
                    properties:
                      actionType:
                        $ref: '#/components/schemas/RuleActionTypeEnum'
                      actionValue:
                        $ref: '#/components/schemas/jsonb'
                      conditionExpression:
                        nullable: true
                        title: String
                        type: string
                      createdAt:
                        $ref: '#/components/schemas/timestamp'
                      criteriaField:
                        nullable: true
                        title: String
                        type: string
                      criteriaObject:
                        $ref: '#/components/schemas/RuleCriteriaObjectEnum'
                      criteriaOperator:
                        $ref: '#/components/schemas/ComparisonOperatorEnum'
                      criteriaValue:
                        nullable: true
                        title: String
                        type: string
                      customerId:
                        nullable: true
                        title: String
                        type: string
                      id:
                        nullable: false
                        title: String
                        type: string
                      priority:
                        nullable: false
                        title: Int
                        type: integer
                      type:
                        $ref: '#/components/schemas/RuleTypeEnum'
                      updatedAt:
                        $ref: '#/components/schemas/timestamp'
                      validationExpression:
                        nullable: true
                        title: String
                        type: string
                    title: Rules
                    type: object
          description: Responses for POST /api/rest/rules
components:
  schemas:
    RulesInsertInput:
      description: input type for inserting data into table "rules"
      nullable: false
      properties:
        actionType:
          $ref: '#/components/schemas/RuleActionTypeEnum'
        actionValue:
          $ref: '#/components/schemas/jsonb'
        conditionExpression:
          nullable: true
          title: String
          type: string
        createdAt:
          $ref: '#/components/schemas/timestamp'
        criteriaField:
          nullable: true
          title: String
          type: string
        criteriaObject:
          $ref: '#/components/schemas/RuleCriteriaObjectEnum'
        criteriaOperator:
          $ref: '#/components/schemas/ComparisonOperatorEnum'
        criteriaValue:
          nullable: true
          title: String
          type: string
        customerId:
          nullable: true
          title: String
          type: string
        enabled:
          nullable: true
          title: Boolean
          type: boolean
        exceptionConfig:
          $ref: '#/components/schemas/jsonb'
        exceptionType:
          $ref: '#/components/schemas/ExceptionTypeEnum'
        id:
          nullable: true
          title: String
          type: string
        priority:
          nullable: true
          title: Int
          type: integer
        ruleActionType:
          type: object
          description: RuleActionTypeObjRelInsertInput (simplified)
        ruleType:
          type: object
          description: RuleTypeObjRelInsertInput (simplified)
        type:
          $ref: '#/components/schemas/RuleTypeEnum'
        updatedAt:
          $ref: '#/components/schemas/timestamp'
        validationExpression:
          nullable: true
          title: String
          type: string
      title: RulesInsertInput
      type: object
    RuleActionTypeEnum:
      enum:
        - CREATE_EXCEPTION
        - ROUTE_TO_SCAC
        - SET_CUSTOMER_BY_CASS_ID
        - SET_CUSTOMER_BY_CUSTOMER_NAME
        - SET_REQUIRED_DOCUMENTS
        - VALIDATE_CONTENT
      nullable: false
      title: RuleActionTypeEnum
    jsonb:
      nullable: false
      title: jsonb
    timestamp:
      nullable: false
      title: timestamp
    RuleCriteriaObjectEnum:
      enum:
        - CUSTOMER
        - DOCUMENT
        - EMAIL_MESSAGE
        - INVOICE
        - PARSED_INVOICE
        - PORTAL
        - SHIPMENT
        - TMS
      nullable: false
      title: RuleCriteriaObjectEnum
    ComparisonOperatorEnum:
      enum:
        - ARRAY_DOES_NOT_HAVE_OBJECT_WITH_PROPERTY
        - ARRAY_HAS_OBJECT_WITH_PROPERTY
        - CONTAINED_IN
        - CONTAINS
        - EQ
        - GT
        - GTE
        - HAS_KEY
        - HAS_KEYS_ALL
        - HAS_KEYS_ANY
        - ILIKE
        - IN
        - IREGEX
        - IS_NULL
        - LIKE
        - LT
        - LTE
        - NEQ
        - NILIKE
        - NIN
        - NLIKE
        - NREGEX
        - NSIMILAR
        - REGEX
        - SIMILAR
      nullable: false
      title: ComparisonOperatorEnum
    RuleTypeEnum:
      enum:
        - CARRIER_INVOICE_EXCEPTION
        - CUSTOMER_INVOICE_EXCEPTION
        - DOCUMENT_BASIC
        - DOCUMENT_CUSTOM
        - ON_CREATION_FROM_EMAIL
        - REFERENCE_NUMBER
        - SCAC_ROUTING
      nullable: false
      title: RuleTypeEnum
    ExceptionTypeEnum:
      enum:
        - CARRIER_INVOICE_BOL_PO_NUMBER_MISMATCH
        - CARRIER_INVOICE_HAS_LUMPER_LINE_ITEM_AND_NO_LUMPER_RECEIPT
        - CARRIER_INVOICE_MISSING
        - CARRIER_INVOICE_MISSING_ISSUE_DATE
        - CARRIER_INVOICE_MISSING_POD
        - CARRIER_INVOICE_MISSING_POD_FOR_EACH_DELIVERY_STOP
        - CARRIER_INVOICE_MISSING_RATE_CONFIRMATION
        - CARRIER_INVOICE_MISSING_SIGNED_BY
        - CARRIER_INVOICE_TOTAL_AMOUNT_BILL_TOTAL_AMOUNT_MISMATCH
        - CARRIER_INVOICE_TOTAL_AMOUNT_MISMATCH
        - CARRIER_INVOICE_TOTAL_AMOUNT_MISMATCH_BILL_OR_SHIPMENT
        - CARRIER_INVOICE_TOTAL_AMOUNT_SHIPMENT_CARRIER_TOTAL_RATE_MISMATCH
        - CARRIER_NAME_MISMATCH
        - CARRIER_NAME_MISMATCH_BILL_OR_SHIPMENT
        - CARRIER_NAME_MISMATCH_WITH_ASSIGNED_CARRIER
        - CARRIER_NAME_MISMATCH_WITH_BILL
        - CARRIER_NAME_MISMATCH_WITH_SHIPMENT
        - CARRIER_PAY_FROZEN
        - CUSTOMER_INVOICE_EXCEPTION
        - CUSTOMER_INVOICE_HAS_LUMPER_LINE_ITEM_AND_NO_LUMPER_RECEIPT
        - CUSTOMER_INVOICE_MISSING_BOL
        - CUSTOMER_INVOICE_MISSING_INVOICE_COPY
        - CUSTOMER_INVOICE_MISSING_POD
        - CUSTOMER_INVOICE_MISSING_RATE_CONFIRMATION
        - CUSTOMER_INVOICE_POST_DELIVERY_HOLD
        - DAMAGE_OR_SHORTAGE
        - DOCUMENT_LOAD_NUMBER_MISMATCH
        - DOCUMENT_NOT_LEGIBLE
        - DOCUMENT_SEVERE_MISCLASSIFICATION
        - FINAL_CHECK_PACKET_VALIDATION
        - INVOICE_AMOUNT_MISMATCH
        - MATCHING_INVOICE_NOT_FOUND
        - MISSING_CUSTOMER
        - MULTIPLE_MATCHING_INVOICES_FOUND
        - NO_ASSIGNED_CARRIER
        - NO_CARRIER_NAME
        - NO_MATCHING_BILL
        - NO_MATCHING_SHIPMENT
        - OTHER
        - OVERPAYMENT
        - REMITTANCE_LINE_ITEMS_EXCEPTION
        - REMIT_TO_MISMATCH
        - SHIPMENT_ON_HOLD
        - SHIPPER_INVOICE_DOCUMENT_RULES_EXCEPTION
        - TMS_INCIDENT
        - TMS_STATUS_MISMATCH
        - UNDERPAYMENT
        - UNRESOLVED_BILLING_ROUTE
      nullable: false
      title: ExceptionTypeEnum

````