Skip to main content

Order Status Rules Management

7 API calls in this section.

Get All Status Rules

Storefront & Commerce / Order Status Rules Management
GET/storefront/admin/order-status-rules

Retrieves all active order status aggregation rules along with available status values and aggregation types. Authentication: - Required: Valid tenant admin authentication Features: - Returns rules sorted by priority (highest first) - Includes available order status enum values - Provides aggregation types (ALL, ANY) - Shows rule descriptions and business logic Use Cases: - Configure admin interface for status rules - Understand current business logic - Troubleshoot status aggregation issues

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request GET "$ONDI_BASE_URL/storefront/admin/order-status-rules" \2  --header "Authorization: Bearer {{admin_access_token}}"

Headers

AuthorizationOptional
header string

Bearer {{admin_access_token}}

JWT token for tenant admin (required)

Responses

Success - Status Rules List200OK
Response body
json
1{2  "success": true,3  "rules": [4    {5      "id": "rule-uuid-1",6      "status": "cancelled",7      "priority": 1,8      "aggregationType": "ALL",9      "targetStatus": "cancelled",10      "isActive": true,11      "description": "When all groups have status 'cancelled', set order status to 'cancelled'",12      "createdAt": "2024-01-20T10:00:00Z",13      "updatedAt": "2024-01-20T10:00:00Z"14    },15    {16      "id": "rule-uuid-2",17      "status": "delivered",18      "priority": 2,19      "aggregationType": "ALL",20      "targetStatus": "delivered",21      "isActive": true,22      "description": "When all groups have status 'delivered', set order status to 'delivered'"23    },24    {25      "id": "rule-uuid-3",26      "status": "shipped",27      "priority": 12,28      "aggregationType": "ANY",29      "targetStatus": "shipped",30      "isActive": true,31      "description": "When any group have status 'shipped', set order status to 'shipped'"32    },33    {34      "id": "rule-uuid-4",35      "status": "pending",36      "priority": 99,37      "aggregationType": "ANY",38      "targetStatus": "pending",39      "isActive": true,40      "description": "When any group have status 'pending', set order status to 'pending'"41    }42  ],43  "availableStatuses": [44    "pending",45    "awaiting_approval",46    "approved",47    "rejected",48    "shipped",49    "in_transit",50    "delivered",51    "failed_delivery",52    "returned",53    "cancelled",54    "refunded"55  ],56  "aggregationTypes": [57    "ALL",58    "ANY"59  ]60}

Create Status Rule

Storefront & Commerce / Order Status Rules Management
POST/storefront/admin/order-status-rules

Creates a new order status aggregation rule. Authentication: - Required: Valid tenant admin authentication Request Body Fields: - status (required): The group status to check for (must be valid enum value) - priority (required): Rule priority (lower number = higher priority, 1 is highest) - aggregationType (required): Either 'ALL' or 'ANY' - ALL: All groups must have this status - ANY: At least one group must have this status - targetStatus (required): The resulting order status (must be valid enum value) - isActive (optional): Whether the rule is active (default: true) Business Logic: - Rules are processed in priority order (1, 2, 3...) - First matching rule wins and stops processing - Status values are validated against the order status enum - Priority conflicts are allowed but not recommended Examples: - Priority 1, ALL cancelled → cancelled (highest priority terminal state) - Priority 10, ANY shipped → shipped (progressive state) - Priority 99, ANY pending → pending (default fallback)

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/storefront/admin/order-status-rules" \2  --header "Authorization: Bearer {{admin_access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "status": "processing",7  "priority": 15,8  "aggregationType": "ANY",9  "targetStatus": "processing",10  "isActive": true11}'
Request body
json
1{2  "status": "processing",3  "priority": 15,4  "aggregationType": "ANY",5  "targetStatus": "processing",6  "isActive": true7}

Request body fields

statusExample
string

Example field from the request body.

priorityExample
number

Example field from the request body.

aggregationTypeExample
string

Example field from the request body.

targetStatusExample
string

Example field from the request body.

isActiveExample
boolean

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{admin_access_token}}

JWT token for tenant admin (required)

Content-TypeOptional
header string

application/json

Responses

Success - Rule Created201Created
Response body
json
1{2  "success": true,3  "rule": {4    "id": "new-rule-uuid",5    "status": "processing",6    "priority": 15,7    "aggregationType": "ANY",8    "targetStatus": "processing",9    "isActive": true,10    "description": "When any group have status 'processing', set order status to 'processing'",11    "createdAt": "2024-01-20T11:00:00Z",12    "updatedAt": "2024-01-20T11:00:00Z"13  },14  "message": "Status rule created successfully"15}
Error - Invalid Status400Bad Request
Response body
json
1{2  "success": false,3  "message": "Invalid status: invalid_status. Available statuses are: pending, awaiting_approval, approved, rejected, shipped, in_transit, delivered, failed_delivery, returned, cancelled, refunded"4}

Update Status Rule

Storefront & Commerce / Order Status Rules Management
PUT/storefront/admin/order-status-rules/{{rule_id}}

Updates an existing order status aggregation rule. Authentication: - Required: Valid tenant admin authentication Path Parameters: - rule_id (required): UUID of the rule to update Request Body Fields (all optional): - status: Update the group status to check - priority: Update the rule priority - aggregationType: Update aggregation type (ALL/ANY) - targetStatus: Update the resulting order status - isActive: Enable/disable the rule Partial Updates: - Only include fields you want to update - Omitted fields remain unchanged - Status values are validated if provided Use Cases: - Change rule priority for reordering - Temporarily disable rules without deletion - Modify business logic for specific statuses - Update aggregation behavior

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request PUT "$ONDI_BASE_URL/storefront/admin/order-status-rules/{{rule_id}}" \2  --header "Authorization: Bearer {{admin_access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "priority": 8,7  "isActive": false8}'
Request body
json
1{2  "priority": 8,3  "isActive": false4}

Path parameters

rule_idRequired
path string

Variable used inside the request path.

Request body fields

priorityExample
number

Example field from the request body.

isActiveExample
boolean

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{admin_access_token}}

JWT token for tenant admin (required)

Content-TypeOptional
header string

application/json

Responses

Success - Rule Updated200OK
Response body
json
1{2  "success": true,3  "rule": {4    "id": "rule-uuid",5    "status": "processing",6    "priority": 8,7    "aggregationType": "ANY",8    "targetStatus": "processing",9    "isActive": false,10    "description": "When any group have status 'processing', set order status to 'processing'",11    "updatedAt": "2024-01-20T11:30:00Z"12  },13  "message": "Status rule updated successfully"14}

Delete Status Rule

Storefront & Commerce / Order Status Rules Management
DELETE/storefront/admin/order-status-rules/{{rule_id}}

Permanently deletes an order status aggregation rule. Authentication: - Required: Valid tenant admin authentication Path Parameters: - rule_id (required): UUID of the rule to delete Warning: - This action is permanent and cannot be undone - Consider deactivating rules instead of deleting - Deleting rules may affect order status aggregation - Ensure you have backups of important rules Alternative: - Use UPDATE with isActive: false to disable instead of delete - This preserves rule history and allows easy reactivation

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request DELETE "$ONDI_BASE_URL/storefront/admin/order-status-rules/{{rule_id}}" \2  --header "Authorization: Bearer {{admin_access_token}}"

Path parameters

rule_idRequired
path string

Variable used inside the request path.

Headers

AuthorizationOptional
header string

Bearer {{admin_access_token}}

JWT token for tenant admin (required)

Responses

Success - Rule Deleted200OK
Response body
json
1{2  "success": true,3  "message": "Status rule deleted successfully"4}

Reorder Status Rules

Storefront & Commerce / Order Status Rules Management
POST/storefront/admin/order-status-rules/reorder

Reorders status aggregation rules by priority in batch. Authentication: - Required: Valid tenant admin authentication Request Body: - ruleIds (required): Array of rule UUIDs in desired priority order Reordering Logic: - First rule in array gets priority 10 - Second rule gets priority 20 - Third rule gets priority 30, etc. - This provides spacing for future insertions Use Cases: - Drag-and-drop reordering in admin interface - Bulk priority updates - Business logic reorganization - Testing different rule precedence Best Practices: - Terminal states (cancelled, delivered) should have high priority (low numbers) - Progressive states (shipped, approved) should have medium priority - Default states (pending) should have low priority (high numbers)

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/storefront/admin/order-status-rules/reorder" \2  --header "Authorization: Bearer {{admin_access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "ruleIds": [7    "rule-uuid-1",8    "rule-uuid-2",9    "rule-uuid-3",10    "rule-uuid-4"11  ]12}'
Request body
json
1{2  "ruleIds": [3    "rule-uuid-1",4    "rule-uuid-2",5    "rule-uuid-3",6    "rule-uuid-4"7  ]8}

Request body fields

ruleIdsExample
array<string>

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{admin_access_token}}

JWT token for tenant admin (required)

Content-TypeOptional
header string

application/json

Responses

Success - Rules Reordered200OK
Response body
json
1{2  "success": true,3  "rules": [4    {5      "id": "rule-uuid-1",6      "status": "cancelled",7      "priority": 10,8      "aggregationType": "ALL",9      "targetStatus": "cancelled"10    },11    {12      "id": "rule-uuid-2",13      "status": "delivered",14      "priority": 20,15      "aggregationType": "ALL",16      "targetStatus": "delivered"17    },18    {19      "id": "rule-uuid-3",20      "status": "shipped",21      "priority": 30,22      "aggregationType": "ANY",23      "targetStatus": "shipped"24    },25    {26      "id": "rule-uuid-4",27      "status": "pending",28      "priority": 40,29      "aggregationType": "ANY",30      "targetStatus": "pending"31    }32  ],33  "message": "Status rules reordered successfully"34}

Reset to Default Rules

Storefront & Commerce / Order Status Rules Management
POST/storefront/admin/order-status-rules/reset-defaults

Resets all status aggregation rules to the default configuration. Authentication: - Required: Valid tenant admin authentication Warning: - This action deactivates all existing rules - Creates a new set of default rules - Custom business logic will be lost - This action cannot be undone Default Rules Created: 1. ALL cancelled → cancelled (Priority 1) 2. ALL delivered → delivered (Priority 2) 3. ALL rejected → rejected (Priority 3) 4. ALL refunded → refunded (Priority 4) 5. ALL returned → returned (Priority 5) 6. ANY failed_delivery → failed_delivery (Priority 10) 7. ANY in_transit → shipped (Priority 11) 8. ANY shipped → shipped (Priority 12) 9. ANY approved → approved (Priority 13) 10. ANY awaiting_approval → awaiting_approval (Priority 14) 11. ANY pending → pending (Priority 99) Use Cases: - Emergency reset after configuration errors - Starting fresh with proven business logic - Restoring after failed customizations - Setting up new tenants

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/storefront/admin/order-status-rules/reset-defaults" \2  --header "Authorization: Bearer {{admin_access_token}}"

Headers

AuthorizationOptional
header string

Bearer {{admin_access_token}}

JWT token for tenant admin (required)

Responses

Success - Rules Reset200OK
Response body
json
1{2  "success": true,3  "rules": [4    {5      "id": "new-rule-uuid-1",6      "status": "cancelled",7      "priority": 1,8      "aggregationType": "ALL",9      "targetStatus": "cancelled",10      "isActive": true11    },12    {13      "id": "new-rule-uuid-2",14      "status": "delivered",15      "priority": 2,16      "aggregationType": "ALL",17      "targetStatus": "delivered",18      "isActive": true19    }20  ],21  "message": "Status rules reset to defaults successfully"22}

Test Status Aggregation

Storefront & Commerce / Order Status Rules Management
POST/storefront/admin/order-status-rules/test

Tests status aggregation logic with a given set of group statuses without affecting actual orders. Authentication: - Required: Valid tenant admin authentication Request Body: - groupStatuses (required): Array of group status values to test Testing Logic: - Simulates the same aggregation logic used in production - Processes rules in priority order - Returns the first matching rule result - Shows which rules would match for analysis Use Cases: - Test rule changes before applying to production - Validate business logic correctness - Troubleshoot unexpected status aggregations - Training and documentation - Quality assurance testing Example Scenarios: - Test: ['shipped', 'pending'] → Result: 'shipped' (ANY shipped rule) - Test: ['delivered', 'delivered'] → Result: 'delivered' (ALL delivered rule) - Test: ['cancelled', 'cancelled'] → Result: 'cancelled' (ALL cancelled rule) - Test: ['pending', 'pending'] → Result: 'pending' (fallback rule)

Send a bearer token in the Authorization header for an authenticated OnDi user session.
Request
curl
1curl --request POST "$ONDI_BASE_URL/storefront/admin/order-status-rules/test" \2  --header "Authorization: Bearer {{admin_access_token}}" \3  --header "Content-Type: application/json" \4  --header "Content-Type: application/json" \5  --data '{6  "groupStatuses": [7    "shipped",8    "pending",9    "approved"10  ]11}'
Request body
json
1{2  "groupStatuses": [3    "shipped",4    "pending",5    "approved"6  ]7}

Request body fields

groupStatusesExample
array<string>

Example field from the request body.

Headers

AuthorizationOptional
header string

Bearer {{admin_access_token}}

JWT token for tenant admin (required)

Content-TypeOptional
header string

application/json

Responses

Success - Aggregation Test Result200OK
Response body
json
1{2  "success": true,3  "input": {4    "groupStatuses": [5      "shipped",6      "pending",7      "approved"8    ],9    "totalGroups": 310  },11  "result": {12    "aggregatedStatus": "shipped",13    "appliedRules": [14      {15        "id": "rule-uuid-shipped",16        "status": "shipped",17        "priority": 12,18        "aggregationType": "ANY",19        "targetStatus": "shipped",20        "description": "When any group have status 'shipped', set order status to 'shipped'",21        "matched": true,22        "reason": "1 out of 3 groups have status 'shipped'"23      },24      {25        "id": "rule-uuid-approved",26        "status": "approved",27        "priority": 13,28        "aggregationType": "ANY",29        "targetStatus": "approved",30        "description": "When any group have status 'approved', set order status to 'approved'",31        "matched": true,32        "reason": "1 out of 3 groups have status 'approved'"33      },34      {35        "id": "rule-uuid-pending",36        "status": "pending",37        "priority": 99,38        "aggregationType": "ANY",39        "targetStatus": "pending",40        "description": "When any group have status 'pending', set order status to 'pending'",41        "matched": true,42        "reason": "1 out of 3 groups have status 'pending'"43      }44    ]45  }46}
Test - All Delivered Scenario200OK
Response body
json
1{2  "success": true,3  "input": {4    "groupStatuses": [5      "delivered",6      "delivered",7      "delivered"8    ],9    "totalGroups": 310  },11  "result": {12    "aggregatedStatus": "delivered",13    "appliedRules": [14      {15        "status": "delivered",16        "priority": 2,17        "aggregationType": "ALL",18        "targetStatus": "delivered",19        "matched": true,20        "reason": "All 3 groups have status 'delivered'"21      }22    ]23  }24}