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

# Returns the advanced rules currently available to a customer because of the customer segments they belong to.

> Use this endpoint to show a customer the benefits and campaigns targeted at their profile, such as on a landing page.
It is a dedicated lookup: the customer data endpoint (`GET /v1/pvt/Customer/{id}`) keeps returning only the customer's segments, not their rules.
            
## Which rules are returned
A rule is listed only when **all** of the following are true:
- the rule is active and the current date is within its validity period (`StartDate` / `EndDate`);
- the rule is restricted to customer segments, and the customer belongs to at least one of those segments;
- that segment is active;
- the rule still has participations left, when it has a participation limit.
            
Draft, paused, scheduled and completed rules are never returned. Rules that are not restricted to segments are not returned either, since they apply to every customer.
            
## Empty list
A customer that does not belong to any active segment, or whose segments have no rule available right now, returns HTTP 200 with an empty `result` list.
The list is also empty when the store's plan does not include advanced rules.
            
## Order conditions
A listed rule is available to the customer, but each order must still meet the rule's own conditions to be rewarded.
`purchaseAmount` (amount spent) and `minimumOrderValue` are returned; the other conditions (such as products, brands, categories, stores, payment methods and sales channels) are not part of this response.
            
## Response
Rules are ordered from the oldest to the newest. Each rule lists in `segments` only the customer's segments that made it available, with the same `name` and `tag` returned by the customer data endpoint.
`cardTitle` and `cardDescription` replicate the rule's `name` and `description`, as the BonifiQ widget does.
If the customer is not found, returns HTTP 404 with `hasError: true` and `errorMessage: "Customer not found"`.



## OpenAPI

````yaml https://api.bonifiq.com.br/swagger/Private%20APIs/swagger.json get /v1/pvt/Customer/{id}/segmentrules
openapi: 3.0.0
info:
  title: BonifiQ Private APIs
  description: >-
    # Introduction 

    This is the BonifiQ Private APIs documentation. With these endpoints you can
    interact with BonifiQ systems and enhance your program points.


    # Limitations

    These endpoints are intended to be used in backend communication so they are
    not CORS-compatible and cannot be used by in-browser frontend libraries
    (such as React, Angular, Vue, jQuery, etc)


    If are required to call BonifiQ API from a browser, please refer to our
    [Public APIs](https://api.bonifiq.com.br/apidocs/public)


    # Authentication

    These Private APis use the [Basic
    Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication)
    scheme. You need both an API Token (Username) and API Key (Password) to use
    with it


    You can generate this key pair in BonifiQ admin panel, at the "API Keys"
    menu.


    # How to use this page

    ## Making calls

    You can simulate, test and make calls to API from this Swagger page. To do
    that:

    - Click on the **Authorize** button

    - Inform the Username (API Token) and Passwoird (API Key) and click on
    **Authorize**

    - From the list bellow, choose an API call and click on **Try it out**

    - Inform the required parameters (if any) and click on **Execute**


    ## Verifying requests and responses bodies

    In every API Call there is an explanation of what each field means, theirs
    types and accepted values for all Requests and Responses.


    To view this information, just go to any API Call bellow and in the
    Responses section, click on the Schema.
  version: 1.0.0
servers:
  - url: https://api.bonifiq.com.br
    description: Production
  - url: https://backend--homolog.previewqa.bonifique.com.br
    description: Sandbox
security: []
tags:
  - name: POS
    description: >-
      Flow methods to integrate BonifiQ with a POS system. Check the Flow
      Documentation link on the right
    externalDocs:
      description: Flow Documentation
      url: >-
        https://suporte.bonifiq.com.br/support/solutions/articles/159000319538-integrar-com-pdv
  - name: Checkout
    description: Operations related to checkout cashback redeem, refresh and removal
  - name: Customization
    description: Retrieve customizations for the loyalty program
  - name: Rewards
    description: Interact with rewards already redeemed
paths:
  /v1/pvt/Customer/{id}/segmentrules:
    get:
      tags:
        - Customer
      summary: >-
        Returns the advanced rules currently available to a customer because of
        the customer segments they belong to.
      description: >-
        Use this endpoint to show a customer the benefits and campaigns targeted
        at their profile, such as on a landing page.

        It is a dedicated lookup: the customer data endpoint (`GET
        /v1/pvt/Customer/{id}`) keeps returning only the customer's segments,
        not their rules.
                    
        ## Which rules are returned

        A rule is listed only when **all** of the following are true:

        - the rule is active and the current date is within its validity period
        (`StartDate` / `EndDate`);

        - the rule is restricted to customer segments, and the customer belongs
        to at least one of those segments;

        - that segment is active;

        - the rule still has participations left, when it has a participation
        limit.
                    
        Draft, paused, scheduled and completed rules are never returned. Rules
        that are not restricted to segments are not returned either, since they
        apply to every customer.
                    
        ## Empty list

        A customer that does not belong to any active segment, or whose segments
        have no rule available right now, returns HTTP 200 with an empty
        `result` list.

        The list is also empty when the store's plan does not include advanced
        rules.
                    
        ## Order conditions

        A listed rule is available to the customer, but each order must still
        meet the rule's own conditions to be rewarded.

        `purchaseAmount` (amount spent) and `minimumOrderValue` are returned;
        the other conditions (such as products, brands, categories, stores,
        payment methods and sales channels) are not part of this response.
                    
        ## Response

        Rules are ordered from the oldest to the newest. Each rule lists in
        `segments` only the customer's segments that made it available, with the
        same `name` and `tag` returned by the customer data endpoint.

        `cardTitle` and `cardDescription` replicate the rule's `name` and
        `description`, as the BonifiQ widget does.

        If the customer is not found, returns HTTP 404 with `hasError: true` and
        `errorMessage: "Customer not found"`.
      operationId: Customer_SegmentRules
      parameters:
        - name: id
          in: path
          required: true
          description: Id from the client`s store, usually email address
          schema:
            type: string
          x-position: 1
      responses:
        '200':
          description: >-
            Customer found; returns the available rules, which may be an empty
            list.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/BaseExternalApiResponseOfListOfCustomerSegmentRuleResponse
      security:
        - Basic Authentication: []
components:
  schemas:
    BaseExternalApiResponseOfListOfCustomerSegmentRuleResponse:
      type: object
      description: Standard response envelope used by the External API.
      additionalProperties: false
      properties:
        ErrorMessage:
          type: string
          description: >-
            Error message returned when the request fails validation or
            processing.

            For warnings and successful responses, consumers should usually
            inspect `Result`, `Code` and `Severity` first.
          nullable: true
        ErrorCode:
          type: integer
          description: >-
            Legacy numeric error code derived from internal API errors when
            available.

            This field is relevant only for error flows that use
            `ApiResponseErrorDescription`.
          format: int32
          nullable: true
        Result:
          type: array
          description: Business payload returned by the endpoint.
          nullable: true
          xml:
            wrapped: true
          items:
            xml:
              name: CustomerSegmentRuleResponse
            oneOf:
              - $ref: '#/components/schemas/CustomerSegmentRuleResponse'
        Code:
          type: string
          description: >-
            Endpoint-specific business code formatted as a two-digit string,
            such as `03` or `07`.

            This field is available for success, warning and error outcomes.
          nullable: true
        CodeName:
          type: string
          description: >-
            Symbolic enum name associated with `Code`, such as
            `CheckoutNotFound`.
          nullable: true
        Severity:
          description: >-
            Final severity of the response.

            `Success` means the action completed as expected, `Warning` means
            the request was valid but the business outcome is informational or
            non-ideal, and `Error` means the request should be treated as a
            failure.
          oneOf:
            - $ref: '#/components/schemas/ExternalApiResponseSeverity'
        HasWarning:
          type: boolean
          description: >-
            Convenience flag that is `true` when `Severity` is `Warning`.

            Warnings are valid `200 OK` business outcomes and should not be
            handled as transport or validation errors.
        HasError:
          type: boolean
          description: >-
            Indicates whether the request failed and should be handled as an
            error response.

            This flag is reserved for real API errors; warnings must keep this
            property as `false`.
    CustomerSegmentRuleResponse:
      type: object
      description: >-
        Advanced rule (extra rule) currently available to a customer because of
        the customer segments they belong to.
      additionalProperties: false
      properties:
        Id:
          type: integer
          description: >-
            Rule identifier. It is the same value the purchase points report
            returns as `CampaignId` when `CampaignSource` is `AdvancedRule`.
          format: int32
        Name:
          type: string
          description: Rule name, as shown in the store's admin panel.
        Description:
          type: string
          description: Rule description, as shown in the store's admin panel.
          nullable: true
        RewardType:
          description: >-
            How `RewardValue` must be read: `0` (Percentage) is a percentage of
            the eligible purchase amount; `1` (FixedValue) is a fixed amount
            granted when the rule applies.

            Whether the benefit is granted as points or as cashback follows the
            loyalty program configuration.
          oneOf:
            - $ref: '#/components/schemas/AdvancedRuleRewardType'
        RewardValue:
          type: number
          description: >-
            Percentage (eg: `100` for 100%) or fixed amount, according to
            `RewardType`.
          format: decimal
        StartDate:
          type: string
          description: When the rule started to be valid (UTC).
          format: date-time
        EndDate:
          type: string
          description: >-
            When the rule stops being valid (UTC). `null` means the rule has no
            end date.
          format: date-time
          nullable: true
        PurchaseAmount:
          description: >-
            "Amount spent" condition: range of the order total that activates
            the rule. `null` means the rule has no such condition.
          nullable: true
          oneOf:
            - $ref: '#/components/schemas/CustomerSegmentRulePurchaseAmountResponse'
        MinimumOrderValue:
          type: number
          description: >-
            Minimum order total required for the rule to apply. `null` means
            there is no minimum.
          format: decimal
          nullable: true
        DaysToGrantPoints:
          type: integer
          description: >-
            Days after the order for the benefit to become available. `null`
            means the loyalty program default is used.
          format: int32
          nullable: true
        ExpirationDays:
          type: integer
          description: >-
            Validity, in days, of the benefit granted by this rule. `null` means
            the loyalty program default expiration is used.
          format: int32
          nullable: true
        ShowOnWidgetAndLandingPage:
          type: boolean
          description: >-
            Whether the store chose to advertise this rule on the BonifiQ widget
            and landing page.

            Rules with `false` still apply to the customer's orders; use this
            flag to mirror the store's choice on your own pages.
        CardTitle:
          type: string
          description: >-
            Title of the rule card, exactly as the BonifiQ widget and landing
            page show it. It replicates `Name`.
        CardDescription:
          type: string
          description: >-
            Description of the rule card, exactly as the BonifiQ widget and
            landing page show it. It replicates `Description`.
          nullable: true
        IconUrl:
          type: string
          description: Icon of the rule card.
          nullable: true
        ActionButtonText:
          type: string
          description: >-
            Text of the card's call-to-action button. `null` when the store did
            not configure a button.
          nullable: true
        ActionButtonUrl:
          type: string
          description: >-
            Destination of the card's call-to-action button. `null` when the
            store did not configure a button.
          nullable: true
        Segments:
          type: array
          description: >-
            Active segments of the customer that make this rule available to
            them. A rule may target other segments too; only the ones the
            customer belongs to are listed.
          xml:
            wrapped: true
          items:
            xml:
              name: CustomerSegmentResponse
            oneOf:
              - $ref: '#/components/schemas/CustomerSegmentResponse'
    ExternalApiResponseSeverity:
      type: integer
      description: |-
        0 = Success
        1 = Warning
        2 = Error
      x-enumNames:
        - Success
        - Warning
        - Error
      enum:
        - 0
        - 1
        - 2
    AdvancedRuleRewardType:
      type: integer
      description: |-
        Tipo de recompensa de uma regra avançada (Motor de Regras Avançadas).

        0 = Percentage
        1 = FixedValue
      x-enumNames:
        - Percentage
        - FixedValue
      enum:
        - 0
        - 1
    CustomerSegmentRulePurchaseAmountResponse:
      type: object
      description: >-
        "Amount spent" condition of an advanced rule. Both limits are inclusive
        and compared with the order total.
      additionalProperties: false
      properties:
        MinimumAmount:
          type: number
          description: The order total must be at least this amount ("from X").
          format: decimal
        MaximumAmount:
          type: number
          description: >-
            The order total must be at most this amount. `null` means there is
            no upper limit.
          format: decimal
          nullable: true
    CustomerSegmentResponse:
      type: object
      description: >-
        Customer segment (a manual group of customers maintained by the store)
        the customer belongs to.
      additionalProperties: false
      properties:
        Name:
          type: string
          description: Segment name, as shown in the store's admin panel.
        Tag:
          type: string
          description: >-
            Segment public identifier (slug, unique per store). Use it to
            reference the segment in integrations.
  securitySchemes:
    Basic Authentication:
      type: http
      description: Use API Basic Auth Keys
      scheme: basic

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.