---
title: "Calculates prices for the given data."
url: "https://developer.migros.ch/apis/central-pricing-facade-1/versions/3d3408ff-7c6b-4890-82ea-373f6d4abb25/operations/calculate"
---

> Full API specification: https://developer.migros.ch/apis/central-pricing-facade-1/versions/3d3408ff-7c6b-4890-82ea-373f6d4abb25.md

# Calculates prices for the given data.

`POST` `/migros/sales/central-pricing/v1/{store}/calculate`

Operation ID: `calculate`

Business errors are documented at <a href="https://wiki.migros.net/x/Gb6cGw">https://wiki.migros.net/x/Gb6cGw</a>.

## Path parameters

- `store` (string, required) - Store which the calculation is based on

## Request body (required)

Content types: `application/json`

## Responses

- `200` - Successful calculation result
- `400` - Invalid data given

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: Central Pricing Facade
  version: 1.3.3.7
servers:
  - description: URL of upstream
    url: https://api.migros.ch
paths:
  /migros/sales/central-pricing/v1/{store}/calculate:
    post:
      description: Business errors are documented at <a
        href="https://wiki.migros.net/x/Gb6cGw">https://wiki.migros.net/x/Gb6cGw</a>.
      operationId: calculate
      parameters:
        - description: Store which the calculation is based on
          example: "0034833"
          in: path
          name: store
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Calculate"
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Calculation"
          description: Successful calculation result
        "400":
          $ref: "#/components/responses/400"
      summary: Calculates prices for the given data.
      tags:
        - central-pricing-facade
security:
  - Kong-Api-Key: []
components:
  schemas:
    Calculate:
      additionalProperties: false
      description: Request body for calculating prices.
      properties:
        coupons:
          description: List of coupon GTINs to take into account for the price calculation.
          items:
            example: "7613404420317"
            minLength: 4
            type: string
          type: array
        customer:
          description: Information about the customer and their loyalty.
          example:
            cumulus_number: "2099123123123"
            loyalty:
              - cumulus
          nullable: true
          oneOf:
            - $ref: "#/components/schemas/Customer"
        date:
          description: >-
            Date and time used for calculating the prices.


            This defaults to now but can be used to calculate prices based
            historic data.
          format: date-time
          nullable: true
          type: string
        products:
          description: List of products to calculate prices for.
          example:
            - product_id: "120299100000"
              quantity: 3
            - product_id: "101924500000"
              unit: KG
              weight: 3.5
          items:
            $ref: "#/components/schemas/ProductToCalculate"
          minItems: 1
          type: array
        ucbs:
          description: List of user coupon IDs (UCB) to take into account for the price
            calculation.
          items:
            example: "456456456"
            minLength: 4
            type: string
          type: array
      required:
        - products
      type: object
    Calculation:
      additionalProperties: false
      description: Response with calculated prices.
      properties:
        amounts:
          description: Information about the different total amounts.
          nullable: true
          oneOf:
            - $ref: "#/components/schemas/Amounts"
        coupons:
          description: List of coupons attached to the calculation.
          items:
            type: string
            uniqueItems: true
          minItems: 1
          type: array
        products:
          description: List of products with calculated prices.
          items:
            $ref: "#/components/schemas/CalculatedItem"
          minItems: 1
          type: array
        ucbs:
          description: List of UCBs with calculated prices.
          items:
            $ref: "#/components/schemas/CalculatedItem"
          minItems: 1
          type: array
        vat:
          description: Information about the VAT.
          items:
            $ref: "#/components/schemas/Vat"
          type: array
      required:
        - products
        - amounts
        - vat
      type: object
    Customer:
      additionalProperties: false
      description: Information about the customer.
      properties:
        cumulus_number:
          description: Cumulus number of the customer.
          example: "2099123123123"
          maxLength: 40
          minLength: 10
          type: string
        loyalty:
          description: >-
            Loyalty programs the customer is part of.

            A person who uses the loyalty program `GKK` cannot use any of the
            other loyalty programs. Therefore the maxItems

            is set to 4, even though there are 5 loyalty programs in total.
          example:
            - cumulus
          items:
            enum:
              - cumulus
              - famigros
              - genossenschafter
              - migusto
              - gkk
            type: string
          maxItems: 4
          type: array
          uniqueItems: true
      required:
        - cumulus_number
      type: object
    ProductToCalculate:
      additionalProperties: false
      description: Product to calculate prices for.
      properties:
        price_per_unit:
          description: >-
            User-defined price per unit for the product.


            This can be used to override a price for a given product.

            If not set, the price will be looked up.

            The price is per unit of the product. Promotions are calculated
            based on this price.
          example: 1.75
          format: float
          minimum: 0
          nullable: true
          type: number
        product_id:
          description: ID of the product.
          example: "101924500000"
          maxLength: 40
          minLength: 9
          type: string
        quantity:
          description: |-
            Number of products.

            This is not used for weight-based products.
          example: 1
          exclusiveMinimum: true
          minimum: 0
          nullable: true
          type: integer
        unit:
          description: |-
            User-defined unit for the product.

            This can be used to override the unit for a given product.
            If not set, the unit will be looked up.
          enum:
            - CU
            - KG
            - M
            - QM
          example: CU
          nullable: true
          type: string
        weight:
          description: >-
            Total weight of the product.


            This is only used for weight-based products. Set the `unit` field to
            "KG" when overwriting the weight.
          example: 125.2
          exclusiveMinimum: true
          format: float
          minimum: 0
          nullable: true
          type: number
      required:
        - product_id
      type: object
    Amounts:
      additionalProperties: false
      description: Information about the different total amounts.
      properties:
        rounding:
          description: Rounding difference.
          example: 0.1
          format: float
          nullable: true
          type: number
        to_pay:
          description: Total price to pay.
          example: 15.35
          exclusiveMinimum: true
          format: float
          minimum: 0
          nullable: true
          type: number
      required:
        - to_pay
        - saved
      type: object
    CalculatedItem:
      additionalProperties: false
      description: Information about calculated prices for a single item.
      properties:
        amounts:
          description: Information about the different amounts for a single item.
          nullable: true
          oneOf:
            - $ref: "#/components/schemas/ItemAmounts"
        applied_promotions:
          description: List of applied promotions for a single item.
          items:
            $ref: "#/components/schemas/AppliedPromotion"
          type: array
        base_price_per_unit:
          description: Unit price before any promotions are applied.
          example: 12.5
          exclusiveMinimum: true
          format: float
          minimum: 0
          nullable: true
          type: number
        product_id:
          description: ID of the product.
          type: string
      required:
        - amounts
        - base_price_per_unit
      type: object
    Vat:
      additionalProperties: false
      description: Information about the VAT.
      properties:
        code:
          description: |-
            VAT code.

            - 0: No taxes
            - 1: Reduced taxes
            - 2: Full taxes
            - 9: Proportionally split
          enum:
            - 0
            - 1
            - 2
            - 9
          type: integer
        rate:
          description: VAT rate.
          example: 7.7
          exclusiveMinimum: true
          format: float
          minimum: 0
          type: number
        taxable_amount:
          description: Taxable amount for this VAT.
          example: 11.9
          exclusiveMinimum: true
          format: float
          minimum: 0
          type: number
        vat_amount:
          description: Amount of the VAT.
          example: 1.1
          exclusiveMinimum: true
          format: float
          minimum: 0
          type: number
      required:
        - code
        - rate
        - taxable_amount
        - vat_amount
      type: object
    problem:
      description: Problem Details for HTTP APIs defined by RFC 7807
      properties:
        detail:
          example: More details
          type: string
        status:
          example: 400
          type: integer
        title:
          example: Test error
          type: string
        validation-errors:
          items:
            properties:
              constraint:
                example: minLength
                type: string
              message:
                example: Example error
                type: string
              pointer:
                example: /prop1/0
                type: string
              property:
                example: prop1[0]
                type: string
            required:
              - property
              - pointer
              - message
              - constraint
            type: object
          minItems: 1
          type: array
      required:
        - status
        - title
      title: Problem Details
      type: object
    ItemAmounts:
      additionalProperties: false
      description: Information about the different amounts for a single item.
      properties:
        saved:
          description: Saved amount for the item.
          example: 1.1
          exclusiveMinimum: true
          format: float
          minimum: 0
          type: number
        total:
          description: Total price of the item.
          example: 11.2
          exclusiveMinimum: true
          format: float
          minimum: 0
          type: number
      required:
        - total
        - saved
      type: object
    AppliedPromotion:
      additionalProperties: false
      description: Information about an applied promotion to a single item.
      properties:
        coupon:
          description: Coupon identifier for the promotion.
          example: "7610300001381"
          maxLength: 40
          nullable: true
          type: string
        cumulus_points:
          description: Amount of awarded Cumulus Points for a single item.
          example: 2
          exclusiveMinimum: true
          format: float
          minimum: 0
          nullable: true
          type: number
        price_reduction_per_unit:
          description: Amount of the price reduction per unit for a single item.
          example: 1.1
          exclusiveMinimum: true
          format: float
          minimum: 0
          nullable: true
          type: number
      type: object
  responses:
    "400":
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/problem"
      description: Invalid data given
  securitySchemes:
    Kong-Api-Key:
      description: Kong key-auth authentication
      in: header
      name: X-Api-Key
      type: apiKey
```
