Skip to main content

Zone Pricing

5 API calls in this section.

List Zone Pricing​

Delivery & Last-Mile / Zone Pricing
GET/delivery/zone-pricing

List pricing rules with SQL-side filtering, sorting, exact pagination, and optional tenant KPI stats. Multi-select semantics are (origin zones OR origin tags) AND (destination zones OR destination tags) AND (services). Each row returns origin.preview, destination.preview, and services.preview with at most three active entities plus exact counts. Filter matches are prioritized in each preview and marked matched=true. services is the only service response field.

Query parameters

ParameterTypeDescription
pagestring

Page number for pagination

Example: 1

limitstring

Number of items per page

Example: 10

origin_zone_idstring

Legacy single origin-zone filter. Prefer origin_zone_ids.

origin_zone_idsstring

Comma-separated or repeated origin zone IDs. OR within origin filters.

destination_zone_idstring

Legacy single destination-zone filter. Prefer destination_zone_ids.

destination_zone_idsstring

Comma-separated or repeated destination zone IDs. OR within destination filters.

origin_tag_idstring

Legacy single origin-tag filter. Prefer origin_tag_ids.

origin_tag_idsstring

Comma-separated or repeated origin tag IDs. Combined with origin_zone_ids using OR.

destination_tag_idstring

Legacy single destination-tag filter. Prefer destination_tag_ids.

destination_tag_idsstring

Comma-separated or repeated destination tag IDs. Combined with destination_zone_ids using OR.

origin_selector_typestring

Filter by origin selector type (zone|tag)

destination_selector_typestring

Filter by destination selector type (zone|tag)

service_idstring

Legacy single service filter. Prefer service_ids.

service_idsstring

Comma-separated or repeated service IDs. A rule matches any selected service.

activestring

Filter by active status (true/false)

Example: true

include_statsstring

Set false when KPI stats are not rendered. Rows and stats otherwise come from one database call.

Example: true

column_filtersstring

JSON object for grid column filters. Multi-select arrays: origin_zone_ids, origin_tag_ids, destination_zone_ids, destination_tag_ids, service_ids. Also supports status, selector types, service_code, numeric ranges, and effective date ranges. Multi-select values are merged with equivalent top-level query parameters.

Example: {"origin_zone_ids":["uuid-origin-1","uuid-origin-2"],"service_ids":["uuid-service-1"],"status":"true"}

sort_bystring

Sort field. Allowed: base_price, per_unit_price, carrier_price, min_transit_time, max_transit_time, effective_from, effective_to, service.name, created_at

Example: created_at

sort_orderstring

Sort direction (asc|desc). Defaults to desc.

Example: desc

tenant_idstring

Tenant ID (defaults to authenticated user's tenant)

languagestring

Preferred language for response messages

Example: en

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Staging
Request
curl
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/delivery/zone-pricing?page=1&limit=10&active=true&include_stats=true&column_filters=%7B%22origin_zone_ids%22%3A%5B%22uuid-origin-1%22%2C%22uuid-origin-2%22%5D%2C%22service_ids%22%3A%5B%22uuid-service-1%22%5D%2C%22status%22%3A%22true%22%7D&sort_by=created_at&sort_order=desc&tenant_id=&language=en" \2  --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}"

Response examples

200OK
Response body
json
1{2  "success": true,3  "message": "Zone pricing retrieved successfully",4  "zonePricing": [5    {6      "id": "pricing-rule-uuid",7      "active": true,8      "base_price": 1000,9      "per_unit_price": 90,10      "origin_selector_type": "zone",11      "destination_selector_type": "tag",12      "origin": {13        "type": "zone",14        "count": 7,15        "preview": [16          {17            "id": "origin-filtered",18            "name": "West Zone",19            "code": "WEST",20            "matched": true21          },22          {23            "id": "origin-2",24            "name": "Central",25            "code": "CTR",26            "matched": false27          },28          {29            "id": "origin-3",30            "name": "North",31            "code": "NTH",32            "matched": false33          }34        ]35      },36      "destination": {37        "type": "tag",38        "count": 4,39        "preview": [40          {41            "id": "tag-priority",42            "name": "priority",43            "code": null,44            "matched": true45          }46        ]47      },48      "services": {49        "count": 5,50        "preview": [51          {52            "id": "service-express",53            "code": "EXP",54            "name": "Express",55            "matched": true56          },57          {58            "id": "service-parcel",59            "code": "PAR",60            "name": "Parcel",61            "matched": false62          },63          {64            "id": "service-same-day",65            "code": "SD",66            "name": "Same Day",67            "matched": false68          }69        ]70      }71    }72  ],73  "stats": {74    "totalRules": 42,75    "activeRules": 30,76    "inactiveRules": 12,77    "recentlyAdded": []78  },79  "page": 1,80  "limit": 10,81  "total": 4282}

Get Zone Pricing​

Delivery & Last-Mile / Zone Pricing
GET/delivery/zone-pricing/:pricingId

Get details for a pricing rule. Response includes services[{id,name,code,unit_min,unit_max}] for edit-form initialization plus full selector arrays. services is the only service response field.

Path parameters

ParameterTypeDescription
pricingIdRequiredstring

ID of the pricing rule to retrieve

Example: uuid

Query parameters

ParameterTypeDescription
tenant_idOptionalstring

Tenant ID (optional if in auth token)

languagestring

Preferred language for response messages

Example: en

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Staging
Request
curl
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/delivery/zone-pricing/${PRICINGID}?tenant_id=&language=en" \2  --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}"

Response examples

200OK
Response body
json
1{2  "success": true,3  "message": "Zone pricing retrieved successfully",4  "pricing": {5    "id": "uuid",6    "active": true,7    "base_price": 10.5,8    "per_unit_price": 0.75,9    "min_transit_time": 30,10    "max_transit_time": 60,11    "pricing_rules": {},12    "effective_from": "2023-01-01",13    "effective_to": null,14    "origin_selector_type": "zone",15    "destination_selector_type": "tag",16    "services": [17      {18        "id": "uuid-standard",19        "name": "Standard Delivery",20        "code": "STD",21        "unit_min": 1,22        "unit_max": 1023      },24      {25        "id": "uuid-express",26        "name": "Express Delivery",27        "code": "EXP",28        "unit_min": 1,29        "unit_max": 530      }31    ],32    "origins": [33      {34        "id": "uuid-origin-1",35        "name": "Downtown",36        "code": "DT-01"37      }38    ],39    "destinations": [],40    "origin_tags": [],41    "destination_tags": [42      {43        "id": "uuid-tag-1",44        "name": "erbil"45      }46    ]47  }48}

Create Zone Pricing​

Delivery & Last-Mile / Zone Pricing
POST/delivery/zone-pricing

Create one pricing rule for one or more delivery services. service_ids is required and must contain at least one tenant service. A legacy service_id string is accepted as a one-item array. All services share the same selectors, prices, effective window, carrier price, transit times, and pricing_rules. The write is atomic; an overlap for any selected service rejects the entire request with HTTP 409. Unit tiers must cover every selected service's unit range. Frontend: submit all chips as service_ids and display the localized message for 400/404/409 responses.

Query parameters

ParameterTypeDescription
tenant_idstring

Tenant ID (defaults to authenticated user's tenant)

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Content-Typestring

Example: application/json

Body parameters

ParameterTypeDescription
origin_selector_typestring—
destination_selector_typestring—
origin_zone_idsarray<string>—
destination_tag_idsarray<string>—
service_idsarray<string>—
base_pricenumber—
per_unit_pricenumber—
min_transit_timenumber—
max_transit_timenumber—
pricing_rulesobject—
effective_fromstring—
effective_tonull—
Staging
Request
curl
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/delivery/zone-pricing?tenant_id=&language=en" \2  --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3  --header "Content-Type: application/json" \4  --data-raw '{5  "origin_selector_type": "zone",6  "destination_selector_type": "tag",7  "origin_zone_ids": [8    "uuid-origin-1"9  ],10  "destination_tag_ids": [11    "uuid-tag-erbil"12  ],13  "service_ids": [14    "uuid-service-standard",15    "uuid-service-express"16  ],17  "base_price": 10.5,18  "per_unit_price": 0.75,19  "min_transit_time": 30,20  "max_transit_time": 60,21  "pricing_rules": {},22  "effective_from": "2025-01-01",23  "effective_to": null24}'

Response examples

201Created
Response body
text
1{\n  "success": true,\n  "message": "Pricing rule created successfully",\n  "pricing_id": "pricing-rule-uuid"\n}

Update Zone Pricing​

Delivery & Last-Mile / Zone Pricing
PUT/delivery/zone-pricing/:pricingId

Update a pricing rule and its covered services atomically. When service_ids is provided, it becomes the complete active service set: added IDs are activated and omitted IDs are soft-deactivated. Omit both service_ids and service_id to preserve the current set. An explicit empty service_ids array is rejected. The legacy service_id field is accepted as a one-service replacement. Exact zone rules remain prioritized during runtime resolution. Frontend: initialize chips from pricing.services, submit the complete service_ids array, and use code plus localized message for errors.

Path parameters

ParameterTypeDescription
pricingIdRequiredstring

ID of the pricing rule to update

Example: uuid

Query parameters

ParameterTypeDescription
tenant_idOptionalstring

Tenant ID (optional if in auth token)

languagestring

Preferred language for response messages

Example: en

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Content-Typestring

Example: application/json

Body parameters

ParameterTypeDescription
origin_selector_typestring—
destination_selector_typestring—
origin_tag_idsarray<string>—
destination_zone_idsarray<string>—
service_idsarray<string>—
base_pricenumber—
per_unit_pricenumber—
min_transit_timenumber—
max_transit_timenumber—
pricing_rulesobject—
effective_fromstring—
effective_tonull—
Staging
Request
curl
1curl --globoff --request PUT "https://staging-api.ondi.io/functions/v1/delivery/zone-pricing/${PRICINGID}?tenant_id=&language=en" \2  --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3  --header "Content-Type: application/json" \4  --data-raw '{5  "origin_selector_type": "tag",6  "destination_selector_type": "zone",7  "origin_tag_ids": [8    "uuid-tag-erbil"9  ],10  "destination_zone_ids": [11    "uuid-dest-1",12    "uuid-dest-2"13  ],14  "service_ids": [15    "uuid-service-standard",16    "uuid-service-express"17  ],18  "base_price": 12.5,19  "per_unit_price": 0.85,20  "min_transit_time": 24,21  "max_transit_time": 72,22  "pricing_rules": {},23  "effective_from": "2025-01-01",24  "effective_to": null25}'

Response examples

200OK
Response body
text
1{\n  "success": true,\n  "message": "Pricing rule updated successfully"\n}

Delete Zone Pricing​

Delivery & Last-Mile / Zone Pricing
DELETE/delivery/zone-pricing/:pricingId

Soft-delete a pricing rule by setting active=false. Pricing and relationship history are preserved, and the rule no longer participates in order pricing.

Path parameters

ParameterTypeDescription
pricingIdRequiredstring

ID of the pricing rule to delete

Example: uuid

Query parameters

ParameterTypeDescription
tenant_idOptionalstring

Tenant ID (optional if in auth token)

languagestring

Preferred language for response messages

Example: en

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Staging
Request
curl
1curl --globoff --request DELETE "https://staging-api.ondi.io/functions/v1/delivery/zone-pricing/${PRICINGID}?tenant_id=&language=en" \2  --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}"

Response examples

No saved response example. Use Try it to inspect a staging response.