Returns
1 API call in this section.
Create Return Request
/external/returnsCreate a return request for a delivered delivery (Customer-only endpoint).
External API note
This endpoint accepts delivery_code instead of delivery_id (UUID). The system resolves the external delivery code internally. When auto-approved, return_delivery_id is also returned as the public return delivery code.
Security
This endpoint is customer-only. The authenticated user must be a customer.
The delivery must belong to the authenticated customer. Returns
403if the delivery belongs to a different customer.
Business rules
Delivery must be in
deliveredstatus.Only one non-cancelled return request is allowed per delivery.
Inserts
return_requestswith statuspendingand updatesdeliveries.return_status = return_requested.If tenant setting
return_requests.auto_approval = true, the system auto-approves and creates a return delivery usingreturn_requests.default_delivery_service_idand destination rules fromreturn_requests.destination_mode.
Return delivery payment settings
Return deliveries are always created with
payment_method = walletandpayer_type = sender(customer pays via wallet), regardless of the original delivery's payment settings.
Responses
201success (pending or auto-approved)400validation / not eligible / missing fields401unauthorized (customer authentication required)403unauthorized_delivery_access(delivery does not belong to customer)404delivery_not_found/tenant_not_found
Headers
| Parameter | Type | Description |
|---|---|---|
X-API-Key | string | Example: |
Content-Type | string | Example: |
Body parameters
| Parameter | Type | Description |
|---|---|---|
delivery_codeRequired | string | External delivery code, for example |
return_reasonRequired | string | Non-empty reason for the return. |
notesOptional | string | Additional customer note. Empty strings are treated as |
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/external/returns" \2 --header "X-API-Key: ${ONDI_TENANT_API_KEY}" \3 --header "Content-Type: application/json" \4 --data-raw '{5 "delivery_code": "DEL-000001",6 "return_reason": "Damaged product",7 "notes": "Package arrived with visible damage"8}'Response examples
1{2 "success": true,3 "error": null,4 "message": "Return request created",5 "return_request_id": "return-request-uuid",6 "auto_approved": false7}