# Workflow

## Overview

The content on this page helps you set up and verify the workflow for the complaints module using Postman APIs. Workflows define how a complaint moves from one stage to another (e.g., from "Apply" to "Resolved").

A workflow defines:

* &#x20;All states a complaint goes through (e.g., Pending, Resolved)
* &#x20;Transitions between states (what happens when a user clicks Assign, Resolve, etc.)
* &#x20;Roles allowed to take each action
* &#x20;SLA (Service Level Agreement) durations for each state

***

## Configure Workflows&#x20;

{% stepper %}
{% step %}

### Import Postman Collection

* Use the provided [Postman collection](https://api.postman.com/collections/23418568-9e180744-697b-475a-b475-13e456850e8d?access_key=PMAT-01JZQ5BRNK5WSE1JWASXY40JWX) for workflow setup.
* Make sure your Postman environment contains the following values:
  * baseUrl (e.g., <https://dev.digit.org>)
  * authToken (Superuser token)
  * tenantId (e.g., pb, uk)
    {% endstep %}

{% step %}

### Setup Before API Calls

<table><thead><tr><th width="195.8984375">Field </th><th>What to use</th></tr></thead><tbody><tr><td>authToken</td><td>A Superuser token with workflow permissions</td></tr><tr><td>tenantId</td><td>state-level or city level  (e.g., pg,  pg.citya)</td></tr></tbody></table>
{% endstep %}

{% step %}

### Create Workflow

* Use POST /businessservice/\_create
* Paste the sample payload (see below)
* Hit "Send" in Postman
* If successful, you’ll receive a confirmation response
  {% endstep %}

{% step %}

### Verify the Workflow

* Use POST /businessservice/\_search
* Search with:
  * tenantId: pb
  * businessService: PGR
* Confirm:
  * All states and transitions are listed
  * Roles and actions are mapped correctly
    {% endstep %}

{% step %}

### Update Workflow (if required)

If something is missing or incorrect:

* Use POST /businessservice/\_update
* Update only the affected parts (state, action, etc.)
* Re-verify using the /search API
  {% endstep %}
  {% endstepper %}

## Sample Workflow Payload

Below is an example workflow for the complaints module:

```
{
  "tenantId": "pb",
  "businessService": "PGR",
  "business": "pgr-services",
  "businessServiceSla": 432000000, // 5 days
  "states": [
    {
      "isStartState": true,
      "isTerminateState": false,
      "isStateUpdatable": true,
      "docUploadRequired": false,
      "actions": [
        {
          "action": "APPLY",
          "nextState": "PENDINGFORASSIGNMENT",
          "roles": ["CITIZEN", "CSR"]
        }
      ]
    },
    {
      "state": "PENDINGFORASSIGNMENT",
      "applicationStatus": "PENDINGFORASSIGNMENT",
      "isStateUpdatable": false,
      "actions": [
        {
          "action": "ASSIGN",
          "nextState": "PENDINGATLME",
          "roles": ["GRO", "DGRO"]
        },
        {
          "action": "REJECT",
          "nextState": "REJECTED",
          "roles": ["GRO", "DGRO"]
        }
      ]
    },
    {
      "state": "PENDINGFORREASSIGNMENT",
      "applicationStatus": "PENDINGFORREASSIGNMENT",
      "isStateUpdatable": false,
      "actions": [
        {
          "action": "REASSIGN",
          "nextState": "PENDINGATLME",
          "roles": ["GRO", "DGRO"]
        },
        {
          "action": "REJECT",
          "nextState": "REJECTED",
          "roles": ["GRO", "DGRO"]
        }
      ]
    },
    {
      "state": "PENDINGATLME",
      "applicationStatus": "PENDINGATLME",
      "sla": 259200000,  // 3 days
      "actions": [
        {
          "action": "RESOLVE",
          "nextState": "RESOLVED",
          "roles": ["PGR_LME"]
        },
        {
          "action": "REASSIGN",
          "nextState": "PENDINGFORREASSIGNMENT",
          "roles": ["PGR_LME"]
        }
      ]
    },
    {
      "state": "REJECTED",
      "applicationStatus": "REJECTED",
      "isTerminateState": true,
      "actions": [
        {
          "action": "REOPEN",
          "nextState": "PENDINGFORASSIGNMENT",
          "roles": ["CITIZEN", "CSR", "CFC"]
        },
        {
          "action": "RATE",
          "nextState": "CLOSEDAFTERREJECTION",
          "roles": ["CITIZEN", "CFC"]
        }
      ]
    },
    {
      "state": "RESOLVED",
      "applicationStatus": "RESOLVED",
      "isTerminateState": true,
      "actions": [
        {
          "action": "REOPEN",
          "nextState": "PENDINGFORASSIGNMENT",
          "roles": ["CITIZEN", "CSR", "CFC"]
        },
        {
          "action": "RATE",
          "nextState": "CLOSEDAFTERRESOLUTION",
          "roles": ["CITIZEN", "CFC"]
        }
      ]
    },
    {
      "state": "CLOSEDAFTERREJECTION",
      "applicationStatus": "CLOSEDAFTERREJECTION",
      "isTerminateState": true
    },
    {
      "state": "CLOSEDAFTERRESOLUTION",
      "applicationStatus": "CLOSEDAFTERRESOLUTION",
      "isTerminateState": true
    }
  ]
}

```

***

## &#x20;Developer Notes&#x20;

<table><thead><tr><th width="241.83984375">Item</th><th>Notes</th></tr></thead><tbody><tr><td>SLA Values</td><td>In milliseconds (e.g., 5 days = 432000000)</td></tr><tr><td>businessService</td><td>Must match what’s used in CCRS module backend</td></tr><tr><td>Roles</td><td>Must exist in MDMS role-action mapping </td></tr><tr><td>Workflow Transitions</td><td>Each action should correctly link one state to another</td></tr></tbody></table>

***

#### Understanding `businessService` in CMS

If the value of `businessService` in the complaint request does **not match** what's configured:

* The workflow won't initialise or progress properly.
* You may see errors like "No workflow found" or "Invalid businessService".

## Summary

<table><thead><tr><th width="174.75390625">Step</th><th>Action</th></tr></thead><tbody><tr><td>1️⃣</td><td>Import Postman Collection</td></tr><tr><td>2️⃣</td><td>Set authToken, tenantId</td></tr><tr><td>3️⃣</td><td>Create workflow via /businessservice/_create</td></tr><tr><td>4️⃣</td><td>Verify with /businessservice/_search</td></tr><tr><td>5️⃣</td><td>Update using /businessservice/_update if needed</td></tr></tbody></table>

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digit.org/complaints-management/complaints-resolution-v2.10/deploy/configure/workflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
