工作流:createNewVersion

命名空间:microsoft.graph.identityGovernance

重要

Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。

创建 工作流 对象的新版本。

此 API 可用于以下国家级云部署

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考

权限类型 最低特权权限 更高特权权限
委派(工作或学校帐户) LifecycleWorkflows-Workflow.ReadWrite.All LifecycleWorkflows.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。 不支持。
应用程序 LifecycleWorkflows-Workflow.ReadWrite.All LifecycleWorkflows.ReadWrite.All

重要

在具有工作或学校帐户的委托方案中,必须为登录用户分配受支持的Microsoft Entra角色或具有支持的角色权限的自定义角色。 生命周期工作流管理员 是此作支持的最低特权角色。

HTTP 请求

POST /identityGovernance/lifecycleWorkflows/workflows/{workflowId}/createNewVersion

请求标头

名称 说明
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权
Content-Type application/json. 必需。

请求正文

在请求正文中,提供参数的 JSON 表示形式。

下表显示了可用于此操作的参数。

参数 类型 说明
工作流 microsoft.graph.identityGovernance.workflow 要为其创建新版本的工作流。

响应

如果成功,此作将在 200 OK 响应正文中返回响应代码和 microsoft.graph.identityGovernance.workflow

示例

示例 1:使用基于时间的触发器创建联接器工作流的新版本

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/beta/identityGovernance/lifecycleWorkflows/workflows/{workflowId}/createNewVersion
Content-Type: application/json
Content-length: 631

{
    "workflow":{
        "category": "joiner",
        "description": "Configure new hire tasks for onboarding employees on their first day",
        "displayName": "Global onboard new hire employee",
        "isEnabled": true,
        "isSchedulingEnabled": false,
        "executionConditions": {
            "@odata.type": "#microsoft.graph.identityGovernance.triggerAndScopeBasedConditions",
            "scope": {
                "@odata.type": "#microsoft.graph.identityGovernance.ruleBasedSubjectSet",
                "rule": "(department eq 'Marketing')"
            },
            "trigger": {
                "@odata.type": "#microsoft.graph.identityGovernance.timeBasedAttributeTrigger",
                "timeBasedAttribute": "employeeHireDate",
                "offsetInDays": 1
            }
        },
        "tasks": [
            {
                "continueOnError": false,
                "description": "Enable user account in the directory",
                "displayName": "Enable User Account",
                "isEnabled": true,
                "taskDefinitionId": "6fc52c9d-398b-4305-9763-15f42c1676fc",
                "arguments": []
            },
            {
                "continueOnError": false,
                "description": "Send welcome email to new hire",
                "displayName": "Send Welcome Email",
                "isEnabled": true,
                "taskDefinitionId": "70b29d51-b59a-4773-9280-8841dfd3f2ea",
                "arguments": []
            }
        ]
    }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 200 OK
Content-Type: application/json


{
    "workflow":{
        "category": "joiner",
        "description": "Configure new hire tasks for onboarding employees on their first day",
        "displayName": "Global onboard new hire employee",
        "isEnabled": true,
        "isSchedulingEnabled": false,
        "executionConditions": {
            "@odata.type": "#microsoft.graph.identityGovernance.triggerAndScopeBasedConditions",
            "scope": {
                "@odata.type": "#microsoft.graph.identityGovernance.ruleBasedSubjectSet",
                "rule": "(department eq 'Marketing')"
            },
            "trigger": {
                "@odata.type": "#microsoft.graph.identityGovernance.timeBasedAttributeTrigger",
                "timeBasedAttribute": "employeeHireDate",
                "offsetInDays": 1
            }
        },
        "tasks": [
            {
                "continueOnError": false,
                "description": "Enable user account in the directory",
                "displayName": "Enable User Account",
                "isEnabled": true,
                "taskDefinitionId": "6fc52c9d-398b-4305-9763-15f42c1676fc",
                "arguments": []
            },
            {
                "continueOnError": false,
                "description": "Send welcome email to new hire",
                "displayName": "Send Welcome Email",
                "isEnabled": true,
                "taskDefinitionId": "70b29d51-b59a-4773-9280-8841dfd3f2ea",
                "arguments": []
            }
        ]
    }
}

示例 2:使用自定义电子邮件创建任务的新版本

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/beta/identityGovernance/lifecycleWorkflows/workflows/{workflowId}/createNewVersion
Content-Type: application/json
Content-length: 631

{
    "category": "joiner",
    "description": "Configure new hire tasks for onboarding employees on their first day",
    "displayName": "custom email marketing API test",
    "isEnabled": true,
    "isSchedulingEnabled": false,
    "executionConditions": {
        "@odata.type": "#microsoft.graph.identityGovernance.triggerAndScopeBasedConditions",
        "scope": {
            "@odata.type": "#microsoft.graph.identityGovernance.ruleBasedSubjectSet",
            "rule": "(department eq 'Marketing')"
        },
        "trigger": {
            "@odata.type": "#microsoft.graph.identityGovernance.timeBasedAttributeTrigger",
            "timeBasedAttribute": "employeeHireDate",
            "offsetInDays": 0
        }
    },
    "tasks": [
        {
            "continueOnError": false,
            "description": "Enable user account in the directory",
            "displayName": "Enable User Account",
            "isEnabled": true,
            "taskDefinitionId": "6fc52c9d-398b-4305-9763-15f42c1676fc",
            "arguments": []
        },
        {
            "continueOnError": false,
            "description": "Send welcome email to new hire",
            "displayName": "Send Welcome Email",
            "isEnabled": true,
            "taskDefinitionId": "70b29d51-b59a-4773-9280-8841dfd3f2ea",
            "arguments": [
                {
                    "name": "cc",
                    "value": "1baa57fa-3c4e-4526-ba5a-db47a9df95f0"
                },
                {
                    "name": "customSubject",
                    "value": "Welcome to the organization {{userDisplayName}}!"
                },
                {
                    "name": "customBody",
                    "value": "Welcome to our organization {{userGivenName}}!"
                },
                {
                    "name": "locale",
                    "value": "en-us"
                }
            ]
        }
    ]
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 200 OK
Content-Type: application/json

{
    "workflow":{
        "category": "joiner",
        "description": "Configure new hire tasks for onboarding employees on their first day",
        "displayName": "Global onboard new hire employee",
        "isEnabled": true,
        "isSchedulingEnabled": false,
        "executionConditions": {
            "@odata.type": "#microsoft.graph.identityGovernance.triggerAndScopeBasedConditions",
            "scope": {
                "@odata.type": "#microsoft.graph.identityGovernance.ruleBasedSubjectSet",
                "rule": "(department eq 'Marketing')"
            },
            "trigger": {
                "@odata.type": "#microsoft.graph.identityGovernance.timeBasedAttributeTrigger",
                "timeBasedAttribute": "employeeHireDate",
                "offsetInDays": 1
            }
        },
        "tasks": [
            {
                "continueOnError": false,
                "description": "Enable user account in the directory",
                "displayName": "Enable User Account",
                "isEnabled": true,
                "taskDefinitionId": "6fc52c9d-398b-4305-9763-15f42c1676fc",
                "arguments": []
            },
            {
                "continueOnError": false,
                "description": "Send welcome email to new hire",
                "displayName": "Send Welcome Email",
                "isEnabled": true,
                "taskDefinitionId": "70b29d51-b59a-4773-9280-8841dfd3f2ea",
                "arguments": [
                    {
                    "name": "cc",
                    "value": "b47471b9-af8f-4a5a-bfa2-b78e82398f6e, a7a23ce0-909b-40b9-82cf-95d31f0aaca2"
                },
                {
                "name": "customSubject",
                "value": "Welcome to the organization {{userDisplayName}}!"
                },
                {
                "name": "customBody",
                "value": "Welcome to our organization {{userGivenName}} {{userSurname}}. \nFor more information, reach out to your manager {{managerDisplayName}} at {{managerEmail}}."
                },
                {
                "name": "locale",
                "value": "en-us"
                }, 
    ]
            }
        ]
    }
}

示例 3:创建具有特定管理范围的工作流的新版本

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/beta/identityGovernance/lifecycleWorkflows/workflows/{workflowId}/createNewVersion


{
  "workflow": {
    "category": "mover",
    "displayName": "On Demand mover workflow",
    "description": "Execute real-time tasks for employee job changes",
    "tasks": [
      {
        "category": "mover",
        "continueOnError": false,
        "description": "Send email to notify user’s manager of user move",
        "displayName": "Send email to notify manager of user move",
        "executionSequence": 1,
        "id": "f09eb640-6c16-4f1a-8b48-6a295a307705",
        "isEnabled": true,
        "taskDefinitionId": "aab41899-9972-422a-9d97-f626014578b7",
        "arguments": []
      },
      {
        "arguments": [
          {
            "name": "groupID",
            "value": "8d1d1deb-2ef0-4f72-a460-729a1cc74e7e"
          }
        ],
        "description": "Add user to selected groups",
        "displayName": "Add user to groups",
        "isEnabled": true,
        "continueOnError": false,
        "taskDefinitionId": "22085229-5809-45e8-97fd-270d28d66910",
        "category": "joiner,leaver,mover"
      }
    ],
    "executionConditions": {
      "@odata.type": "#microsoft.graph.identityGovernance.onDemandExecutionOnly"
    },
    "isEnabled": true,
    "isSchedulingEnabled": false,
    "administrationScopeTargets": [
      {
        "@odata.type": "#microsoft.graph.administrativeUnit",
        "id": "2ae6f1b1-fcbf-4ad1-9f4f-8c5e48e364c7"
      }
    ]
  }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.identityGovernance.workflow",
  "category": "mover",
  "description": "Execute real-time tasks for employee job changes",
  "displayName": "On Demand mover workflow",
  "isEnabled": true,
  "isSchedulingEnabled": false,
  "lastModifiedDateTime": "2025-01-09T15:40:14.4514101Z",
  "createdDateTime": "2025-01-09T15:28:24.0565526Z",
  "deletedDateTime": null,
  "id": "394f5831-b1c2-44b3-830d-bbcb88d4ebb0",
  "nextScheduleRunDateTime": null,
  "version": 2,
  "executionConditions": null,
  "lastModifiedBy": {
    "id": "03ad19ba-bf80-4900-bee0-7f6813ee6ecf"
  },
  "tasks@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identityGovernance/lifecycleWorkflows/workflows('465d0d08-3099-483f-9d93-16aad77bcd22')('465d0d08-3099-483f-9d93-16aad77bcd22')/tasks",
  "tasks": [
    {
      "category": "mover",
      "continueOnError": false,
      "description": "Send email to notify user’s manager of user move",
      "displayName": "Send email to notify manager of user move",
      "executionSequence": 1,
      "id": "c070b422-17e3-45a2-82a0-42b5a46c2421",
      "isEnabled": true,
      "taskDefinitionId": "aab41899-9972-422a-9d97-f626014578b7",
      "arguments": []
    },
    {
      "category": "joiner,leaver,mover",
      "continueOnError": false,
      "description": "Add user to selected groups",
      "displayName": "Add user to groups",
      "executionSequence": 2,
      "id": "71b576f8-da57-457f-a507-e7b978c56680",
      "isEnabled": true,
      "taskDefinitionId": "22085229-5809-45e8-97fd-270d28d66910",
      "arguments": [
        {
          "name": "groupID",
          "value": "8d1d1deb-2ef0-4f72-a460-729a1cc74e7e"
        }
      ]
    }
  ],
  "createdBy": {
    "id": "03ad19ba-bf80-4900-bee0-7f6813ee6ecf"
  },
  "administrationScopeTargets": [
    {
      "@odata.type": "#microsoft.graph.administrativeUnit",
      "id": "2ae6f1b1-fcbf-4ad1-9f4f-8c5e48e364c7"
    }
  ]
}

示例 4:创建删除目标范围的移动器工作流的新版本

请求

以下示例显示了一个请求,该请求使用以下配置更新工作流:

  • 它是启用了“mover”工作流的,并设置为仅按需运行。
  • 它为未设置目标范围的用户运行,因为管理范围目标参数为空。
  • 执行两个任务:发送电子邮件以通知用户的经理移动,以及将用户添加到特定组。
POST https://graph.microsoft.com/beta/identityGovernance/lifecycleWorkflows/workflows/{workflowId}/createNewVersion

{
  "workflow": {
    "category": "mover",
    "displayName": "Remove existing target scope of a workflow",
    "description": "On-demand removal of the target scope of a workflow.",
    "tasks": [
      {
        "category": "mover",
        "continueOnError": false,
        "description": "Send email to notify user’s manager of user move",
        "displayName": "Send email to notify manager of user move",
        "executionSequence": 1,
        "id": "f09eb640-6c16-4f1a-8b48-6a295a307705",
        "isEnabled": true,
        "taskDefinitionId": "aab41899-9972-422a-9d97-f626014578b7",
        "arguments": []
      },
      {
        "arguments": [
          {
            "name": "groupID",
            "value": "5fa668df-a7b0-43fe-828d-48f7a1f7ca44"
          }
        ],
        "description": "Add user to selected groups",
        "displayName": "Add user to groups",
        "isEnabled": true,
        "continueOnError": false,
        "taskDefinitionId": "22085229-5809-45e8-97fd-270d28d66910",
        "category": "joiner,leaver,mover"
      }
    ],
    "executionConditions": {
      "@odata.type": "#microsoft.graph.identityGovernance.onDemandExecutionOnly"
    },
    "isEnabled": true,
    "isSchedulingEnabled": false,
    "administrationScopeTargets": []
  }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-Type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#microsoft.graph.identityGovernance.workflow",
  "category": "mover",
  "description": "On-demand removal of the target scope of a workflow.",
  "displayName": "Remove existing target scope of a workflow",
  "isEnabled": true,
  "isSchedulingEnabled": false,
  "lastModifiedDateTime": "2025-01-09T15:40:14.4514101Z",
  "createdDateTime": "2025-01-09T15:28:24.0565526Z",
  "deletedDateTime": null,
  "id": "394f5831-b1c2-44b3-830d-bbcb88d4ebb0",
  "nextScheduleRunDateTime": null,
  "version": 2,
  "executionConditions": null,
  "lastModifiedBy": {
    "id": "2355df95-8fd8-499c-adcf-4b5f1acf713d"
  },
  "tasks@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/lifecycleWorkflows/workflows('e64ec370-8b6c-4eb7-a692-a07ffa26dc1f')('e64ec370-8b6c-4eb7-a692-a07ffa26dc1f')/tasks",
  "tasks": [
    {
      "category": "mover",
      "continueOnError": false,
      "description": "Send email to notify user’s manager of user move",
      "displayName": "Send email to notify manager of user move",
      "executionSequence": 1,
      "id": "c070b422-17e3-45a2-82a0-42b5a46c2421",
      "isEnabled": true,
      "taskDefinitionId": "aab41899-9972-422a-9d97-f626014578b7",
      "arguments": []
    },
    {
      "category": "joiner,leaver,mover",
      "continueOnError": false,
      "description": "Add user to selected groups",
      "displayName": "Add user to groups",
      "executionSequence": 2,
      "id": "71b576f8-da57-457f-a507-e7b978c56680",
      "isEnabled": true,
      "taskDefinitionId": "22085229-5809-45e8-97fd-270d28d66910",
      "arguments": [
        {
          "name": "groupID",
          "value": "5fa668df-a7b0-43fe-828d-48f7a1f7ca44"
        }
      ],
      "administrationScopeTargets": []
    }
  ],
  "createdBy": {
    "id": "2355df95-8fd8-499c-adcf-4b5f1acf713d"
  }
}