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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.dintero.com/feedback

```json
{
  "path": "/api-reference/rules-automations/automation-collection",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Automation collection

> Get available automations for the account

scopes:
- admin:automations
- read:automations




## OpenAPI

````yaml /mintlify-docs/openapi/spec-discounts.yaml get /accounts/{aid}/automations/rules
openapi: 3.0.0
info:
  title: Discounts API
  description: >
    API for managing discount for customers


    # Changelog

    All notable changes to the API.


    ## 2026-02-27


    > **update**: Add support for listing discount rules by state `active`,

    > `scheduled` and `completed`

    > - [GET /discounts/rules](#operation/aid_discounts_get)


    ## 2026-01-31


    > **new**: Add support for creating discount rule with `net_amount`
    requirement.

    > The new option enables support creating rules that works with receipts
    that

    > receive external discounts, where use will limit rule from being enabled

    > - [POST /discounts/rules](#operation/aid_discounts_post)

    > - [Example
    `requirement.net_amount`](#section/Discount-Examples/Net-Amount)


    ## 2024-09-01


    > **new**: Add support for creating discount with 

    > `limitation.dynamic_purchase_to_days`

    > - [POST /discounts/rules](#operation/aid_discounts_post)

    > - [Example
    `limitation.dynamic_purchase_to_days`](#section/Discount-Examples/Limitation:-dynamic-purchase-to)


    > **new**: Add support for updating `reward.base` when updating

    > a discount rule.

    > - [PUT /discounts/rules/{did}]((#operation/aid_discounts_did_put)


    ## 2024-04-01


    > **update**: Remove enum requirement for `enrolled_by.type` and

    > add support for more `receipt.customer.type` to support changes to the

    > customer user definition. See
    https://docs.dintero.com/customers-api.html#section/Changelog/2024-03-01

    > - [POST
    /v1/accounts/{aid}/discounts/available_for_receipt](#tag/use-discounts/operation/aid_discounts_available_for_receipt_post)


    ## 2023-12-01


    > **new**: Add support for `ANY_ITEM` when creating discount rule. The

    > new option makes it possible to create item rules that is valid for

    > any item but cannot be combined with other item rules (on same item)

    > - [POST /discounts/rules](#operation/aid_discounts_post)

    > ```json

    > {

    >   "requirement": {

    >     "item": {

    >       "items": [{"id":"ANY_ITEM"}],

    >     },

    >   --->8---------

    > }

    > ```


    > **new**: Add support for rules search.

    > - [POST
    /v1/accounts/{aid}/discounts/search/rules](#tag/rules/operation/aid_discounts_rules_search_post)


    ## 2023-11-01


    > **new**: Support creating rules with `reward.values`. The new option

    > make it possible to create a single rule that can give different

    > rewards based on purchased items, replacing the need to create a rule

    > for each reward.

    > - [POST
    /v1/accounts/{aid}/discounts/rules](#tag/rules/operation/aid_discounts_post)

    > - [Reward values example](#section/Discount-Examples/Reward-values)


    ## 2023-07-01


    > - **new** Support creating bonus reward rules via `reward.effect=bonus`.

    > Bonus given on a purchase will be included in receipt

    > `discounts.[].refs[].bonus` and `items.[].bonus_lines`

    >

    > - [POST
    /v1/accounts/{aid}/discounts/rules](#tag/rules/operation/aid_discounts_post)

    > - [POST
    /v1/accounts/{aid}/discounts/available_for_receipt](#tag/use-discounts/operation/aid_discounts_available_for_receipt_post)


    ## 2022-03-01


    > - **new** Support private metadata properties in discount rules.

    > Metadata prefixed with `dintero:exclude:public:` will now be

    > excluded when listing public rules


    ## 2021-10-01


    > Add support for specifying
    `limitation.discount_activation[*].type=deactivate_if_discount_active`.

    > Use the new option to limit the activation of a discount based on other
    active

    > discounts

    > - [POST /discounts/rules](#operation/aid_discounts_post)


    ## 2021-09-01


    > **DEPRECATE**: `requirement.store_id` <br/>

    > Use the `requirement.store.id` property to limit discount on store id.

    > - [POST /discounts/rules](#operation/aid_discounts_post)


    ## 2021-07-01


    > Add support for specifying `requirement.customer.attributes.[property]`

    when creating new discount rules.

    > - [POST /discounts/rules](#operation/aid_discounts_post)



    ## 2020-08-01


    > Add support for campaigns, group rules by campaign_id

    > - [POST /discounts/campaigns](#operation/aid_discounts_campaigns_post)


    ## 2020-05-01


    > Add support for `offering_constraint_id` when giving discount to one

    > or more customers. The new optional can be used to constrain how many

    > times the customer will receive the discount.

    > - [POST
    /discounts/rules/{did}/customers](#operation/aid_discounts_did_customers_post)


    ## 2020-03-10


    > Extend discount statistics with `current_stamp`

    > - [GET
    /discounts/customers/{customer_id}/refs/{ref_id}](#operation/aid_discounts_customer_cid_get_ref_id)

    > - [GET
    /discounts/rules/{did}/usages](#operation/aid_discounts_did_usages_get)

    > - [GET
    /discounts/customers/{customer_id}/rules](#operation/aid_discounts_customer_cid_get)

    >


    ## 2020-01-31


    > Add support for adding requirements for MCC ranges, and currencies in
    discounts.

    > - [POST /discounts/rules]((#operation/aid_discounts_post)

    > - [PUT /discounts/rules/{did}]((#operation/aid_discounts_did_put)


    > Add support for adding usage ref (usage, stamp, amount) to

    > a customer discount ref.

    > - [POST
    /discounts/customers/{customer_id}/refs/{ref_id}](#operation/aid_discounts_customer_cid_post_ref_id)

    > - [GET
    /discounts/customers/{customer_id}/refs/{ref_id}](#operation/aid_discounts_customer_cid_get_ref_id)


    > Add support for discount rules with `discount_code`.

    > The `discount_code` must be included in the purchase, either in the

    > new `discount_code` property or as an item, where the item id is set

    > to the `discount_code`.

    > - [POST /discounts/public/rules](#operation/aid_discounts_post)

    > - [POST
    /discounts/available_for_receipt](#operation/aid_discounts_available_for_receipt_post)


    > Add support for `no_customer_id` query parameter when

    > listing public discount rules.

    > - [GET /discounts/public/rules](#operation/aid_discounts_public_get)


    ## 2019-12-31


    > Add support for specifying `requirement.store` when creating

    > new discount rules.

    > - [POST /discounts/rules](#operation/aid_discounts_post)


    > Add support for giving discounts on purchase with no `customer_id`.

    > - [POST
    /discounts/available_for_receipt](#operation/aid_discounts_available_for_receipt_post)

    > - [POST
    /discounts/rules/{did}/customers](#operation/aid_discounts_did_customers_post)


    > Add support for updating rules `requirement.purchase_to`.

    > - [PUT /discounts/rules/{did}](#operation/aid_discounts_did_put)


    ## 2019-10-31


    > Change minumum number of mixes in a discount rule from

    > 2 to 1

    > - [POST /discounts/rules](#operation/aid_discounts_post)


    ## 2019-07-31


    > Exclude statistics, usage and stamp count and more

    > in response from:

    > - [GET
    /discounts/rules/{did}/customers](#operation/aid_discounts_did_customers_get)


    > Add new endpoint for retrieving discount usages

    > - [GET
    /discounts/rules/{did}/usages](#operation/aid_discounts_did_usages_get)


    ## 2019-06-31


    > The scope required for accessing endpoint has changed,

    > we will continue to support the old scopes but they was removed from

    > the documentation


    ## 2019-04-31


    > Include statistics, usage and stamp count and more

    > in response from:

    > - [GET
    /discounts/customers/{customer_id}/rules](#operation/aid_discounts_customer_cid_get)

    > - [GET
    /discounts/rules/{did}/customers](#operation/aid_discounts_did_customers_get)


    > *deprecate* the `statistics.used` property, replaced by
    `statistics.usage`.


    > *Moved* the `debit_balance` property into `statistics.usage`.


    > Add new `mixes` property to the discount requirement item.

    > The new property can be used to define Mix & Match discounts, discount

    > that requires multiple items to be purchase to enable the reward.

    > - [POST /discounts/rules](#operation/aid_discounts_post)


    ## 2019-01-31


    > Add new `private` property to the discount rule object.

    > A private discount will be excluded from public discount

    > collection if the rule is given to all customers.

    > - [POST /discounts/rules](#operation/aid_discounts_post)

    > - [PUT /discounts/rules/{did}](#operation/aid_discounts_did_put)

    > - [GET /discounts/public/rules](#operation/aid_discounts_public_get)


    > Add new endpoint for getting details about a

    >  discount claim.

    > - [GET
    /discounts/available_for_receipt/claims/{claim_id}](#operation/aid_discounts_available_for_receipt_get_claim)


    > Increase maximum `limit` value accepted by endpoint:

    > - [GET
    /discounts/rules/{did}/customers](#operation/aid_discounts_did_customers_get)


    ## 2018-11-26


    > Extend the `discount.limitation` with

    > `discount_eligible`, an optional property for limiting what

    > items in a purchase is eligible for the rule.


    > Extend the `discount.limitation` with

    > `discount_combination`, an optional property for limiting how

    >  many other discount rules the rule can be combined with.


    > Extend the `discount.limitation` with `blacklist`,

    > an optional property for blacklisting items by id or group, items

    > not eligible for discount.


    ## 2018-06-04


    > Extend support for discount customer requirement.

    > - [POST /discounts/rules](#operation/aid_discounts_post)


    > Add support for claim collection

    > - [GET
    /discounts/available_for_receipt/claims](#operation/aid_discounts_available_for_receipt_get_claims)


    > Add support for inactive discount by new `active`

    > property on discount.

    > - [POST /discounts/rules](#operation/aid_discounts_post)

    > - [PUT /discounts/rules/{did}](#operation/aid_discounts_did_put)

    > - [GET /discounts/rules](#operation/aid_discounts_get)


    > An inactive discount will not be included in response from

    > - [GET /discounts/public/rules](#operation/aid_discounts_public_get)

    > - [GET
    /discounts/customers/{customer_id}/rules](#operation/aid_discounts_customer_cid_get)


    > Add new endpoint for listing customer a discount

    > has been given to.

    > - [GET
    /discounts/rules/{did}/customers](#operation/aid_discounts_did_customers_get)


    ## 2018-04-11


    > Extend support for update of discount rule to allow

    > update of limitation and requirement

    > Include `updated_by` property container the user/client that last updated

    > the discount rule.

    > - [PUT /discounts/rules/{did}](#operation/aid_discounts_did_put)


    > Add support for filtering discounts by `state`, `since_datetime`,
    `purchase_from`

    > and `purchase_to`

    > - [GET /discounts/rules](#operation/aid_discounts_get)


    ## 2018-02-15


    > Change default item.quantity requirement from `1` to `0`.

    > Allows discount on items where quantity is in weigth/volume and value is <
    1

    > by default.


    > Add minimum length for token token_id/type/value/customer_id

    > - [POST /discounts/events](#operation/aid_discounts_events_post)


    > Add new reward type `discount_debit`


    ## 2018-02-02


    > Add `links` and `metadata` property to the discount.

    >  Support adding links related to the discount and any key/value metadata


    ## 2017-12-04


    > Add `type` property to the discount.

    > The value is calculated from the discount.requirement,

    > stating if the discount is given on the receipt or

    > limited to specific items.


    > Change type of properties to support decimal values.

    > - *discount.reward.value* *discount.requirement.item.quantity*


    > Rename reward type enums.

    > - *discount_total_amount* => *discount_amount*

    > - *discount_percent_amount* => *discount_percent*

    > - *discount_new_item_price* => *discount_item_new_price*

    > - *discount_item* => *discount_item_quantity*

    > - *discount_item_percent_amount* => *discount_item_percent*


    > Define required properties for a discount requirement.

    > - *requirement.purchase_from* *requirement.purchase_to*


    ## 2017-11-22


    > Add support for discount rule with

    > customer.status requirement.



    # Bonus Examples


    Short bonus rules examples for the supported reward types


    ## Bonus


    Get 15000 in bonus for purchase at store if total is over 50000

        {
            "limitation": {
                "discount_reward_usage": 1
            },
            "requirement": {
                "gross_amount": 50000,
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z",
                "store_ids": ["sc029"]
            },
            "reward": {
                "type": "discount_amount",
                "value": 15000,
                "effect": "bonus"
            }
        }

    # Discount Examples


    Short discount rules examples for the supported reward types


    ## Amount


    Get 15000 in discount for purchase at store if total is over 50000

        {
            "limitation": {
                "discount_reward_usage": 1
            },
            "requirement": {
                "gross_amount": 50000,
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z",
                "store_ids": ["sc029"]
            },
            "reward": {
                "type": "discount_amount",
                "value": 15000
            }
        }

    ## Net Amount


    Get 15000 in discount for purchase at store if total net amount is over
    50000


    > Use `net_amount` over `gross_amount` if the requirement should be

    > dependent on external discount that reduces the `net_amount` before
    discount

    > is calculated

        {
            "limitation": {
                "discount_reward_usage": 1
            },
            "requirement": {
                "net_amount": 50000,
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z",
                "store_ids": ["sc029"]
            },
            "reward": {
                "type": "discount_amount",
                "value": 15000
            }
        }

    ## % one-time


    Get 25% discount for one purchase that includes the item 714118

        {
            "limitation": {
                "discount_repeat_usage": 1
            },
            "requirement": {
                "item": {
                    "items": [{"id": "714118"}]
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_percent",
                "value": 25
            }
        }

    ## % only currencies


    25 % discount on tex-mex items if purchase currency is `NOK`.

        {
            "requirement": {
                "item": [{"group_id": "tex-mex"}],
                "purchase_from": "2020-01-03T09:00:04Z",
                "purchase_to": "2020-01-03T22:00Z",
                "currencies": ["NOK"]
            },
            "reward": {
                "type": "discount_percent",
                "value": 25
            }
        }

    ## % anything-but currencies


    25% discount on tex-mex items if purchase currency is anything but `NOK`.

        {
            "requirement": {
                "item": [{"group_id": "tex-mex"}],
                "purchase_from": "2020-01-03T09:00:04Z",
                "purchase_to": "2020-01-03T22:00Z",
                "currencies": [{"anything-but": ["NOK"]}]
            },
            "reward": {
                "type": "discount_percent",
                "value": 25
            }
        }

    ## % discount_code


    25% discount on tex-mex items when using discount_code `TACOFREDAG`.

        {
            "requirement": {
                "item": [{"group_id": "tex-mex"}],
                "discount_code": "TACOFREDAG",
                "purchase_from": "2020-01-03T09:00:04Z",
                "purchase_to": "2020-01-03T22:00Z"
            },
            "reward": {
                "type": "discount_percent",
                "value": 25
            }
        }

    ## New price - one-time


    Discount calculated from the `original price - new price`

        {
            "limitation": {
                "discount_repeat_usage": 1
            },
            "requirement": {
                "item": {
                    "items": [{"id": "714118"}]
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_new_price",
                "value": 2500
            }
        }

    ## New price - mix & match


    All items in a mix will get the new price and discount calculated

    from their original prices and new price

        {
            "limitation": {
                "discount_reward_usage": 1
            },
            "requirement": {
                "item": {
                    "mixes": [
                        {"items":[{"id": "cola"}], "quantity":1, "reward_eligible": true},
                        {"items":[{"id": "sprite"}], "quantity":1, "reward_eligible": true}
                    ]
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_new_price",
                "value": 3000
            }
        }

    ## New price - mix & match total


    New total price for the items in the mix. Discount calculated from original

    prices and the new total.

        {
            "limitation": {
                "discount_reward_usage": 1
            },
            "requirement": {
                "item": {
                    "mixes": [
                        {"items":[{"group_id": "trampoline"}], "quantity":1, "reward_eligible": true},
                        {"items":[{"group_id": "sikkerhetsnett"}], "quantity":1, "reward_eligible": true}
                    ]
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_mix_new_price",
                "value": 255990
            }
        }

    ## Quantity - 3 for 2


    Give the cheapest for free

        {
            "requirement": {
                "item": {
                    "items": [{"id": "714118"}],
                    "quantity": 3
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_quantity",
                "value": 1
            }
        }

    ## Quantity - mix & match


    Get one free if mix is in purchase. Get colgate for free if

    purchased with any soda

        {
            "requirement": {
                "item": {
                    "mixes": [
                        {"items": [{"id":"solo", "id":"cola"}], "quantity":1, "reward_eligible": false},
                        {"items": [{"group_id": "colgate"}], "quantity":1, "reward_eligible": true}
                    ]
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_quantity",
                "value": 1
            }
        }

    ## Item % - stamp


    Get 50% discount on every 5 purchase done within 100 days

        {
            "limitation": {
                "stamp_expire_days": 100
            },
            "requirement": {
                "item": [{"id": "cola"}],
                "stamp": 5,
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_percent",
                "value": 50
            }
        }

    ## Debit - min purchase


    Get 20000 (initial) in debit discount, can be used

    over multiple purchase where the total amount is over 10000.

        {
            "requirement": {
                "gross_amount": 10000,
                "purchase_from": "2018-01-29T11:44:04Z",
                "purchase_to": "2018-02-24T12:00Z"
            },
            "reward": {
                "type": "discount_debit",
                "value": 20000
            }
        }

    ## Reward values


    Reward values are supported for reward types:

     - discount_amount
     - discount_item_new_price
     - discount_item_percent
     - discount_percent

    Use reward values to combine product rewards into a single discount rule.


    The example will calculate reward so items of group id `G1` get a new price

    of `2000` and item with id `714118`

    will get new price of 2500

        {
            "requirement": {
                "item": {
                    "items": [{"id": "714118"}, {"group_id": "G1"}],
                    "quantity": 1
                 },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_new_price",
                "value": 2500
                "values": [
                    {
                        "items": [{ "group_id": "G1" }],
                        "value": 2000
                    }
                ]
            }
        }

    ## Limitation - reward & repeat


    Limit new price discount to max 3 items and 1 purchase.

    Note that `requirement.item.quantity` must be set to enable

    the `discount_reward_usage` limitation.

        {
            "limitation": {
                "discount_repeat_usage": 1,
                "discount_reward_usage": 3
            },
            "requirement": {
                "item": {
                    "items": [{"id": "714118"}],
                    "quantity": 1
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_new_price",
                "value": 2500
            }
        }

    ## Limitation: purchase time


    Limit discount to specific day of the week, e.g

    receive 50 % in discount on Tuesdays

        {
            "limitation": {
                "discount_hours": {
                    "hours": [{
                    "day": "tue",
                    "start": "10:00",
                    "end": "23:00"
                    }],
                    "timezone": "Europe/Oslo"
                }
            },
            "requirement": {
                "item": {
                    "items": [{"id": "714118"}]
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_percent",
                "value": 50
            }
        }

    ## Limitation: combination


    Limit discount with blacklist, combination and purchase not

    received other discounts

        {
            "limitation": {
                "discount_combination": 0,
                "discount_eligible": "receipt_no_discount",
                "blacklist": [{"group_id": "tobacco"}]
            },
            "requirement": {
                "item": {
                    "items": [{"id": "*"}]
                },
                "purchase_from": "2017-11-29T11:44:04Z",
                "purchase_to": "2017-12-24T12:00Z"
            },
            "reward": {
                "type": "discount_item_percent",
                "value": 10
            }
        }

    ## Limitation: dynamic purchase to


    Limit the `purchase_to` to a time calculated from when the discount was
    given to

    a customer


    > E.g. a discount rule that "never" expires, but it will only be available

    > for the customer for 30 days when given

        {
            "limitation": {
                "dynamic_purchase_to_days": 30
            },
            "requirement": {
                "item": {
                    "items": [{"id": "*"}]
                },
                "purchase_from": "2025-04-30T08:47:34.344Z",
                "purchase_to": "2099-04-30T08:47:34.344Z"
            },
            "reward": {
                "type": "discount_item_percent",
                "value": 10
            }
        }
  contact:
    name: API Integration Support
    email: integration@dintero.com
  version: 1.0.0
  license:
    name: UNLICENSED
    url: https://dintero.com
servers:
  - url: https://api.dintero.com/v1
security:
  - JWT: []
paths:
  /accounts/{aid}/automations/rules:
    get:
      tags:
        - rules automations
      summary: Automation collection
      description: |
        Get available automations for the account

        scopes:
        - admin:automations
        - read:automations
      operationId: aid_automations_rules_get
      parameters:
        - $ref: '#/components/parameters/accountId'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/startingAfter'
        - name: state
          in: query
          description: |
            Indicate the state of the automation to return
          required: false
          schema:
            type: string
            enum:
              - all
              - available
              - deleted
            default: all
      responses:
        '200':
          description: Automation collection
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  allOf:
                    - $ref: '#/components/schemas/Entity'
                    - $ref: '#/components/schemas/Automation'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/AccessForbidden'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - JWT: []
components:
  parameters:
    accountId:
      name: aid
      description: |
        An id that uniquely identifies the account.
      in: path
      required: true
      schema:
        type: string
        format: ^[PT]{1}\d{8}$
        minLength: 9
        maxLength: 9
    limit:
      name: limit
      in: query
      description: |
        A limit on the number of objects to be returned. Limit can range
        between 1 and 100 items, and the default is 10 items.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 10
    startingAfter:
      name: starting_after
      in: query
      description: |
        cursor for use in pagination. starting_after is an object ID
        that defines your place in the list. For instance, if you make
        a list request and receive 100 objects, end the result contains
          `paging_token=pt1`, your subsequent call can include
        `starting_after=pt1` in order to fetch the next page of the list.
      required: false
      schema:
        type: string
  schemas:
    Entity:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: |
            An UUID that uniquely identifies the resource
          readOnly: true
        created_at:
          type: string
          format: date-time
          description: |
            The date-time when the resource was created
          readOnly: true
        created_by:
          type: string
          example: 1c92f7e1-2897-4d46-bdcc-c127a914fb4e
          description: |
            The ID of the user/client created the resource
          readOnly: true
        updated_at:
          type: string
          format: date-time
          description: |
            The date-time when the resource was last updated
          readOnly: true
        deleted_by:
          type: string
          example: 1c92f7e1-2897-4d46-bdcc-c127a914fb4e
          description: |
            The ID of the user/client created the resource
          readOnly: true
        deleted_at:
          type: string
          format: date-time
          readOnly: true
    Automation:
      type: object
      required:
        - requirement
        - actions
      properties:
        name:
          type: string
          description: Optinal name for the automation rule
          example: Company Automation
        description:
          type: string
          description: Optional description for the automation rule
          example: Automation for non blocked companies with postal_code 0342 or 6901
        requirement:
          type: object
          required:
            - automation_from
            - automation_to
            - events
          properties:
            automation_from:
              description: |
                limit the time when automation is activated, the value must be
                before the discount `requirement.purchase_to` time if the action
                type is `discount`
              type: string
              format: date-time
            automation_to:
              description: |
                limit the time when the automation is active, the value must be
                before the discount `requirement.purchase_to` time if the action
                type is `discount`
              type: string
              format: date-time
            events:
              type: array
              description: |
                Events that the automation will be applied to (triggers)
              minItems: 1
              items:
                type: string
                enum:
                  - customer_add
                  - customer_update
                  - customer_remove
                  - token_add
                  - token_remove
                  - receipt_add
            filter:
              type: object
              description: >
                limit the automation by properties read from the events accepted

                by the automation

                The key for each filter must be a valid JSONPath, that will be
                used

                to resolve the event value to match with the path value. The
                result of the JSONPath

                must be a single value or list of values to compare.


                #### Excact matching

                  - `"$.store.id": ["S00123"]`

                #### Anything-but matching

                  - `$.status: [{"anything-but":"blocked"}]`

                #### Numeric Range matching


                In addition to the `=` operator, a numeric filter can include
                `<`, `<=`, `>`, and `>=`

                  - `$.gross_amount: [{"numeric":[">", 50000]}]`
                  - `$.gross_amount: [{"numeric":[">", 0, "<=", 1500]}]`

                #### AND/OR Logic

                Apply AND/OR logic to your filter policies as follows.


                ##### AND logic

                Apply AND logic by using multiple names (keys). For example, the
                filters:

                      {
                        "$.store.id": ["S00129"],
                        "$.gross_amount": [{"numeric":[">", 50000]}]
                      }

                Matches events with a store.id of S00129 and a gross_amount
                value that's over 50000.


                ##### OR logic


                Apply OR logic by assigning multiple values to an attribute
                name. For example, the filter:

                    "$.addresses[*].postal_code": ["0342", "6901", "5020"]

                Matches events with an address.postal_code value of 0342 or 6901
                or 5020.
              example:
                $.type:
                  - company
                $.status:
                  - anything-but: blocked
                $.addresses[*].postal_code:
                  - '0342'
                  - '6901'
        limitation:
          type: object
          required:
            - automation_repeat
          properties:
            automation_repeat:
              description: |
                limit the number of times the automation will trigger and
                give the customer the discount. A value of `-1` will disable the
                limitation and the automation will give discount to the customer
                every time
              type: number
              default: 1
              minimum: -1
        actions:
          type: array
          description: |
            Actions to perform if the automation is triggered
            (given events, limitation and filter)
          minItems: 1
          maxItems: 1
          items:
            $ref: '#/components/schemas/AutomationAction'
    AutomationAction:
      discriminator:
        propertyName: type
        mapping:
          discount:
            $ref: '#/components/schemas/AutomationActionDiscount'
          http:
            $ref: '#/components/schemas/AutomationActionHTTP'
      oneOf:
        - $ref: '#/components/schemas/AutomationActionDiscount'
        - $ref: '#/components/schemas/AutomationActionHTTP'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
          properties:
            code:
              type: string
              description: The code used to identify the error/warning
            errors:
              type: array
              description: The nested error(s) encountered during validation
              items:
                type: object
            message:
              type: string
              description: The human readable description of the error/warning
    AutomationActionDiscount:
      x-discriminator-value: discount
      allOf:
        - required:
            - id
          properties:
            id:
              type: string
              description: |
                Id of existing discount to give to customer the
                automation originated from
              readOnly: false
        - $ref: '#/components/schemas/AutomationAction'
      title: Automation Action Discount
    AutomationActionHTTP:
      type: object
      x-discriminator-value: http
      allOf:
        - $ref: '#/components/schemas/AutomationAction'
        - required:
            - url
            - method
          properties:
            url:
              type: string
              example: >-
                https://api.dintero.com/v1/accounts/{aid}/discounts/rules/{did}/customers
            method:
              type: string
              example: POST
            content_type:
              type: string
              example: application/json
            body:
              type: string
              example: '{ "customers": [ "$.customer_id" ] }'
      title: Automation Action HTTP
  responses:
    BadRequest:
      description: Bad / Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    AccessForbidden:
      description: Access forbidden, invalid JWT token was used
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Unexpected Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    JWT:
      type: http
      description: >
        Bearer authentication (token authentication) should be used for
        accessing the API.


        Use [Get
        Token](https://docs.dintero.com/api.html#operation/aid_auths_oauth_token_post)
        to get an access token for client credentials.

        Pass the token in the request header:

            Authorization: Bearer {access_token}

        where the **access_token** is JSON Web Tokens (JWT).
      scheme: bearer
      bearerFormat: JWT

````