logo
การพัฒนา
ค้นหา
Run Workflow

Run Workflow

After enabling the Workflow API and creating an API key, you can run workflows by making API requests with parameters and retrieve the execution results.

Request Method

POST

Endpoint

https://api-{endpoint}.gptbots.ai/v1/workflow/invoke

Request Authentication

Please refer to Overview in API Reference.

Request

Request Example

curl -X POST 'https://api-{endpoint}.gptbots.ai/v1/workflow/invoke' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "userId": "<your_user_id>", "input": { <your_start> } }'
                      
                      curl -X POST 'https://api-{endpoint}.gptbots.ai/v1/workflow/invoke' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
    "userId": "<your_user_id>",
    "input": {
        <your_start>
    }
}'

                    
บล็อกโค้ดนี้ในหน้าต่างลอย

Request Headers

Field Type Required Description
Authorization Bearer ${API Key} Use Authorization: Bearer ${API Key} for authentication. Get API key from API Key page.
Content-Type application/json Yes Data type, set to application/json.

Request Parameters

Field Type Required Description
userId string No Serves as an identifier of the initiator of this request.
input object Yes Represents the Start node of the workflow. The parameters in this field must match the parameters specified in the Start node of the workflow.

Response

Response Example

{ "workflowId": "xxxxxxxx", "workflowName": "todayNews", "workflowVersion": "9", "workflowRunId": "xxxxxxxx", "input": { "topic": "hi" }, "output": { "news": [ { "summary": "Fatal crash shuts down major highway in Haleiwa. According to Emergency Medical Services, paramedics responded to the scene of the crash Wednesday morning.", "media": "Hawaii News Now", "title": "Hawaii News Now - Breaking News, Latest News, Weather & Traffic" }, { "summary": "Hawaii Crime: Man, 65, critically injured in Waikīkī assault. Jamil Hart found guilty in Mililani murder case. HPD busts illegal gambling room in Nanakuli.", "media": "KHON2", "title": "KHON2: Hawaii News, Weather, Sports, Breaking News & Live" }, { "summary": "Man left with serious injuries after being hit by car in Hawaii Kai. Holomua brush fire 50% contained; 380 acres burned. Haleiwa collision claims one life.", "media": "KITV 4", "title": "KITV 4 Island News | Honolulu, HI News & Weather" }, { "summary": "Hawaii news daily. In-depth reporting on breaking news and more for Honolulu, Big Island, Maui and Kauai counties. No paywall.", "media": "Honolulu Civil Beat", "title": "Hawaii News: In-Depth Local News From Honolulu Civil Beat" }, { "summary": "Breaking News: Man, 21, dies in crash on J.P. Leong Highway in Haleiwa. Gunman inscribed 'ANTI-ICE' on bullet before fatal Dallas attack. Man, 44, dies after...", "media": "Honolulu Star-Advertiser", "title": "Honolulu Star-Advertiser: Hawaii News, Breaking News & Top Stories" } ] }, "workflowExecutionTime": 8347, "status": "SUCCEED", "totalCost": 0.6928, "totalTokens": 1745, "startTime": 1758765323024, "endTime": 1758765331373 }
                      
                      {
    "workflowId": "xxxxxxxx",
    "workflowName": "todayNews",
    "workflowVersion": "9",
    "workflowRunId": "xxxxxxxx",
    "input": {
        "topic": "hi"
    },
    "output": {
        "news": [
            {
                "summary": "Fatal crash shuts down major highway in Haleiwa. According to Emergency Medical Services, paramedics responded to the scene of the crash Wednesday morning.",
                "media": "Hawaii News Now",
                "title": "Hawaii News Now - Breaking News, Latest News, Weather & Traffic"
            },
            {
                "summary": "Hawaii Crime: Man, 65, critically injured in Waikīkī assault. Jamil Hart found guilty in Mililani murder case. HPD busts illegal gambling room in Nanakuli.",
                "media": "KHON2",
                "title": "KHON2: Hawaii News, Weather, Sports, Breaking News & Live"
            },
            {
                "summary": "Man left with serious injuries after being hit by car in Hawaii Kai. Holomua brush fire 50% contained; 380 acres burned. Haleiwa collision claims one life.",
                "media": "KITV 4",
                "title": "KITV 4 Island News | Honolulu, HI News & Weather"
            },
            {
                "summary": "Hawaii news daily. In-depth reporting on breaking news and more for Honolulu, Big Island, Maui and Kauai counties. No paywall.",
                "media": "Honolulu Civil Beat",
                "title": "Hawaii News: In-Depth Local News From Honolulu Civil Beat"
            },
            {
                "summary": "Breaking News: Man, 21, dies in crash on J.P. Leong Highway in Haleiwa. Gunman inscribed 'ANTI-ICE' on bullet before fatal Dallas attack. Man, 44, dies after...",
                "media": "Honolulu Star-Advertiser",
                "title": "Honolulu Star-Advertiser: Hawaii News, Breaking News & Top Stories"
            }
        ]
    },
    "workflowExecutionTime": 8347,
    "status": "SUCCEED",
    "totalCost": 0.6928,
    "totalTokens": 1745,
    "startTime": 1758765323024,
    "endTime": 1758765331373
}

                    
บล็อกโค้ดนี้ในหน้าต่างลอย

Response Parameters

Field Type Description
workflowId string Workflow ID.
workflowName string Workflow name.
workflowVersion string Workflow version.
workflowRunId string Operation ID of the workflow, serving as the unique identifier for this execution.
input object Input content of the Start node. This must match the content of the "input field" in the Request.
output object Output content of the End node. This will also show the workflow's execution result.
workflowExecutionTime number Time taken for executing the workflow (Unit: ms).
status string The integration status of the workflow. Possible values inlude: * SUCCED:Successful integration * FAILED:Failed integration * RUNNING:Running workflow
totalCost number Total credits consumed (consumption of all nodes); unit: credit.
totalTokens number Total Token consumed (consumption of all nodes)
startTime number Timestamp of action start (unit: ms)
endTime number Timestamp of action end (unit: ms)