COD Collections
5 API calls in this section.
List COD Collections
/delivery/cod-collections?page=1&limit=20&search=&sort_by=collected_at&sort_order=desc&status=&driver_id=&delivery_id=&delivery_code=&amount_min=&amount_max=&collected_at_from=&collected_at_to=&remitted_at_from=&remitted_at_to=&settled_at_from=&settled_at_to=&column_filters=&tenant_id=&language=enList physical cash collections with pagination, search, sorting, and column filters. Drivers see only their own collections. Dispatchers see all. amount is the total cash held by the driver. allocations.cod is the goods/COD portion and allocations.delivery_fee is the delivery-fee portion. collection_stage is pickup or dropoff for new records. Cash record rules: - Sender pays delivery fee in cash: create a pickup record with {cod: 0, delivery_fee}. - Receiver pays COD while sender paid the fee: create a separate dropoff record with {cod, delivery_fee: 0}. - Receiver pays both COD and delivery fee in cash: create one dropoff record with {cod, delivery_fee}. Frontend integration contract: Display amount as the amount held/remitted. Use collection_stage and allocations for the collection point and breakdown. Status values remain collected, remitted, and settled_by_wallet. Search example: ?search=chirag matches rows where driver name, customer name, email, or address contains 'chirag' Sort example: ?sort_by=amount&sort_order=desc Column Filters (column_filters as JSON): Per-column filter object. Takes priority over direct query params for the same field when direct params are absent. | Key | Type | Behaviour | |-----|------|----------| | customer_name | string | ILIKE match | | driver_name | string | ILIKE match | | delivery_address | string | ILIKE match | | external_reference_id | string | ILIKE match | | status | string | Exact match (collected \| remitted \| settled_by_wallet) | | delivery_code | number or {min,max} | Exact or range | | amount | number or {min,max} | Exact or range | | collected_at | {from,to} | Date range (day boundaries) | | remitted_at | {from,to} | Date range (day boundaries) | | settled_at | {from,to} | Date range (day boundaries) | Example: ?column_filters={"customer_name":"john","amount":{"min":50,"max":200},"collected_at":{"from":"2024-01-01","to":"2024-01-31"}} Summary fields: - total_collected — sum of collected status amounts - total_remitted — sum of remitted status amounts - total_settled_by_wallet — sum of settled_by_wallet status amounts - total_pending — same as total_collected (unremitted) - total_cod_collections — total count (ignores status filter)
1curl --request GET "$ONDI_BASE_URL/delivery/cod-collections?page=1&limit=20&search=&sort_by=collected_at&sort_order=desc&status=&driver_id=&delivery_id=&delivery_code=&amount_min=&amount_max=&collected_at_from=&collected_at_to=&remitted_at_from=&remitted_at_to=&settled_at_from=&settled_at_to=&column_filters=&tenant_id=&language=en" \2 --header "Authorization: Bearer {{access_token}}"Query parameters
pageOptional1
Page number (default: 1)
limitOptional20
Items per page (default: 20, max: 100)
searchOptionalCase-insensitive partial match across delivery code, customer name, driver name, driver email, delivery address
sort_byOptionalcollected_at
Sort column: delivery_code | amount | status | collected_at | remitted_at | settled_at | customer_name | driver_name (default: collected_at)
sort_orderOptionaldesc
Sort direction: asc | desc (default: desc)
statusOptionalFilter by status: collected | remitted | settled_by_wallet
driver_idOptionalFilter by driver ID (dispatcher only)
delivery_idOptionalFilter by delivery ID
delivery_codeOptionalFilter by exact delivery code
amount_minOptionalFilter amount >= value
amount_maxOptionalFilter amount <= value
collected_at_fromOptionalFilter collected_at >= date (ISO, normalized to day start). Alias: from_date
collected_at_toOptionalFilter collected_at <= date (ISO, normalized to day end). Alias: to_date
remitted_at_fromOptionalFilter remitted_at >= date (ISO)
remitted_at_toOptionalFilter remitted_at <= date (ISO)
settled_at_fromOptionalFilter settled_at >= date (ISO)
settled_at_toOptionalFilter settled_at <= date (ISO)
column_filtersOptionalJSON object for per-column filtering. Supported keys: customer_name (ilike), driver_name (ilike), delivery_address (ilike), external_reference_id (ilike), status (exact string), delivery_code (number or {min,max}), amount (number or {min,max}), collected_at ({from,to} date range), remitted_at ({from,to} date range), settled_at ({from,to} date range). Example: {"customer_name":"john","amount":{"min":50,"max":200},"collected_at":{"from":"2024-01-01","to":"2024-01-31"}}
tenant_idOptionalTenant ID (optional if in auth token)
languageOptionalen
Response language
Headers
AuthorizationOptionalBearer {{access_token}}
Responses
Get COD Summary
/delivery/cod-summary?driver_id=&tenant_id=&language=enGet driver's COD summary for wallet dashboard display. Shows unremitted amounts and pending collection counts. Authentication: - Requires valid authentication token - Drivers see their own summary - Dispatchers can fetch specific driver's summary Query Parameters: - driver_id (optional): Driver ID to fetch summary for (dispatcher only) - tenant_id (optional): Tenant ID (defaults to authenticated user's tenant) - language (optional): Preferred language for response messages
1curl --request GET "$ONDI_BASE_URL/delivery/cod-summary?driver_id=&tenant_id=&language=en" \2 --header "Authorization: Bearer {{access_token}}"Query parameters
driver_idOptionalDriver ID to fetch summary for (dispatcher only)
tenant_idOptionalTenant ID (optional if in auth token)
languageOptionalen
Preferred language for response messages
Headers
AuthorizationOptionalBearer {{access_token}}
Responses
1{2 "success": true,3 "summary": {4 "total_unremitted": 200,5 "pending_collections_count": 5,6 "oldest_unremitted_date": "2023-01-01T10:00:00Z"7 }8}1{2 "success": false,3 "message": "Driver not found"4}Bulk Remit COD Collections
/delivery/cod-collections/remit?tenant_id=&language=enMark physical cash collections as remitted after a dispatcher receives cash from the driver. Atomic business rules: - Credit each delivery customer's wallet with allocations.cod. - Change the matching COD_COLLECTION payment from PENDING to SUCCESS. - Mark each collection remitted. - The delivery-fee allocation is not moved to a wallet in cash-remittance mode. - If any wallet/payment/collection update fails, the whole remittance fails. Frontend integration contract: Submit selected IDs in cod_collection_ids. On success, display status remitted. Handle HTTP 400 when a collection is invalid or no longer pending.
1curl --request POST "$ONDI_BASE_URL/delivery/cod-collections/remit?tenant_id=&language=en" \2 --header "Authorization: Bearer {{access_token}}" \3 --header "Content-Type: application/json" \4 --header "Content-Type: application/json" \5 --data '{6 "cod_collection_ids": [7 "uuid1",8 "uuid2",9 "uuid3"10 ],11 "remitted_to_user_id": "dispatcher-uuid",12 "notes": "Weekly remittance batch",13 "reference": "REM-REF-001"14}'1{2 "cod_collection_ids": [3 "uuid1",4 "uuid2",5 "uuid3"6 ],7 "remitted_to_user_id": "dispatcher-uuid",8 "notes": "Weekly remittance batch",9 "reference": "REM-REF-001"10}Query parameters
tenant_idOptionalTenant ID (optional if in auth token)
languageOptionalen
Preferred language for response messages
Request body fields
cod_collection_idsExampleExample field from the request body.
remitted_to_user_idExampleExample field from the request body.
notesExampleExample field from the request body.
referenceExampleExample field from the request body.
Headers
AuthorizationOptionalBearer {{access_token}}
Content-TypeOptionalapplication/json
Responses
Settle COD by Wallet
/delivery/cod-collections/settle-by-wallet?tenant_id=&language=enSettle selected cash collections using the driver's wallet. Atomic business rules: - Debit the driver wallet by total collection amount. - Credit customer wallets with allocations.cod. - Credit the tenant wallet with allocations.delivery_fee. - Change matching COD_COLLECTION payments from PENDING to SUCCESS. - Mark collections settled_by_wallet. settlement_amount is optional; when supplied it must match the selected total. Handle HTTP 400 for insufficient balance, invalid collections, or amount mismatch.
1curl --request POST "$ONDI_BASE_URL/delivery/cod-collections/settle-by-wallet?tenant_id=&language=en" \2 --header "Authorization: Bearer {{access_token}}" \3 --header "Content-Type: application/json" \4 --header "Content-Type: application/json" \5 --data '{6 "notes": "Settled all collected CODs using wallet balance",7 "reference": "INV-2024-001",8 "driver_id": ""9}'1{2 "notes": "Settled all collected CODs using wallet balance",3 "reference": "INV-2024-001",4 "driver_id": ""5}Query parameters
tenant_idOptionalTenant ID (optional if in auth token)
languageOptionalen
Preferred language for response messages
Request body fields
notesExampleExample field from the request body.
referenceExampleExample field from the request body.
driver_idExampleExample field from the request body.
Headers
AuthorizationOptionalBearer {{access_token}}
Content-TypeOptionalapplication/json
Responses
Remit Single COD Collection (Legacy)
/delivery/cod-collections/:codId/remit?tenant_id=&language=enRemit a single COD collection (legacy endpoint for backward compatibility). Requires admin permissions. Authentication: - Requires valid authentication token - Requires manage:operations:tenant permission or system admin Path Parameters: - codId: ID of the COD collection to remit Query Parameters: - tenant_id (optional): Tenant ID (defaults to authenticated user's tenant) - language (optional): Preferred language for response messages
1curl --request POST "$ONDI_BASE_URL/delivery/cod-collections/:codId/remit?tenant_id=&language=en" \2 --header "Authorization: Bearer {{access_token}}" \3 --header "Content-Type: application/json" \4 --header "Content-Type: application/json" \5 --data '{}'1{}Path parameters
codIdRequireduuid
ID of the COD collection to remit
Query parameters
tenant_idOptionalTenant ID (optional if in auth token)
languageOptionalen
Preferred language for response messages
Headers
AuthorizationOptionalBearer {{access_token}}
Content-TypeOptionalapplication/json
Responses
1{2 "success": true,3 "message": "COD collection remitted successfully",4 "data": {5 "id": "uuid",6 "delivery_id": "uuid",7 "driver_id": "uuid",8 "amount": "50.00",9 "delivery_code": 1001,10 "collected_at": "2023-01-01T10:00:00Z",11 "remitted_at": "2023-01-01T12:00:00Z",12 "status": "remitted"13 }14}1{2 "success": false,3 "message": "Insufficient permissions"4}1{2 "success": false,3 "message": "COD collection not found"4}