Jira Bulk Create Workflow API with existing statuses is always failing
Asked by Vinod K Gandham:

I am using **Bulk create workflows API** from Jira Cloud to create a workflow using existing workflow statuses within the Jira Site.

If I am trying to create a workflow with new status which is not exists in Jira Site is getting succeeded. However if the workflow status is already present is always failing with below error
>
> ```
> { "errorMessages": [ "Status name \"Not Started\" must be unique." ], "errors": {} }
> ```

Here is the sample payload which I am using:

```
{
```

"scope": {  
"type": "GLOBAL"  
},  
"statuses": \[  
{  
"description": "",  
"name": "Not Started",  
"statusCategory": "TODO",  
"statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3"  
}  
\],  
"workflows": \[  
{  
"description": "Action Item Workflow that applies to all projects that are either test or come via intake as a Standard project",  
"name": "Action Item Workflow",  
"startPointLayout": {  
"x": 784.0,  
"y": 67.4  
},  
"statuses": \[  
{  
"layout": {  
"x": 736.2705078125,  
"y": 149.29999877929689  
},  
"properties": {},  
"statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3"  
}  
\],  
"transitions": \[  
{  
"id": "1",  
"type": "INITIAL",  
"from": \[\],  
"to": {  
"statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3",  
"port": 1  
},  
"name": "Create",  
"description": "",  
"actions": \[\],  
"validators": \[  
{  
"ruleKey": "system:check-permission-validator",  
"parameters": {  
"permissionKey": "CREATE_ISSUES"  
},  
"id": "c11b6b06-5cfd-4606-9596-cb64bd1d1c08"  
}  
\],  
"triggers": \[\],  
"properties": {}  
}  
\]  
}  
\]  
}

```

```


Answers:
author: Vinod K Gandham
body: Hi [@Marcel Caroly](/t5/user/viewprofilepage/user-id/3151198)

I found some of your replies around Workflow Jira cloud APIs but none of the providing solution for above issue. Can you please check above issue and assist us in resolving the issue if you have suggestions or steps.

Here is the API reference which we are following.

[https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-workflows/#api-rest-api-3-workflows-create-post](http://Bulk%20create workflow API)

If this is not the correct API to create a workflows using existing statuses, let me know the valid api reference.

Thanks

comments: author: Marcel Caroly
body: Hey [@Vinod K Gandham](/t5/user/viewprofilepage/user-id/5544171),

I don't check into community that often. Sorry.   
The issue is with the statuses in your payload. When no id is supplied we assume you are trying to making a new status with that name. So we are blocking the update because we don't allow you to create a new status with an existing name in the scope of the operation here.

```
"statuses": [
  {
    "description": "",
    "name": "Not Started",
    "statusCategory": "TODO",
    "statusReference": "9a734e9b-fcf8-4b23-8574-e35609d42fb3",
    "id": "<ID>"
  }
],
```

For a bit of context around why,  

The workflow update/create API is declarative, it will create and update the statuses that are related to the workflow in these updates. Because we don't allocate know what status-id will be generated by the system for new statuses we went with using a reference to connect the 'statuses' to the 'workflows' in the payload.


Tags: cloud

jira-cloud

rest-api

workflow