Skip to content
Proud to collaborate with Microsoft for Startups

ai-provider.set-default ​

Atomically promotes one AIProviderConfig to be the organization's default AI provider, demoting any previously-default config in the same transaction

Atomically promote an AIProviderConfig to be the org default.

States: PENDING (initial, auto_advance="execute") → COMPLETED (terminal, success=True) PENDING (catch-all) → FAILED (terminal, success=False)

The operation is idempotent: if the target is already the default, the workflow completes with changed=False and no DB mutations.

The unique partial index (organization_id, is_default WHERE is_default) requires that we clear the previous default before setting the new one; we use session.flush() between the two UPDATE statements.

Overview ​

PropertyValue
Workflow typeAtomic
LibraryApp-connection
Version1.0

Input Schema ​

FieldTypeRequiredDefaultDescription
organization_uuiduuidYes—UUID of the organization that owns the AI provider configs
ai_provider_config_uuiduuidYes—UUID of the AIProviderConfig to promote as default
actorstringNo—Authenticated caller initiating the operation

Output Schema ​

FieldTypeRequiredDefaultDescription
organization_uuiduuidYes—UUID of the organization that owns the AI provider configs
ai_provider_config_uuiduuidYes—UUID of the AIProviderConfig to promote as default
actorstringNo—Authenticated caller initiating the operation
previous_default_uuiduuidNo—UUID of the AIProviderConfig that was demoted, or null if none existed
changedbooleanNo—False when target was already the default (idempotent); true when a flip occurred
completed_atstringNo—ISO-8601 timestamp of completion
failure_reasonstringNo—Human-readable failure reason (controlled vocabulary)
failure_typestringNo—Failure category (error code)
failed_actionstringNo—Action method that raised
failed_at_statestringNo—State the workflow was in when it failed
failed_atstringNo—ISO-8601 timestamp of failure
errorstringNo—Engine-stamped exception message
error_typestringNo—Engine-stamped exception class name
failed_layerstringNo—Engine-stamped layer index (DAG path)
failed_stepstringNo—Engine-stamped step name (DAG path)

States ​

StateInitialTerminalSuccessAuto-advanceDescription
pendingYesNo—executeSet-default request received; executing atomic flip
completedNoYesYes—Default AI provider updated (or confirmed unchanged)
failedNoYesNo—Set-default operation failed

State Diagram ​

Transitions ​

FromActionToDescription
pendingexecutecompleted—
* (any state)failfailed—

Business Errors ​

CodeMessage Template
AI_PROVIDER_CONFIG_NOT_FOUNDAIProviderConfig {config_uuid} not found for this organization
AI_PROVIDER_CONFIG_DISABLEDAIProviderConfig {config_uuid} is disabled and cannot be set as default

API Usage ​

bash
POST /api/workflows/start
Content-Type: application/json

{
  "workflow_type": "ai-provider.set-default",
  "initial_data": {
    "organization_uuid": "value",
    "ai_provider_config_uuid": "value"
  }
}