Skip to main content

COD Collections

5 API calls in this section.

List COD Collections

Delivery & Last-Mile / COD Collections
GET/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

List 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)

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
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

pageOptional
query string

1

Page number (default: 1)

limitOptional
query string

20

Items per page (default: 20, max: 100)

searchOptional
query string

Case-insensitive partial match across delivery code, customer name, driver name, driver email, delivery address

sort_byOptional
query string

collected_at

Sort column: delivery_code | amount | status | collected_at | remitted_at | settled_at | customer_name | driver_name (default: collected_at)

sort_orderOptional
query string

desc

Sort direction: asc | desc (default: desc)

statusOptional
query string

Filter by status: collected | remitted | settled_by_wallet

driver_idOptional
query string

Filter by driver ID (dispatcher only)

delivery_idOptional
query string

Filter by delivery ID

delivery_codeOptional
query string

Filter by exact delivery code

amount_minOptional
query string

Filter amount >= value

amount_maxOptional
query string

Filter amount <= value

collected_at_fromOptional
query string

Filter collected_at >= date (ISO, normalized to day start). Alias: from_date

collected_at_toOptional
query string

Filter collected_at <= date (ISO, normalized to day end). Alias: to_date

remitted_at_fromOptional
query string

Filter remitted_at >= date (ISO)

remitted_at_toOptional
query string

Filter remitted_at <= date (ISO)

settled_at_fromOptional
query string

Filter settled_at >= date (ISO)

settled_at_toOptional
query string

Filter settled_at <= date (ISO)

column_filtersOptional
query string

JSON 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_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Response language

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Responses

Success Response200OK

Get COD Summary

Delivery & Last-Mile / COD Collections
GET/delivery/cod-summary?driver_id=&tenant_id=&language=en

Get 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

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request GET "$ONDI_BASE_URL/delivery/cod-summary?driver_id=&tenant_id=&language=en" \2  --header "Authorization: Bearer {{access_token}}"

Query parameters

driver_idOptional
query string

Driver ID to fetch summary for (dispatcher only)

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Responses

Success Response200OK
Response body
json
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}
Error (404 Not Found)404
Response body
json
1{2  "success": false,3  "message": "Driver not found"4}

Bulk Remit COD Collections

Delivery & Last-Mile / COD Collections
POST/delivery/cod-collections/remit?tenant_id=&language=en

Mark 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.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
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}'
Request body
json
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_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

cod_collection_idsExample
array<string>

Example field from the request body.

remitted_to_user_idExample
string

Example field from the request body.

notesExample
string

Example field from the request body.

referenceExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response200OK

Settle COD by Wallet

Delivery & Last-Mile / COD Collections
POST/delivery/cod-collections/settle-by-wallet?tenant_id=&language=en

Settle 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.

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
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}'
Request body
json
1{2  "notes": "Settled all collected CODs using wallet balance",3  "reference": "INV-2024-001",4  "driver_id": ""5}

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Request body fields

notesExample
string

Example field from the request body.

referenceExample
string

Example field from the request body.

driver_idExample
string

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response200OK
Success Response200OK

Remit Single COD Collection (Legacy)

Delivery & Last-Mile / COD Collections
POST/delivery/cod-collections/:codId/remit?tenant_id=&language=en

Remit 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

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
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 '{}'
Request body
json
1{}

Path parameters

codIdRequired
path string

uuid

ID of the COD collection to remit

Query parameters

tenant_idOptional
query string

Tenant ID (optional if in auth token)

languageOptional
query string

en

Preferred language for response messages

Headers

AuthorizationOptional
header string

Bearer {{access_token}}

Content-TypeOptional
header string

application/json

Responses

Success Response200OK
Response body
json
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}
Error (403 Forbidden)403
Response body
json
1{2  "success": false,3  "message": "Insufficient permissions"4}
Error (404 Not Found)404
Response body
json
1{2  "success": false,3  "message": "COD collection not found"4}