Updated on 2025-07-28 GMT+08:00

Using APIs to Call a Workflow

After the trial run of a workflow is successful, you can call the workflow through APIs.

Obtaining the Call Path

To obtain the call path of a workflow, perform the following steps:

  1. Log in to ModelArts Studio and choose Agent Dev in the navigation pane.
  2. On the Workbench page, click the Workflows tab. Click and choose Call Path of the required workflow.
    Figure 1 Obtaining the call path of a workflow (1)

  3. In the Call Path dialog box, click Copy Path.

    The conversation_id parameter indicates the session ID, which uniquely identifies a session. You can set the session ID to any value in the standard UUID format. For example, conversation_id in the following figure can be replaced with 550e8400-e29b-41d4-a716-446655440000.

    Figure 2 Obtaining the call path of a workflow (2)

Obtaining a Token

Obtain the token by following the instructions provided in section "Calling REST APIs" > "Authentication" in API Reference.

Using Postman to Call APIs

  1. Create a POST request in Postman and enter the workflow call path. For details, see Obtaining the Call Path.
  2. Set the request header parameters.
    • KEY: Content-Type; VALUE: application/json
    • The header parameter X-Auth-Token is mandatory, and the parameter value is the token obtained in Obtaining a Token.
    Figure 3 Configuring the request header
  3. In Postman, choose Body > raw. The following is an example of configuring the request body:
    The inputs parameter is a question raised by the user, and is used as an input of the workflow. If the workflow has a plug-in, add the plugin_configs parameter. The plugin_id parameter indicates the plug-in ID. For details about how to obtain the plug-in ID, see Managing Plug-ins.
    Request with plug-ins
    { 
      "inputs": {
        "query": "Hello"
      },
      "plugin_configs": [
        {
          "plugin_id": "xxxxxxxxx",
          "config": {
            "key": "value"
          }
        }
      ]
    }
    Request without a plug-in
    { 
      "inputs": {
        "query": "Introduce Beijing."
      }
    }
  4. Click Send on Postman to send the request. If status code 200 is returned, the API is successfully called.

    The following is an example of a workflow with a Questioner node:

    {
        "conversation_id": "2c90493f-803d-431d-a197-57543d414317",
        "messages": [
            {
                "role": "assistant",
                "content": "Hello"
            }
        ],
        "status": {
            "code": 1,
            "desc": "succeeded"
        },
        "start_time": 1734336269313,
        "end_time": 1734336270908
    }

    The following is an example of a workflow without a Questioner node:

    {
        "conversation_id": "2c90493f-803d-431d-a197-57543d414317",
        "outputs": {
            "responseContent": "Hello. How can I help you?"
        },
        "messages": [],
        "status": {
            "code": 1,
            "desc": "succeeded"
        },
        "start_time": 1734337068533,
        "end_time": 1734337082545
    }