Skip to main content

External & Carrier Integrations

2 API calls in this section.

Calculate Delivery Price

External & Carrier Integrations / External & Carrier Integrations
GET/external/delivery/price?delivery_service_id={{delivery_service_id}}&pickup_lat={{pickup_lat}}&pickup_lng={{pickup_lng}}&dropoff_lat={{dropoff_lat}}&dropoff_lng={{dropoff_lng}}&tenant_id={{tenant_id}}

Calculate delivery price based on pickup and dropoff coordinates. This endpoint is designed for external integrations and accepts latitude/longitude coordinates directly instead of address IDs. Authentication: - Requires valid authentication token or API key - Public endpoint accessible to external systems Query Parameters: - delivery_service_id (required): UUID of the delivery service - pickup_lat (conditional): Latitude of pickup location (decimal format, e.g., 40.7128) - Required if warehouse_id not provided - pickup_lng (conditional): Longitude of pickup location (decimal format, e.g., -74.0060) - Required if warehouse_id not provided - dropoff_lat (required): Latitude of dropoff location (decimal format, e.g., 40.7589) - dropoff_lng (required): Longitude of dropoff location (decimal format, e.g., -73.9851) - tenant_id (required): UUID of the tenant - warehouse_id (optional): UUID of warehouse for pickup location (alternative to pickup_lat/lng) - units (optional): Number of units for pricing calculation (defaults to delivery service unit_max if not provided) Pricing Logic: - Determines delivery zones based on coordinates - If pickup and dropoff are in the same zone: uses delivery service default price - If pickup and dropoff are in different zones: uses zone-specific pricing - If warehouse_id provided, uses warehouse address as pickup location - Units parameter multiplies the base price calculation - Returns error if locations are outside configured delivery zones

Send a bearer token in Authorization and a tenant API key when the integration requires X-APIKey or X-API-Key.
Request
curl
1curl --request GET "$ONDI_BASE_URL/external/delivery/price?delivery_service_id={{delivery_service_id}}&pickup_lat={{pickup_lat}}&pickup_lng={{pickup_lng}}&dropoff_lat={{dropoff_lat}}&dropoff_lng={{dropoff_lng}}&tenant_id={{tenant_id}}" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "X-API-Key: {{api_key}}"

Query parameters

delivery_service_idOptional
query string

{{delivery_service_id}}

ID of the delivery service to calculate price for (Required)

pickup_latOptional
query string

{{pickup_lat}}

Latitude of pickup location (Optional if warehouse_id provided, decimal format)

pickup_lngOptional
query string

{{pickup_lng}}

Longitude of pickup location (Optional if warehouse_id provided, decimal format)

dropoff_latOptional
query string

{{dropoff_lat}}

Latitude of dropoff location (Required, decimal format)

dropoff_lngOptional
query string

{{dropoff_lng}}

Longitude of dropoff location (Required, decimal format)

tenant_idOptional
query string

{{tenant_id}}

ID of the tenant (Required)

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

X-API-KeyOptional
header string

{{api_key}}

Responses

Success Response200OK
Response body
json
1{2  "success": true,3  "price": 15.54}
Error - Missing Parameters400Bad Request
Response body
json
1{2  "success": false,3  "error": "missing_required_parameters"4}
Error - Invalid Coordinates400Bad Request
Response body
json
1{2  "success": false,3  "error": "invalid_coordinates"4}
Error - Service Not Found400Bad Request
Response body
json
1{2  "success": false,3  "error": "delivery_service_not_found"4}
Error - Outside Delivery Zone400Bad Request
Response body
json
1{2  "success": false,3  "error": "delivery_location_outside_delivery_zone"4}
Error - Zone Pricing Not Found400Bad Request
Response body
json
1{2  "success": false,3  "error": "address_outside_delivery_zone"4}
Error - Server Error500Internal Server Error
Response body
json
1{2  "success": false,3  "error": "internal_server_error"4}
Invalid Units (400 Bad Request)400
Response body
json
1{2  "success": false,3  "error": "invalid_units_parameter"4}
Server Error (500 Internal Server Error)500
Response body
json
1# Using coordinates2curl -X GET "https://your-domain.supabase.co/functions/v1/external/delivery/price?delivery_service_id=123e4567-e89b-12d3-a456-426614174000&pickup_lat=40.7128&pickup_lng=-74.0060&dropoff_lat=40.7589&dropoff_lng=-73.9851&tenant_id=abc123def-456-789-ghi-jklmnop&units=2" \3  -H "Authorization: Bearer your-token-here"45# Using warehouse ID6curl -X GET "https://your-domain.supabase.co/functions/v1/external/delivery/price?delivery_service_id=123e4567-e89b-12d3-a456-426614174000&warehouse_id=warehouse-uuid&dropoff_lat=40.7589&dropoff_lng=-73.9851&tenant_id=abc123def-456-789-ghi-jklmnop" \7  -H "Authorization: Bearer your-token-here"

Get Zone by Coordinates

External & Carrier Integrations / External & Carrier Integrations
GET/external/zone?lat={{latitude}}&lng={{longitude}}&tenant_id={{tenant_id}}

Get the delivery zone that contains the given coordinates. This endpoint uses the get_zone_by_point database function to find which zone contains the specified latitude and longitude. Authentication: - Requires valid authentication token or API key - Public endpoint accessible to external systems Query Parameters: - lat (required): Latitude of the location (decimal format, e.g., 40.7128) - lng (required): Longitude of the location (decimal format, e.g., -74.0060) - tenant_id (required): UUID of the tenant

Send a bearer token in Authorization and a tenant API key when the integration requires X-APIKey or X-API-Key.
Request
curl
1curl --request GET "$ONDI_BASE_URL/external/zone?lat={{latitude}}&lng={{longitude}}&tenant_id={{tenant_id}}" \2  --header "Authorization: Bearer {{access_token}}" \3  --header "X-API-Key: {{api_key}}"

Query parameters

latOptional
query string

{{latitude}}

Latitude of the location (Required, decimal format)

lngOptional
query string

{{longitude}}

Longitude of the location (Required, decimal format)

tenant_idOptional
query string

{{tenant_id}}

ID of the tenant (Required)

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

X-API-KeyOptional
header string

{{api_key}}

Responses

Success Response200OK
Response body
json
1{2  "success": true,3  "message": "zone_found_successfully",4  "zone": {5    "id": "123e4567-e89b-12d3-a456-426614174000",6    "name": "Downtown Zone",7    "boundaries": {8      "type": "Polygon",9      "coordinates": [10        [11          [12            40.7128,13            -74.00614          ],15          [16            40.72,17            -74.0118          ]19        ]20      ]21    },22    "is_active": true23  }24}
Error - Missing Parameters400Bad Request
Response body
json
1{2  "success": false,3  "message": "lat, lng, and tenant_id are required"4}
Error - Invalid Coordinates400Bad Request
Response body
json
1{2  "success": false,3  "message": "lat and lng must be valid numbers"4}
Error - Zone Not Found404Not Found
Response body
json
1{2  "success": false,3  "message": "zone_not_found_for_coordinates"4}
Error - Server Error500Internal Server Error
Response body
json
1{2  "success": false,3  "message": "internal_server_error"4}
Success (200 OK)200
Response body
json
1{2  "success": true,3  "message": "zone_found_successfully",4  "zone": {5    "id": "123e4567-e89b-12d3-a456-426614174000",6    "name": "Downtown Zone",7    "boundaries": {8      "type": "Polygon",9      "coordinates": [[[lat, lng], [lat, lng]]]10    },11    "is_active": true12  }13}
Missing Parameters (400 Bad Request)400
Response body
json
1{2  "success": false,3  "message": "lat_lng_required"4}
Missing Tenant ID (400 Bad Request)400
Response body
json
1{2  "success": false,3  "message": "tenant_id_required"4}
Invalid Coordinates (400 Bad Request)400
Response body
json
1{2  "success": false,3  "message": "invalid_coordinates"4}
Server Error (500 Internal Server Error)500
Response body
json
1curl -X GET "https://your-domain.supabase.co/functions/v1/external/zone?lat=40.7128&lng=-74.0060&tenant_id=abc123def-456-789-ghi-jklmnop" \2  -H "Authorization: Bearer your-token-here"