Order Status Rules Management
7 API calls in this section.
Dynamic Order Status Rules Management API for configuring how order group statuses are aggregated into order statuses. Provides complete control over business logic without code changes.
Get All Status Rules
/storefront/admin/order-status-rulesRetrieves all active order status aggregation rules along with available status values and aggregation types.
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
Headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | JWT token for tenant admin (required) Example: |
1curl --globoff --request GET "https://staging-api.ondi.io/functions/v1/storefront/admin/order-status-rules" \2 --header "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}"Response examples
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/admin/order-status-rulesCreates a new order status aggregation rule.
Required: Valid tenant admin authentication
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)
Headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | JWT token for tenant admin (required) Example: |
Content-Type | string | Example: |
Body parameters
| Parameter | Type | Description |
|---|---|---|
status | string | — |
priority | number | — |
aggregationType | string | — |
targetStatus | string | — |
isActive | boolean | — |
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/storefront/admin/order-status-rules" \2 --header "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}" \3 --header "Content-Type: application/json" \4 --data-raw '{5 "status": "processing",6 "priority": 15,7 "aggregationType": "ANY",8 "targetStatus": "processing",9 "isActive": true10}'Response examples
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}Update Status Rule
/storefront/admin/order-status-rules/{{rule_id}}Updates an existing order status aggregation rule.
Required: Valid tenant admin authentication
rule_id(required): UUID of the rule to updatestatus: 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
Path parameters
| Parameter | Type | Description |
|---|---|---|
rule_idRequired | string | Variable used inside the request path. |
Headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | JWT token for tenant admin (required) Example: |
Content-Type | string | Example: |
Body parameters
| Parameter | Type | Description |
|---|---|---|
priority | number | — |
isActive | boolean | — |
1curl --globoff --request PUT "https://staging-api.ondi.io/functions/v1/storefront/admin/order-status-rules/${RULE_ID}" \2 --header "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}" \3 --header "Content-Type: application/json" \4 --data-raw '{5 "priority": 8,6 "isActive": false7}'Response examples
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/admin/order-status-rules/{{rule_id}}Permanently deletes an order status aggregation rule.
Required: Valid tenant admin authentication
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: falseto disable instead of deleteThis preserves rule history and allows easy reactivation
Path parameters
| Parameter | Type | Description |
|---|---|---|
rule_idRequired | string | Variable used inside the request path. |
Headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | JWT token for tenant admin (required) Example: |
1curl --globoff --request DELETE "https://staging-api.ondi.io/functions/v1/storefront/admin/order-status-rules/${RULE_ID}" \2 --header "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}"Response examples
1{2 "success": true,3 "message": "Status rule deleted successfully"4}Reorder Status Rules
/storefront/admin/order-status-rules/reorderReorders status aggregation rules by priority in batch.
Required: Valid tenant admin authentication
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)
Headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | JWT token for tenant admin (required) Example: |
Content-Type | string | Example: |
Body parameters
| Parameter | Type | Description |
|---|---|---|
ruleIds | array<string> | — |
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/storefront/admin/order-status-rules/reorder" \2 --header "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}" \3 --header "Content-Type: application/json" \4 --data-raw '{5 "ruleIds": [6 "rule-uuid-1",7 "rule-uuid-2",8 "rule-uuid-3",9 "rule-uuid-4"10 ]11}'Response examples
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/admin/order-status-rules/reset-defaultsResets all status aggregation rules to the default configuration.
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
ALL cancelled → cancelled (Priority 1)
ALL delivered → delivered (Priority 2)
ALL rejected → rejected (Priority 3)
ALL refunded → refunded (Priority 4)
ALL returned → returned (Priority 5)
ANY
failed_delivery→failed_delivery(Priority 10)ANY
in_transit→ shipped (Priority 11)ANY shipped → shipped (Priority 12)
ANY approved → approved (Priority 13)
ANY
awaiting_approval→awaiting_approval(Priority 14)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
Headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | JWT token for tenant admin (required) Example: |
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/storefront/admin/order-status-rules/reset-defaults" \2 --header "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}"Response examples
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/admin/order-status-rules/testTests status aggregation logic with a given set of group statuses without affecting actual orders.
Required: Valid tenant admin authentication
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)
Headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | JWT token for tenant admin (required) Example: |
Content-Type | string | Example: |
Body parameters
| Parameter | Type | Description |
|---|---|---|
groupStatuses | array<string> | — |
1curl --globoff --request POST "https://staging-api.ondi.io/functions/v1/storefront/admin/order-status-rules/test" \2 --header "Authorization: Bearer ${ADMIN_ACCESS_TOKEN}" \3 --header "Content-Type: application/json" \4 --data-raw '{5 "groupStatuses": [6 "shipped",7 "pending",8 "approved"9 ]10}'Response examples
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}