Skip to main content

Price

2 API calls in this section.

Delivery price calculation and package-aware order price preview.

Get Delivery Price (Legacy Units)​

Delivery & Last-Mile / Price
GET/delivery/price

Backward-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

ParameterTypeDescription
delivery_service_idstring

Example: uuid

pickup_latstring

Example: 23.780

pickup_lngstring

Example: 90.410

dropoff_latstring

Example: 23.810

dropoff_lngstring

Example: 90.430

unitsstring

Example: 1

languagestring

Example: en

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Staging
Request
curl
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

200OK
Response body
json
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 & Last-Mile / Price
POST/delivery/price

Returns the exact backend-selected unit and delivery price before order creation. Authentication and tenant context are required.

  • Send pickup and delivery coordinates in pickup_location and delivery_location; aliases pickup_address/delivery_address and flat coordinate fields are also accepted. Location objects accept latitude/longitude or lat/lng/long.

  • package is the customer-compatible package shape and may contain direct single-package measurements or items[].

  • package_details remains accepted for backward compatibility. When both package fields are sent, package_details takes precedence.

Unit selection priority

  1. If every item provides positive weight, length, width, and height, the backend calculates unit size from total weight and largest dimensions using tenant unit settings. This calculated unit overrides submitted unit_size; quantity defaults to 1 and must be a positive integer.

  2. If any item has a zero, missing, or empty measurement, the package is treated as unmeasurable and the submitted unit_size is used.

  3. 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 400 unit_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

ParameterTypeDescription
languagestring

Example: en

Headers

ParameterTypeDescription
Authorizationstring

Example: Bearer {{access_token}}

Content-Typestring

Example: application/json

Body parameters

ParameterTypeDescription
delivery_service_idRequiredstring

is required.

pickup_locationobject—
pickup_location.latitudenumber—
pickup_location.longitudenumber—
delivery_locationobject—
delivery_location.latitudenumber—
delivery_location.longitudenumber—
unit_sizeOptionalnumber

is optional. units is accepted as a legacy alias.

packageobject—
package.itemsarray<object>—
package.items.namestring—
package.items.quantitynumber—
Show 4 more body fields

Additional body parameters

ParameterTypeDescription
package.items.weightnumber—
package.items.lengthnumber—
package.items.widthnumber—
package.items.heightnumber—
Staging
Request
curl
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

200OK
Response body
json
1{2  "success": true,3  "price": 20000,4  "unit_size": 4,5  "unit_size_source": "package_details",6  "message": "Price calculated successfully"7}