Skip to main content

CreateProcessDefinitionCommand

Overview

Creates a new process definition from BPMN 2.0 XML.

Purpose

Uploads and validates a BPMN 2.0 workflow definition, making it available for process instance creation.

Command Type

CB.Administration.Api.Commands.BPM.Process.CreateProcessDefinitiionCommand


Request

{
"cmd": "CreateProcessDefinitiionCommand",
"data": {
"name": "Loan Approval Workflow",
"description": "Multi-stage loan approval process with credit checks",
"category": "Lending",
"bpmnXml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\">...</definitions>",
"contextLoaderType": "LoanApplicationContext",
"triggerEvents": ["OnLoanCreation"],
"isActive": true,
"metadata": {
"version": "1.0",
"author": "System Admin",
"tags": ["lending", "approval"]
}
}
}

Request Fields (data object)

FieldTypeRequiredDefaultDescription
namestringYes-Unique name for the process definition
descriptionstringNo""Human-readable description
categorystringNo"General"Logical category for grouping (e.g., "Lending", "Customer Onboarding")
bpmnXmlstring (XML)Yes-Valid BPMN 2.0 XML definition
contextLoaderTypestringNonullType of context loader to use for variable initialization
triggerEventsarrayNo[]System events that auto-trigger this process (e.g., ["OnLoanCreation", "OnDepositOpening"])
isActivebooleanNotrueWhether process can be instantiated
metadataobjectNoAdditional metadata (version, author, tags, etc.)

BPMN XML Validation

The system validates the BPMN XML for:

  • ✅ Valid XML structure
  • ✅ BPMN 2.0 schema compliance
  • ✅ Required elements (process, start event, end event)
  • ✅ Valid task types (userTask, serviceTask, scriptTask, etc.)
  • ✅ Valid gateway types (exclusiveGateway, parallelGateway, etc.)
  • ✅ Valid sequence flows
  • ✅ Script task syntax (if using embedded scripts)
  • ✅ Service task configuration (command names, parameters)

Response

{
"isSuccessful": true,
"message": "Process definition created successfully",
"statusCode": "00",
"data": {
"id": 456,
"name": "Loan Approval Workflow",
"category": "Lending",
"version": 1,
"isActive": true,
"createdDate": "2026-01-06T10:30:00Z",
"createdBy": "admin@bank.com",
"triggerEvents": ["OnLoanCreation"],
"contextLoaderType": "LoanApplicationContext",
"elementCounts": {
"totalElements": 15,
"startEvents": 1,
"endEvents": 2,
"userTasks": 5,
"serviceTasks": 3,
"scriptTasks": 2,
"gateways": 2
}
}
}

Response Fields

FieldTypeDescription
idlongUnique identifier for the process definition
namestringProcess definition name
categorystringLogical category
versionintVersion number (auto-incremented)
isActivebooleanActivation status
createdDatedatetimeCreation timestamp
createdBystringUser who created the definition
triggerEventsarrayConfigured trigger events
contextLoaderTypestringContext loader type
elementCountsobjectSummary of BPMN elements

Supported BPMN Elements

Events

  • Start Event (startEvent) - Process entry point
  • End Event (endEvent) - Process completion point
  • Intermediate Throw Event (intermediateThrowEvent) - Signal/message throwing
  • Intermediate Catch Event (intermediateCatchEvent) - Signal/message catching
  • Timer Event (timerEvent) - Time-based triggers

Tasks

  • User Task (userTask) - Human interaction task
  • Service Task (serviceTask) - Automated system task
  • Script Task (scriptTask) - JavaScript/expression execution
  • Send Task (sendTask) - Message/notification sending
  • Receive Task (receiveTask) - Message/signal receiving

Gateways

  • Exclusive Gateway (exclusiveGateway) - XOR decision point
  • Parallel Gateway (parallelGateway) - Fork/join parallel flows
  • Inclusive Gateway (inclusiveGateway) - OR decision point
  • Event-Based Gateway (eventBasedGateway) - Event-driven routing

Other Elements

  • Subprocess (subProcess) - Embedded workflow
  • Call Activity (callActivity) - External workflow reference
  • Boundary Event (boundaryEvent) - Exception/timer on task
  • Sequence Flow (sequenceFlow) - Flow connections
  • Message Flow (messageFlow) - Cross-process communication

Trigger Events

Process definitions can be configured to automatically start when specific system events occur:

Trigger EventDescriptionUse Case
OnLoanCreationFired when a loan account is createdLoan approval workflows
OnDepositCreationFired when a deposit account is createdAccount opening workflows
OnClientCreationFired when a client is registeredKYC/onboarding workflows
OnTransactionCreationFired on any transactionFraud detection, notifications
OnCashDepositFired on cash deposit transactionsLarge deposit monitoring
OnCashWithdrawalFired on cash withdrawal transactionsWithdrawal limit checks
OnLoanDisbursementFired when loan is disbursedPost-disbursement tasks
OnLoanRepaymentFired on loan repaymentRepayment tracking

Context Loaders

Context loaders initialize process variables from entity data:

Context LoaderEntity TypeAvailable Variables
LoanApplicationContextLoan AccountloanId, amount, clientId, productId, branch, status
DepositAccountContextDeposit AccountaccountId, accountNumber, balance, clientId, productId
ClientContextClientclientId, clientCode, firstName, lastName, email, phone
TransactionContextTransactiontransactionId, amount, type, accountId, reference

Error Responses

Invalid BPMN XML

{
"isSuccessful": false,
"message": "Invalid BPMN XML: Start event 'StartEvent_1' is missing",
"statusCode": "40",
"data": {
"validationErrors": [
"Start event required",
"End event 'EndEvent_1' has no incoming sequence flow"
]
}
}

Duplicate Name

{
"isSuccessful": false,
"message": "Process definition with name 'Loan Approval Workflow' already exists",
"statusCode": "40"
}

Example: Creating a Simple Approval Workflow

{
"cmd": "CreateProcessDefinitiionCommand",
"data": {
"name": "Simple Approval",
"description": "Basic approval workflow with 2 steps",
"category": "General",
"bpmnXml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<definitions xmlns=\"http://www.omg.org/spec/BPMN/20100524/MODEL\"
xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\"
targetNamespace=\"http://banklingo.com/bpmn\">
<process id=\"SimpleApproval\" name=\"Simple Approval Process\">
<startEvent id=\"StartEvent_1\" name=\"Start\"/>
<userTask id=\"Task_Review\" name=\"Review Request\"/>
<userTask id=\"Task_Approve\" name=\"Approve Request\"/>
<endEvent id=\"EndEvent_1\" name=\"End\"/>

<sequenceFlow id=\"Flow_1\" sourceRef=\"StartEvent_1\" targetRef=\"Task_Review\"/>
<sequenceFlow id=\"Flow_2\" sourceRef=\"Task_Review\" targetRef=\"Task_Approve\"/>
<sequenceFlow id=\"Flow_3\" sourceRef=\"Task_Approve\" targetRef=\"EndEvent_1\"/>
</process>
</definitions>",
"isActive": true
}
}

Best Practices

✅ Do's

  1. Use Descriptive Names: Process names should clearly indicate purpose

    ✅ "Loan Approval Workflow - SME Lending"
    ❌ "Process1"
  2. Add Comprehensive Documentation: Use BPMN documentation elements

    <userTask id="Task_1" name="Credit Check">
    <documentation>
    Perform comprehensive credit check including:
    - Credit bureau report
    - Internal scoring
    - Risk assessment
    </documentation>
    </userTask>
  3. Version Your Processes: Include version in metadata

    {
    "name": "Loan Approval Workflow",
    "metadata": {
    "version": "2.1.0",
    "changelog": "Added automated credit checks"
    }
    }
  4. Use Categories: Organize processes logically

    • Lending - Loan-related workflows
    • Deposits - Deposit account workflows
    • Compliance - Regulatory/compliance workflows
    • Operations - Operational processes
  5. Test Before Activation: Create as inactive, test thoroughly, then activate

    {
    "name": "New Workflow",
    "isActive": false, // Test first
    "bpmnXml": "..."
    }

❌ Don'ts

  1. Don't skip XML validation - Ensure valid BPMN before submission
  2. Don't create duplicate definitions - Check existing processes first
  3. Don't hardcode values - Use variables and context loaders
  4. Don't create overly complex processes - Break into subprocesses
  5. Don't forget error handling - Include boundary events and error flows


Last Updated: January 6, 2026