OfferingUser States and Management
OfferingUser represents a user account created for a specific marketplace offering. It supports a finite state machine (FSM) that tracks the lifecycle of user account creation, validation, and management.
States
OfferingUser has the following states:
State | Description |
---|---|
CREATION_REQUESTED |
Initial state when user account creation is requested |
CREATING |
Account is being created by the service provider |
PENDING_ACCOUNT_LINKING |
Waiting for user to link their existing account |
PENDING_ADDITIONAL_VALIDATION |
Requires additional validation from service provider |
OK |
Account is active and ready to use |
DELETION_REQUESTED |
Account deletion has been requested |
DELETING |
Account is being deleted |
DELETED |
Account has been successfully deleted |
ERROR_CREATING |
An error occurred during account creation |
ERROR_DELETING |
An error occurred during account deletion |
State Transitions
stateDiagram-v2
[*] --> CREATION_REQUESTED : Account requested
CREATION_REQUESTED --> CREATING : begin_creating()
CREATION_REQUESTED --> OK : set_ok()
CREATING --> PENDING_ACCOUNT_LINKING : set_pending_account_linking()
CREATING --> PENDING_ADDITIONAL_VALIDATION : set_pending_additional_validation()
CREATING --> OK : set_ok()
PENDING_ACCOUNT_LINKING --> OK : set_validation_complete()
PENDING_ADDITIONAL_VALIDATION --> OK : set_validation_complete()
OK --> DELETION_REQUESTED : request_deletion()
DELETION_REQUESTED --> DELETING : set_deleting()
DELETING --> DELETED : set_deleted()
%% Error state transitions during creation flow
CREATION_REQUESTED --> ERROR_CREATING : set_error_creating()
CREATING --> ERROR_CREATING : set_error_creating()
PENDING_ACCOUNT_LINKING --> ERROR_CREATING : set_error_creating()
PENDING_ADDITIONAL_VALIDATION --> ERROR_CREATING : set_error_creating()
%% Error state transitions during deletion flow
DELETION_REQUESTED --> ERROR_DELETING : set_error_deleting()
DELETING --> ERROR_DELETING : set_error_deleting()
%% Recovery from error states
ERROR_CREATING --> CREATING : begin_creating()
ERROR_CREATING --> OK : set_ok()
ERROR_CREATING --> PENDING_ACCOUNT_LINKING : set_pending_account_linking()
ERROR_CREATING --> PENDING_ADDITIONAL_VALIDATION : set_pending_additional_validation()
ERROR_DELETING --> DELETING : set_deleting()
ERROR_DELETING --> OK : set_ok()
%% Legacy error transitions (backward compatibility)
CREATION_REQUESTED --> ERROR_CREATING : set_error() [legacy]
CREATING --> ERROR_CREATING : set_error() [legacy]
PENDING_ACCOUNT_LINKING --> ERROR_CREATING : set_error() [legacy]
PENDING_ADDITIONAL_VALIDATION --> ERROR_CREATING : set_error() [legacy]
OK --> ERROR_CREATING : set_error() [legacy]
DELETION_REQUESTED --> ERROR_CREATING : set_error() [legacy]
DELETING --> ERROR_CREATING : set_error() [legacy]
REST API Endpoints
State Transition Actions
All state transition endpoints require UPDATE_OFFERING_USER
permission and are accessed via POST to the offering user detail endpoint with the action suffix.
Base URL: /api/marketplace-offering-users/{uuid}/
Set Pending Additional Validation
1 2 3 4 5 6 7 |
|
Valid transitions from: CREATING
, ERROR_CREATING
Set Pending Account Linking
1 2 3 4 5 6 7 |
|
Valid transitions from: CREATING
, ERROR_CREATING
Set Validation Complete
1 |
|
Valid transitions from: PENDING_ADDITIONAL_VALIDATION
, PENDING_ACCOUNT_LINKING
Note: This action clears both the service_provider_comment
and service_provider_comment_url
fields.
Set Error Creating
1 |
|
Valid transitions from: CREATION_REQUESTED
, CREATING
, PENDING_ACCOUNT_LINKING
, PENDING_ADDITIONAL_VALIDATION
Sets the user account to error state during the creation process. Used when creation operations fail.
Set Error Deleting
1 |
|
Valid transitions from: DELETION_REQUESTED
, DELETING
Sets the user account to error state during the deletion process. Used when deletion operations fail.
Begin Creating
1 |
|
Valid transitions from: CREATION_REQUESTED
, ERROR_CREATING
Initiates the account creation process. Can be used to retry creation after an error.
Request Deletion
1 |
|
Valid transitions from: OK
Initiates the account deletion process. Moves the user from active status to deletion requested.
Set Deleting
1 |
|
Valid transitions from: DELETION_REQUESTED
, ERROR_DELETING
Begins the account deletion process. Can be used to retry deletion after an error.
Set Deleted
1 |
|
Valid transitions from: DELETING
Marks the user account as successfully deleted. This is the final state for successful account deletion.
Service Provider Comment Management
Update Comments
Service providers can directly update comment fields without changing the user's state:
1 2 3 4 5 6 7 |
|
Permissions: Requires UPDATE_OFFERING_USER
permission on the offering's customer.
Valid states: All states except DELETED
Both fields are optional - you can update just the comment, just the URL, or both.
OfferingUser Fields
When retrieving or updating OfferingUser objects, the following state-related fields are available:
state
(string, read-only): Current state of the user accountservice_provider_comment
(string, read-only): Comment from service provider for pending statesservice_provider_comment_url
(string, read-only): Optional URL link for additional information or actions related to the service provider comment
Backward Compatibility
The system maintains backward compatibility with existing integrations:
Automatic State Transitions
- Username Assignment: When a username is assigned to an OfferingUser (via API or
set_offerings_username
), the state automatically transitions toOK
- Creation with Username: Creating an OfferingUser with a username immediately sets the state to
OK
Legacy Endpoints
POST /api/marketplace-service-providers/{uuid}/set_offerings_username/
- Bulk username assignment that automatically transitions users toOK
state
Legacy Error State Support
For backward compatibility with existing integrations:
set_error()
method: The legacyset_error()
method still exists and defaults toERROR_CREATING
state
New integrations should use the specific error states (ERROR_CREATING
, ERROR_DELETING
) for better error context.
Usage Examples
Service Provider Workflow
Standard Creation Flow
- Initial Creation: OfferingUser is created with state
CREATION_REQUESTED
- Begin Processing: Transition to
CREATING
state - Require Validation: If additional validation needed, transition to
PENDING_ADDITIONAL_VALIDATION
with explanatory comment and optional URL - Complete Validation: Once validated, transition to
OK
state - Account Ready: User can now access the service
Enhanced Workflow with Comment URLs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Error Handling and Recovery
1 2 3 4 5 6 7 8 9 10 11 |
|
Account Deletion Workflow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Permissions
State transition endpoints use the permission_factory
pattern with:
- Permission:
UPDATE_OFFERING_USER
- Scope:
["offering.customer"]
- User must have permission on the offering's customer
This means users need the UPDATE_OFFERING_USER
permission on the customer that owns the offering associated with the OfferingUser.
Filtering OfferingUsers
The OfferingUser list endpoint supports filtering by state to help manage users across different lifecycle stages.
State Filtering
Filter OfferingUsers by their current state using the state
query parameter:
1 2 |
|
Available State Filter Values
Filter Value | State Constant | Description |
---|---|---|
Requested |
CREATION_REQUESTED |
Users with account creation requested |
Creating |
CREATING |
Users whose accounts are being created |
Pending account linking |
PENDING_ACCOUNT_LINKING |
Users waiting to link existing accounts |
Pending additional validation |
PENDING_ADDITIONAL_VALIDATION |
Users requiring additional validation |
OK |
OK |
Users with active, ready-to-use accounts |
Requested deletion |
DELETION_REQUESTED |
Users with deletion requested |
Deleting |
DELETING |
Users whose accounts are being deleted |
Deleted |
DELETED |
Users with successfully deleted accounts |
Error creating |
ERROR_CREATING |
Users with errors during account creation |
Error deleting |
ERROR_DELETING |
Users with errors during account deletion |
Multiple State Filtering
Filter by multiple states simultaneously:
1 2 |
|
Combining with Other Filters
State filtering can be combined with other available filters:
1 2 3 4 5 6 7 8 |
|
Error Handling
Invalid state values return HTTP 400 Bad Request:
1 2 |
|
Other Available Filters
The OfferingUser list endpoint also supports these filters:
offering_uuid
- Filter by offering UUIDuser_uuid
- Filter by user UUIDuser_username
- Filter by user's username (case-insensitive)provider_uuid
- Filter by service provider UUIDis_restricted
- Filter by restriction status (boolean)created_before
/created_after
- Filter by creation datemodified_before
/modified_after
- Filter by modification datequery
- General search across offering name, username, and user names
Practical Filtering Examples
Here are common filtering scenarios for managing OfferingUsers:
Find Users Requiring Attention
1 2 3 4 5 6 7 8 9 10 11 |
|
Monitor Service Provider Operations
1 2 3 4 5 |
|
Audit and Reporting
1 2 3 4 5 |
|
Events and Logging
State transitions generate:
- Event logs: Recorded in the system event log for audit purposes
- Application logs: Logged with user attribution for debugging and monitoring