> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/platform/guides/developer-guide/backend-developer-guide/section-3-integrate-microservices/add-workflow-configuration.md).

# Add Workflow Configuration

## Overview

Workflow configuration should be created based on the business requirements. More details on [extracting workflow in the design guide](/platform/guides/design-guide/model-requirements.md).

## Steps

For our guide, we will configure the following workflow which was the output of the design phase:

![Workflow states, actions and actors](https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-8f91c0f5ee099ad5bb7a63f6a5e497aee03efabd%2Fimage.png?alt=media)

We will re-use the workflow service which is deployed in the development/sandbox environment.

{% hint style="info" %}
This guide assumes you can call the development environment workflow service directly with a **valid auth token**.

A sample curl is posted below. Make sure to replace the server hostname and the username and password in the below statement:

```bash
curl --location --request POST 'https://yourserver.digit.org/user/oauth/token' \
--header 'Authorization: Basic ZWdvdi11c2VyLWNsaWVudDo=' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'scope=read' \
--data-urlencode 'username=<mobile_no_of user>' \
--data-urlencode 'password=<pwd_you_created>' \
--data-urlencode 'tenantId=<your_tenant_id>' \
--data-urlencode 'userType=CITIZEN'
```

{% endhint %}

1. In POSTMan, create a new POST request and paste the below content in the body. The URL for the request is `http://yourserver.digit.org/egov-workflow-v2/egov-wf/businessservice/_create` to create the workflow.

{% hint style="info" %}
Make sure to replace the authToken field in the body with appropriate auth token in your environment. Login to the server as a CITIZEN or EMPLOYEE user (depending on which one you've created) and obtain the authToken from the response body.
{% endhint %}

{% hint style="info" %}
In DIGIT, the API Gateway (Zuul) enriches user information based on the auth token for all requests that go via the gateway. Port forwarding by-passes the API gateway. In this case, when accessing a service directly, for a request to be valid, a user has to send the userInfo JSON **inside the RequestInfo** object. This is true not just for Workflow but for any service. Sample:

`"userInfo": {`

`"id": 24226,`

`"uuid": "11b0e02b-0145-4de2-bc42-c97b96264807",`

`"userName": "sample_user",`

`"roles": [`

`{`"name": "Citizen", "code": "CITIZEN"}

]

}

**Note that UUID and roles can be dummy place-holder entities in this case for local testing.**
{% endhint %}

2. Below is the URL and POST body for the business service creation request.

```
http://yourserver.digit.org/egov-workflow-v2/egov-wf/businessservice/_create
```

```json
{
   "RequestInfo": {
       "apiId": "Rainmaker",
       "action": "",
       "did": 1,
       "key": "",
       "msgId": "20170310130900|en_IN",
       "requesterId": "",
       "ts": 1513579888683,
       "ver": ".01",
       "authToken": "{{devAuth}}"
   },
   "BusinessServices": [
       {
           "tenantId": "pb",
           "businessService": "BTR",
           "business": "birth-registration",
           "businessServiceSla": 432000000,
           "states": [
               {
                   "sla": null,
                   "state": null,
                   "applicationStatus": null,
                   "docUploadRequired": true,
                   "isStartState": true,
                   "isTerminateState": false,
                   "isStateUpdatable": true,
                   "actions": [
                       {
                           "action": "APPLY",
                           "nextState": "APPLIED",
                           "roles": [
                               "CITIZEN",
                               "EMPLOYEE"
                           ]
                       }
                   ]
               },
               {
                   "sla": null,
                   "state": "APPLIED",
                   "applicationStatus": "APPLIED",
                   "docUploadRequired": false,
                   "isStartState": false,
                   "isTerminateState": true,
                   "isStateUpdatable": false,
                   "actions": [
                       {
                           "action": "APPROVE",
                           "nextState": "APPROVED",
                           "roles": [
                               "EMPLOYEE"
                           ]
                       },
                       {
                           "action": "REJECT",
                           "nextState": "REJECTED",
                           "roles": [
                               "EMPLOYEE"
                           ]
                       }
                   ]
               },
               {
                   "sla": null,
                   "state": "APPROVED",
                   "applicationStatus": "APPROVED",
                   "docUploadRequired": false,
                   "isStartState": false,
                   "isTerminateState": false,
                   "isStateUpdatable": false,
                   "actions": [
                       {
                           "action": "PAY",
                           "nextState": "REGISTRATIONCOMPLETED",
                           "roles": [
                               "SYSTEM_PAYMENT",
                               "CITIZEN",
                               "EMPLOYEE"
                           ]
                       }
                   ]
               },
               {
                   "sla": null,
                   "state": "REJECTED",
                   "applicationStatus": "REJECTED",
                   "docUploadRequired": false,
                   "isStartState": false,
                   "isTerminateState": true,
                   "isStateUpdatable": false,
                   "actions": null
               },
               {
                   "sla": null,
                   "state": "REGISTRATIONCOMPLETED",
                   "applicationStatus": "REGISTRATIONCOMPLETED",
                   "docUploadRequired": false,
                   "isStartState": false,
                   "isTerminateState": true,
                   "isStateUpdatable": false,
                   "actions": null
               }
           ]
       }
   ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.digit.org/platform/guides/developer-guide/backend-developer-guide/section-3-integrate-microservices/add-workflow-configuration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
