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

# Matrix pricing

## Concepts

**Matrix pricing** is a strategy that uses two different factors to determine a price. While simpler models only look at "how much" a customer uses, a matrix allows you to change the price based on a second detail, such as the customer's geographic location or their subscription tier.

### The logic of dimensions

Matrix pricing is a **2-Dimensional** model. It relies on two independent factors: **Quantity** (Dimension 1) and a **categorical attribute** (Dimension 2).

Think of this like a **pricing grid**. To find the correct rate, you follow a column (for the quantity) and a row (for the attribute) until they meet. The point where they intersect is the specific price applied to that customer's usage.

### SaaS example: Cloud log storage

A monitoring platform charges for log storage, but the cost of data centers varies by world region. The platform uses a matrix to apply different volume discounts based on where the data is stored.

**The pricing grid:**

| Region (Dimension 2) \| Usage (Dimension 1) | **0 – 500 GB** | **501 – 2,000 GB** | **2,001+ GB** |
| ------------------------------------------- | -------------- | ------------------ | ------------- |
| **US-East**                                 | \$0.10 / GB    | \$0.08 / GB        | \$0.05 / GB   |
| **EU-West**                                 | \$0.12 / GB    | \$0.10 / GB        | \$0.07 / GB   |
| **Asia-Pacific**                            | \$0.15 / GB    | \$0.12 / GB        | \$0.10 / GB   |

**The intersection calculation:**
If a customer in **EU-West** ingests **1,500 GB**, Zenskar navigates the matrix to find the exact rate:

1. **Identify the row:** The customer is in the "EU-West" category.
2. **Identify the column:** The "1,500 GB" usage falls into the 501–2,000 GB bracket.
3. **Find the intersection:** The rate at this meeting point is **\$0.10 / GB**.

***

## Get started: Configure your matrix product

*This tutorial walks you through building a global matrix template in your Product Library.*

1. **Navigate to the Library:** Go to **Contracts** > **Products**. This is your central hub for defining reusable pricing blueprints.
2. **Create a Standalone Product:** Click **+ CREATE NEW** and choose Standalone Product from the dropdown. The Create Standalone Product page will appear. Fill in the required details and click **Save & Proceed** at the bottom right.
3. **Open Price Details:** You will be redirected to the Price Details page. Click **+ Add Price** to configure pricing for the product.
4. **Select Matrix Pricing Model:** In the Pricing Model dropdown, select **Matrix Pricing**.
5. **Configure Dimension and Save:** Click **+ Add Dimension** to add the required dimensions. Enter the **Dimension name**, **Display Alias**, and the unit prices for each combination. Once complete, click **Save**, then click **Done** on the Price Details page.

## How-to: Add matrix product to a contract

### 1. Via Contracts

1. Open the target contract in **Contracts** > **Contracts**.
2. In the Summary tab, click **+ ADD PRODUCT V3**.
3. Search for and select your configured matrix product.
4. Click **ADD PRODUCT**. You will be redirected to the Summary page. Click **Publish**.

### 2. Via Customer

1. Open the target customer in **Customers**.
2. Go to Contracts and click **+ CREATE CONTRACT**.
3. In the Summary tab, click **+ ADD PRODUCT V3**.
4. Search for and select your configured matrix product.
5. Click **ADD PRODUCT**. You will be redirected to the Summary page. Click **Publish**.

***

## Reference

### Technical specifications

| Attribute              | Specification                                                                                                                                          |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Dimensionality**     | **2-dimensional (bivariate)**                                                                                                                          |
| **Math formula**       | ***P = rᵢⱼ × q*** (where ***rᵢⱼ*** is the rate resolved from the intersection of row ***i*** and column ***j***)                                       |
| **Logic type**         | **XY lookup function**: The price is determined by intersecting a usage quantity with a specific categorical or secondary numerical attribute.         |
| **Boundary behavior**  | **Lower-inclusive**: For numerical axes, a value exactly at a threshold belongs to the tier starting at that value.                                    |
| **Calculation engine** | **Coordinate resolution**: The engine identifies the specific "cell" in the matrix based on two distinct metadata inputs and applies that cell's rate. |
| **Data object**        | `pricing_model_type: matrix_pricing`                                                                                                                   |

### System architecture

In Zenskar, all pricing models are governed by a hierarchical relationship between entities:

* **Contract:** The legal agreement between you and your customer.
* **Phase:** A specific time-bound period (e.g., Q1, implementation phase) within that contract.
* **Product:** The actual service or software module being sold.
* **Pricing model:** The specific logic (matrix pricing) that defines how that product is billed.

**Entity hierarchy:**

```mermaid theme={null}
flowchart LR
    CONTRACT[Contract] ---|"has one or more"| PHASE[Phase]
    PHASE ---|"has one or more"| PRODUCT[Product]
    PRODUCT ---|"has exactly one active"| PRICINGMODEL[Pricing model]

style PRICINGMODEL fill:#90ee90

```

### Price resolution flow

This grid represents the abstract coordinate system used by the billing engine to resolve a rate:

| Quantity (q) \| Attribute (attr) | j₁  | j₂  | j₃  |
| -------------------------------- | --- | --- | --- |
| **interval₁ (i₁)**               | r₁₁ | r₁₂ | r₁₃ |
| **interval₂ (i₂)**               | r₂₁ | r₂₂ | r₂₃ |
| **interval₃ (i₃)**               | r₃₁ | r₃₂ | r₃₃ |

The following flow describes how matrix pricing calculates the final price:

1. **Product library:** Defines the dimensions of the matrix (e.g., rows for volume, columns for region) and the rates (***r***) for every intersection.
2. **Contract:** Links the product to a customer and defines the data sources for both axes (***q*** and ***attr***).
3. **Data source:** Provides real-time values for both dimensions (e.g., a meter for quantity and a metadata tag for region).
4. **Billing engine:** Performs a coordinate lookup to find the specific rate ***rᵢⱼ*** and multiplies it by ***q*** to resolve the total price ***P***.

***

<br />
