> ## 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/segment/customer-segmentation",
  "feedback": "Description of the issue"
}
```

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

</AgentInstructions>

# Customer segmentation

> Segment customer by receipt data

scopes:
- admin:receipts
- read:receipts




## OpenAPI

````yaml /mintlify-docs/openapi/spec-receipts.yaml post /accounts/{aid}/receipts/customer_segment
openapi: 3.0.0
info:
  title: Receipts API
  description: >
    API for managing receipts


    ## Changelog

    All notable changes to the API.


    ## 2025-05-01


    > **update**: Extend enum for `receipt.entry_status` with new `Reprinted`
    value


    ## 2024-04-01


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

    > add support for more `receipt.customer.type`.

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


    ## 2023-07-01


    > **new** add support for `items.[].bonus_lines`, discounts with `bonus`
    refs and `total_bonus`

    > - [POST
    /v1/accounts/{aid}/receipts](#tag/receipts/operation/aid_receipts_post)


    ## 2020-05-01


    > Fix the documentation for the response from listing customer receipts. The

    > receipts response was missing receipt items.

    > - [GET
    /receipts/customers/{customer_id}](#operation/aid_receipts_customers_cid_get)


    ## 2019-12-31


    > Add support for `token_expire_days` parameter when creating

    > receipt. The token added to the receipt can be used to retrieve and claim

    > it.

    > - [POST /receipts](#operation/aid_receipts_post)

    > - [GET /receipts/receipt-token](#operation/aid_receipts_receipt_token_get)

    > - [POST
    /receipts/receipt-token](#operation/aid_receipts_receipt_token_post)


    ## 2019-11-31


    > Improve documentation for receipt `receipt_id` property,

    > a non-empty value is required when creating receipts.

    > - [POST /receipts](#operation/aid_receipts_post)


    ## 2019-07-31


    > Extend the receipt format with `store.mcc` property,

    > a four-digit merchant category code for classifying the merchant

    > - [POST /receipts](#operation/aid_receipts_post)

    > - ISO 18245 https://www.iso.org/standard/33365.html


    ## 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


    ## 2018-11-26


    > Extend the `receipt.store` object with `business_name`,

    > an optional property for the store legal name.


    ## 2018-06-04


    > Moved endpoint for search for receipt by receipt_id query parameter

    > - [GET /receipts/search](#operation/aid_receipts_rid_get)


    > Add support for updating anonymous receipt with

    > customer_id and discounts.

    > - [PUT /receipts/all/{receipt_id}](#operation/aid_receipts_update_put)


    ## 2018-04-11


    > Rename property `store.created_on_terminal_id` to

    > `store.terminal_id`.


    > Extend `receipt.discount.refs`. Add `statistics` object

    > and stamp property to refs. The statistics object includes total amount,

    > usage, stamp and current debit_balance.


    > Correct type of `receipt.discount.refs.items.amount` to integer

    > (was string).


    ## 2018-02-02


    > Extend receipt.discounts.refs.

    > Include amount and how the amount was applied to the receipt.items in

    > discount.refs

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


    ## 2017-12-04


    > Add `refs` to receipt discounts. The value

    > is used to record the reference between the owner of the

    > discount and how many times the discount was used on the

    > purchase.


    > Add monetary string properties suffixed with `_dwh`.

    > The new values can be used to store monetary value with

    > a resolution higher than the smallest unit for the

    > currency.


    > Define required properties for a receipt.

    > - *receipt.store.id* *receipt.receipt_id* *receipt.purchase_at*


    > Move `customer_id` from receipt customer to

    > receipt.


    ## 2017-11-22


    > Move receipt `customer_*` properties into a

    > customer object.

    > - *customer_id* => *customer.customer_id*

    > - *customer_token_id* => *customer.token.token_id*

    > - *customer_token* => *customer.token.value*

    > - *customer_token_type* => *customer.token.value*

    > - *customer_pays_tax* => *customer.pays_tax*


    > Add support for more customer properties

    > in the receipt, (first_name, last_name, email,

    > phone_number, metadata, address and status).


    > Add support for adding delivery details to

    > the receipt. `receipt.delivery`.


    ## 2017-10-29


    > Add line_id property to Receipt infocode_items (InfoCodeItem).


    ## 2017-10-27


    > Change `dimension_lines` property to `dimension`

    > for Receipt items (ReceiptItem).


    > Fix typo, rename *card_amound* property to

    > `card_amount` for Payment card_info (CardInfo).
  contact:
    name: API Integration Support
    email: integration@dintero.com
  version: LATEST
  license:
    name: UNLICENSED
    url: https://dintero.com
servers:
  - url: https://api.dintero.com/v1
security:
  - JWT: []
paths:
  /accounts/{aid}/receipts/customer_segment:
    post:
      tags:
        - segment
      summary: Customer segmentation
      description: |
        Segment customer by receipt data

        scopes:
        - admin:receipts
        - read:receipts
      operationId: aid_receipts_customer_segment_post
      parameters:
        - $ref: '#/components/parameters/accountId'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                purchase_from:
                  type: string
                  format: date-time
                purchase_to:
                  type: string
                  format: date-time
                store_ids:
                  type: array
                  items:
                    type: string
                items:
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                      group:
                        type: string
        description: segmentation on receipt data
        required: true
      responses:
        '200':
          description: Customer matching segmentation
          content:
            application/json:
              schema:
                type: object
                properties:
                  customers:
                    type: array
                    items:
                      type: object
                      properties:
                        customer_id:
                          type: string
                          format: uuid
                        purchases:
                          type: integer
                          example: 5
        '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
  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'
  schemas:
    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
  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

````