# Steps for migrating any process

**Step-by-Step Process Migration:**

1. **Log in to the Target Company:** Ensure you're logged into the company where you wish to migrate the process. This step helps in acquiring the authentication token, verifying whether the user has the requisite permissions for creating or modifying components.

&#x20;       For example: The user want to migrate the some process from a company abc.senpiper.com&#x20;

&#x20;       xyz.senpiper.com&#x20;

&#x20;       Source company will be xyz.senpiper.com and Target company will be abc.senpiper.com

2. **Group Creation:** If a group for the process to be migrated isn't already present in target company, create one.
3. **Fetch the auth token for the source company:** This is the company from which the process will be migrated.
4. **Get the Form details:** get the Group ID and form ID of the form to be migrated.
5. **Initiate the GET API Call:** To fetch all dependencies of the chosen form, use the following endpoint:

   **Endpoint:** `Source company URL/api/core/process/migration/metadata`

   **Headers:**

   * Auth token
   * Content/type: application/json
   * Method: GET

   **Body:**

**Sample JSON**

<pre class="language-json"><code class="lang-json">
<strong> {
</strong>   "formSchemaIdentifiers": [
      {
         "groupId": "0bf18c75-4f3d-47e7-bc67-1f79c1bbbc1c",
         "formSchemaId": "6b70ce89-6eeb-4622-b41a-14c76fb8b33f"
      }
   ]
}
</code></pre>

6. **Review the Response:** The API response will detail all the dependencies linked to the selected form. It will provide a clear overview of components such as linked entity migrations (e.g., master schemas, HTML templates), workflows, and alarms.

**Sample Response**

{% code overflow="wrap" fullWidth="false" %}

```json


{
"sourceDetails": {
"authToken": "S8E8MX6S5t7g4VsNgbon6w==.xr346lV0zA84Q37AIgrd5+IwztemapMOuhOicWyHN31UKjxFbsgggXItlbRI6FxRzMr2TqnW9aoyGbjfaCVZzKMosEqI4xyhrUhSr2RJYYTkNtkDM9nbJT9/FeLoZmd8zqIhby01tgCDdX0UD956qKK0VmQftFZ7CFMfn32Msxp+As489QMWZAA3qtuSmWhlZ6LUF0xZvYmwtg2ZLpCK6VdbCd/qiT0c5KPAFGto/tejGXCYZXtPJ3bPfMD6cN689O738JcXe6brM2+hcJIWLCE2XUCKSZis0f13rSyAT9MlCqYSbf0CJnkb/MzFIvn/hYFIFLPDUbtEu3799qyFGTIJip1JRVFgO4LwGT656Y693xBAELHsKdlZ+j6CNaim3IsAoJpqNvY9OzIR5ByYbBFwoRgeeEWHTN4T4BSzqqWdy4H7He/UA0Pf0C++SNIdRZrxWUsNgefs+1vBRjBv5gpfIolS6GU5cSUtKpood/Pk0lzUw5LhBHshS45X5l/aAy8pZ+CO5g==.5ZieRjElncBMFZkVY6Fu/ktQcUjM1eAVr8jE5SDNvCc=",
"companyId": "e22b96ad-ff8d-4652-9aa5-3a305b67388b",
"companyBaseUrl": "https://nl-uat.nagalandpolice.com",
"companyName": "Nagaland Police",
"subdomain": "nl-uat"
},
"entityMigrationDtos": [
{
"migrationType": "FORM",
"sourceFormSchemaIdentifier": {
"groupId": "0bf18c75-4f3d-47e7-bc67-1f79c1bbbc1c",
"formSchemaId": "6b70ce89-6eeb-4622-b41a-14c76fb8b33f",
"formName": "Leave Application Form"
},
"linkedEntityMigrationDtos": [
{
"migrationType": "MASTER_SCHEMA",
"sourceMasterSchemaIdentifier": {
"masterId": "e22b96ad-ff8d-4652-9aa5-3a305b67388b",
"companyId": "e22b96ad-ff8d-4652-9aa5-3a305b67388b",
"name": "EMPLOYEES"
}
},
{
"migrationType": "HTML_TEMPLATE",
"sourceTemplateIdentifier": {
"companyId": "e22b96ad-ff8d-4652-9aa5-3a305b67388b",
"templateId": "b9165db0-f60a-11ed-91e2-e51807e8710e",
"templateName": "Nagaland Leave Management"
}
}
],
"workflowMigrationDto": {
"sourceWorkflowId": "fc85a42e-417d-4485-b3e0-686dc53854da",
"sourceWorkflowName": "NL Leave Workflow "
},
"alarmMigrationDtos": [
{
"sourceAlarmId": "b9393f2c-72ff-4996-9dbd-df1081a78c87",
"sourceAlarmName": "LMS5"
},
{
"sourceAlarmId": "0e927f77-e15b-45cf-ac67-325c3d91c729",
"sourceAlarmName": "LMS10"
},
{

```

{% endcode %}

*Note: The provided example showcases the response structure with elements like `sourceDetails` for authentication and company information, `entityMigrationDtos` for details on form migrations and their linked entities, `workflowMigrationDto` for workflow details, and `alarmMigrationDtos` for alarm details.*

7. The user has to mention the migration mode (CREATE/UPDATE/USE EXISTING) against each entity and migrate the data using POST API.

**Endpoint:** `Source company URL/api/core/process/migration`

**Headers:**

* Auth token
* Content/type: application/json

**Body**

```json
sample Json 1

{
  "sourceDetails":{
    "authToken":"",
    "companyId":"14689f27-8e76-4dc6-8641-4bb72dfbeffe",
    "companyBaseUrl":"https://profiletesting.staging.senpiper.com",
    "companyName":"Profile testing",
    "subdomain":"profiletesting"
  },
  "formMigrationDtos":[
    {
      "migrationMode":"CREATE",
      "migrationType":"FORM",
      "sourceFormSchemaIdentifier":{
        "groupId":"2c7b9f83-f979-4e51-a77c-0de438f36cb3",
        "formSchemaId":"d519c132-29b4-4213-8925-d7b01f3d08b3"
      },
      "destinationFormSchemaIdentifier":{
        "groupId":"968aba22-a4bb-4aa5-8d66-305899590a8f"
      },
      "workflowMigrationDto":{
        "migrationMode":"CREATE",
        "sourceWorkflowId":"c3a1a7d9-bb9f-4335-806d-4f24a7fbe011"
      }
    }
  ]
}

```

<br>

```json
sample Json 2

{
  "sourceDetails":{
    "authToken":"",
    "companyId":"14689f27-8e76-4dc6-8641-4bb72dfbeffe",
    "companyBaseUrl":"https://profiletesting.staging.senpiper.com",
    "companyName":"Profile testing",
    "subdomain":"profiletesting"
  },
  "formMigrationDtos":[
    {
      "migrationMode":"USE_EXISTING",
      "migrationType":"FORM",
      "sourceFormSchemaIdentifier":{
        "groupId":"2c7b9f83-f979-4e51-a77c-0de438f36cb3",
        "formSchemaId":"6de26a5d-58dc-42ec-913d-a1055078f39f"
      },
      "destinationFormSchemaIdentifier":{
        "groupId":"968aba22-a4bb-4aa5-8d66-305899590a8f",
        "formSchemaId":"b1b8b60d-3a82-45ab-84fc-95b35ed355c1"
      },
      "alarmMigrationDtos":[
        {
        "migrationMode":"CREATE",
        "sourceAlarmId":"588c86fe-c3cd-4185-9d39-1269687352b7"
      },
        {
        "migrationMode":"UPDATE",
        "sourceAlarmId":"a49ae506-0534-4604-89e9-dc608eb2dd59",
        "destinationAlarmId":"ae66068d-7a0d-4e51-824c-66adfa0b684d"
      }]
    }
  ]
}
```

*As can be seen from the above sample json, the user need to provide the respective destination id in case of using UPDATE/USE EXISTING.*
