Price
2 API calls in this section.
Delivery price calculation and package-aware order price preview.
Get Delivery Price (Legacy Units)
/delivery/priceBackward-compatible delivery price calculation. The caller supplies a positive units query value. The response now also returns unit_size and unit_size_source=unit_size. New create forms should use POST /delivery/price so the backend can choose between package measurements, submitted unit size, and the configured missing-unit fallback.
Errors
HTTP 400 validation failures return {success:false,error} for missing required query parameters or tenant context, non-positive/non-numeric units, or invalid coordinates. Pricing-domain failures return HTTP 400 with {success:false,code,message,...details}; message is localized and additional detail fields depend on code. Unexpected failures return HTTP 500 with {success:false,message}. Display the localized error or message and branch on HTTP status and code when present.
Query parameters
| Parameter | Type | Description |
|---|---|---|
delivery_service_id | string | Example: |
pickup_lat | string | Example: |
pickup_lng | string | Example: |
dropoff_lat | string | Example: |
dropoff_lng | string | Example: |
units | string | Example: |
language | string | Example: |
Headers
| Parameter | Type | Description |
|---|---|---|
Authorization | string | Example: |
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/delivery/price?delivery_service_id=uuid&pickup_lat=23.780&pickup_lng=90.410&dropoff_lat=23.810&dropoff_lng=90.430&units=1&language=en" \2 --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}"Response examples
1{2 "success": true,3 "price": 5000,4 "unit_size": 1,5 "unit_size_source": "unit_size",6 "message": "Price calculated successfully"7}Preview Delivery Price From Order Data
/delivery/priceReturns the exact backend-selected unit and delivery price before order creation. Authentication and tenant context are required.
Send pickup and delivery coordinates in
pickup_locationanddelivery_location; aliasespickup_address/delivery_addressand flat coordinate fields are also accepted. Location objects acceptlatitude/longitudeorlat/lng/long.packageis the customer-compatible package shape and may contain direct single-package measurements oritems[].package_detailsremains accepted for backward compatibility. When both package fields are sent,package_detailstakes precedence.
Unit selection priority
If every item provides positive
weight,length,width, andheight, the backend calculates unit size from total weight and largest dimensions using tenant unit settings. This calculated unit overrides submittedunit_size;quantitydefaults to 1 and must be a positive integer.If any item has a zero, missing, or empty measurement, the package is treated as unmeasurable and the submitted
unit_sizeis used.If neither usable package measurements nor a submitted unit is available, apply
general.unit_size.settings.missing_unit_size_fallback:service_min,service_half,service_max, or HTTP 400unit_size_or_dimensions_required.
Success returns price, unit_size, and unit_size_source (package_details, unit_size, service_min, service_half, or service_max). Negative or non-numeric package measurements return HTTP 400 with field=package for the customer-compatible shape or field=package_details for the legacy shape. HTTP 400 with code=can_not_use_this_delivery_for_this_unit_size returns a localized cause plus calculated_unit_size, allowed_unit_min, allowed_unit_max, and violation when the selected service cannot carry the selected units.
Frontend integration contract
use the same package shape as /customer/delivery/price, add the current unit_size, and send the current locations and service whenever pricing-relevant form data changes. Zero, missing, or empty measurements may remain in package items; the response will use unit_size_source=unit_size. Display the returned unit_size and price; submit the same package data to POST /delivery/deliveries using its existing package_details field. On the unit-range code, display message and use the numeric fields to highlight the service/package mismatch.
Query parameters
| Parameter | Type | Description |
|---|---|---|
language | string | Example: |
Headers
| Parameter | Type | Description |
|---|---|---|
Authorization | string | Example: |
Content-Type | string | Example: |
Body parameters
| Parameter | Type | Description |
|---|---|---|
delivery_service_idRequired | string | is required. |
pickup_location | object | — |
pickup_location.latitude | number | — |
pickup_location.longitude | number | — |
delivery_location | object | — |
delivery_location.latitude | number | — |
delivery_location.longitude | number | — |
unit_sizeOptional | number | is optional. |
package | object | — |
package.items | array<object> | — |
package.items.name | string | — |
package.items.quantity | number | — |
Show 4 more body fields
Additional body parameters
| Parameter | Type | Description |
|---|---|---|
package.items.weight | number | — |
package.items.length | number | — |
package.items.width | number | — |
package.items.height | number | — |
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/delivery/price?language=en" \2 --header "Authorization: Bearer ${ONDI_ACCESS_TOKEN}" \3 --header "Content-Type: application/json" \4 --data-raw '{5 "delivery_service_id": "uuid",6 "pickup_location": {7 "latitude": 36.1911,8 "longitude": 44.00929 },10 "delivery_location": {11 "latitude": 36.205,12 "longitude": 44.0313 },14 "unit_size": 1,15 "package": {16 "items": [17 {18 "name": "Large box",19 "quantity": 1,20 "weight": 1,21 "length": 100,22 "width": 100,23 "height": 10024 }25 ]26 }27}'Response examples
1{2 "success": true,3 "price": 20000,4 "unit_size": 4,5 "unit_size_source": "package_details",6 "message": "Price calculated successfully"7}