Price Matrix Module

SKYBIZ API — Price Matrix Module

Price Matrix

The Price Matrix module allows you to retrieve pricing matrix records from your SKYBIZ account. This module is read only — no create action is available.

Endpoint: /apiv2/modules/price_matrix.php

Required Permission: Price Matrix — Read


Read Price Matrix

Retrieves price matrix records modified within the given date range, ordered by ItemCode and RunNo. Only active records (Status = '1') are returned.

Base Request Structure

{
  "api_key": "your-api-key",
  "api_secret": "your-api-secret",
  "action": "read",
  "date_from": "YYYY-MM-DD",
  "date_to": "YYYY-MM-DD",
  "item_code": "",
  "cus_code": ""
}

Request Parameters

Parameter Description Required
api_key Your API key Yes
api_secret Your API Secret Yes
action Must be "read" Yes
date_from Start date (YYYY-MM-DD) Yes
date_to End date (YYYY-MM-DD). Max 31 days range. Yes
item_code Filter by specific item code No
cus_code Filter by specific customer code No

Date Rules

  • Format must be YYYY-MM-DD — e.g. "2026-04-01"
  • Maximum range is 31 days
  • date_from cannot be after date_to

Available Fields (Read Only)

The Price Matrix module returns all fields. Field filtering is not supported for this module.

Field Type Description
RunNo integer Unique record identifier
ItemCode string Item code
ItemGroup string Item group / category
CategoryCode string Category code
Description string Price matrix description
Pct float Percentage value
Criteria string Pricing criteria
Comparison string Comparison operator
Qty float Quantity threshold
PeriodYN string Period flag — "Y" or "N"
DateStart string Start date of price matrix validity
DateEnd string End date of price matrix validity
QuotaYN string Quota flag — "Y" or "N"
QuotaQty float Quota quantity
B_ase string Base price reference
CusCode string Customer code (if customer-specific)
BranchCode string Branch code
UnitPriceFormula string Formula for unit price calculation
CusAna1 to CusAna3 string Customer analysis codes
ItemAna3 string Item analysis code 3
LowerLimitQty float Lower quantity limit
UpperLimitQty float Upper quantity limit
Y1 to Y5 float Formula variables Y1 to Y5
Status string Status — "1" = Active, "0" = Inactive
TimeStart string Start time (HH:MM:SS)
TimeEnd string End time (HH:MM:SS)
L_ink string Link reference
DateTimeModify string Last modified datetime — used as the date filter
UserCode string User who last modified the record
MatrixType string Type of price matrix
UOMType string Unit of measure type
SpecialPriceYN string Special price flag — "Y" or "N"
PriceCode string Price code
ServiceChargeYN string Service charge flag — "Y" or "N"
Memo string Memo / notes
UOM string Unit of measure
SalesPersonCode string Salesperson code

Example 1 — Get All Price Matrix Records (All Fields)

This request returns all price matrix records modified between April 1, 2026 and April 30, 2026.

Request

{
  "api_key": "your-api-key",
  "api_secret": "your-api-secret",
  "action": "read",
  "date_from": "2026-04-01",
  "date_to": "2026-04-30",
  "item_code": "",
  "cus_code": ""
}

Sample Code for making an API READ request using php

<?php
header('Content-Type: application/json');

// ============================================================
// STEP 1: CONFIGURATION
// ============================================================

$API_KEY = "your-api-key";
$API_SECRET = "your-api-secret";
$ACTION = "read";

// Date range (required for all endpoints, max 31 days)
$DATE_FROM = "2026-04-01";
$DATE_TO = "2026-04-30";

// ============================================================
// STEP 2: ENDPOINT
// ============================================================

$BASE_URL = "https://domain-name/01/clientportal/apiv2/modules"; //(replace it with your skybiz domain name url)
$ENDPOINT = "price_matrix.php";

// ============================================================
// STEP 3: REQUEST PARAMETERS
// ============================================================

$requestParams = [
    "date_from" => $DATE_FROM,
    "date_to" => $DATE_TO,
    "item_code" => "", // Optional: filter by item code
    "cus_code" => ""   // Optional: filter by customer code
];

// ============================================================
// STEP 4: BUILD PAYLOAD
// ============================================================

$payload = array_merge(
    [
        "api_key" => $API_KEY,
        "api_secret" => $API_SECRET,
        "action" => $ACTION
    ],
    $requestParams
);

// ============================================================
// STEP 5: SEND REQUEST
// ============================================================

$url = rtrim($BASE_URL, '/') . '/' . ltrim($ENDPOINT, '/');

$ch = curl_init($url);

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => http_build_query($payload),
    CURLOPT_TIMEOUT => 30,
]);

$response = curl_exec($ch);

// ============================================================
// STEP 6: HANDLE CURL ERROR
// ============================================================

if ($response === false) {
    echo json_encode([
        "status" => "error",
        "timestamp" => date("c"),
        "request_id" => uniqid("req_"),
        "message" => curl_error($ch)
    ], JSON_PRETTY_PRINT);
    curl_close($ch);
    exit;
}

$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// ============================================================
// STEP 7: DECODE RESPONSE
// ============================================================

$result = json_decode($response, true);

if (!$result) {
    echo json_encode([
        "status" => "error",
        "timestamp" => date("c"),
        "request_id" => uniqid("req_"),
        "message" => "Invalid JSON from API",
        "raw_response" => $response
    ], JSON_PRETTY_PRINT);
    exit;
}

// ============================================================
// STEP 8: RETURN CLEAN JSON FORMAT
// ============================================================

echo json_encode([
    "status" => $result['status'] ?? "error",
    "timestamp" => date("c"),
    "request_id" => $result['request_id'] ?? uniqid("req_"),
    "data" => $result['data'] ?? null,
    "message" => $result['message'] ?? null
], JSON_PRETTY_PRINT);

Response (Success)

{
  "status": "response",
  "timestamp": "2026-04-30T04:07:04+00:00",
  "request_id": "req_69f2d56891e57",
  "data": {
    "requested_by": "your-api-key",
    "mode": "2",
    "date_range": {
      "from": "2026-04-01",
      "to": "2026-04-30",
      "days": 30
    },
    "total_returned": 2,
    "data": [
      {
        "RunNo": 1001,
        "ItemCode": "ITEM001",
        "Description": "Volume Discount - ITEM001",
        "CusCode": "",
        "Qty": 10,
        "Y1": 95.00,
        "Status": "1",
        "DateTimeModify": "2026-04-15 10:30:00"
      },
      {
        "RunNo": 1002,
        "ItemCode": "ITEM002",
        "Description": "Customer Special - CUST001",
        "CusCode": "CUST001",
        "Qty": 5,
        "Y1": 90.00,
        "Status": "1",
        "DateTimeModify": "2026-04-20 14:45:00"
      }
    ]
  }
}

Example 2 — Filter by Item Code

This request returns only price matrix records for item code ITEM001.

Request

{
  "api_key": "your-api-key",
  "api_secret": "your-api-secret",
  "action": "read",
  "date_from": "2026-04-01",
  "date_to": "2026-04-30",
  "item_code": "ITEM001",
  "cus_code": ""
}

Sample Code Configuration

$requestParams = [
    "date_from" => "2026-04-01",
    "date_to" => "2026-04-30",
    "item_code" => "ITEM001",
    "cus_code" => ""
];

Example 3 — Filter by Customer Code

This request returns only price matrix records for customer code CUST001.

Request

{
  "api_key": "your-api-key",
  "api_secret": "your-api-secret",
  "action": "read",
  "date_from": "2026-04-01",
  "date_to": "2026-04-30",
  "item_code": "",
  "cus_code": "CUST001"
}

Sample Code Configuration

$requestParams = [
    "date_from" => "2026-04-01",
    "date_to" => "2026-04-30",
    "item_code" => "",
    "cus_code" => "CUST001"
];

Example 4 — Filter by Both Item Code and Customer Code

This request returns only price matrix records for item code ITEM001 AND customer code CUST001.

Request

{
  "api_key": "your-api-key",
  "api_secret": "your-api-secret",
  "action": "read",
  "date_from": "2026-04-01",
  "date_to": "2026-04-30",
  "item_code": "ITEM001",
  "cus_code": "CUST001"
}

Sample Code Configuration

$requestParams = [
    "date_from" => "2026-04-01",
    "date_to" => "2026-04-30",
    "item_code" => "ITEM001",
    "cus_code" => "CUST001"
];

Postman Steps — READ Request

  1. Set method to POST

2. Enter URL: https://your-domain/01/clientportal/apiv2/modules/price_matrix.php

3. Set header: Content-Type: application/json

4. Under Body, select raw and format JSON

5. Paste your request payload and click Send


Error Responses

Missing Date Range

{
  "status": "error",
  "timestamp": "2026-04-07T10:46:15+08:00",
  "request_id": "req_6612f3b9c21a7",
  "message": "date_from and date_to are required"
}

Invalid Date Format

{
  "status": "error",
  "timestamp": "2026-04-07T10:46:15+08:00",
  "request_id": "req_6612f3b9c21a7",
  "message": "Invalid date format. Use YYYY-MM-DD format."
}

Date Range Exceeds 31 Days

{
  "status": "error",
  "timestamp": "2026-04-07T10:46:15+08:00",
  "request_id": "req_6612f3b9c21a7",
  "message": "Date range cannot exceed 31 days."
}

No Read Permission

{
  "status": "error",
  "timestamp": "2026-04-07T10:46:15+08:00",
  "request_id": "req_6612f3b9c21a7",
  "message": "Price Matrix read permission denied"
}

Common Errors — Price Matrix Module

Error Message Cause Fix
"date_from and date_to are required" Missing date range Add both fields to your request
"Invalid date format. Use YYYY-MM-DD format." Wrong date format Use YYYY-MM-DD — e.g. "2026-04-01"
"Date range cannot exceed 31 days." Date range too wide Narrow range to 31 days or fewer
"Price Matrix read permission denied" No read permission for Price Matrix module Enable read permission in portal by contacting your SkyBiz Admin
"Invalid API credentials" Wrong or expired API key/secret Check your credentials or generate new ones