Copy.ai
  1. 工作流程运行
Copy.ai
  • Copy.ai 工作流程 API 入门
  • API 接口
    • 身份验证
    • WEBHOOKS
      • 注册 Webhook
      • 获取 Webhook
      • 获取所有 Webhook
      • 删除 Webhook
    • 工作流程运行
      • 开始工作流程运行
        POST
      • 获取工作流运行
        GET
      • 获取所有工作流程运行
        GET
  1. 工作流程运行

开始工作流程运行

开发环境
http://dev-cn.your-api-server.com
开发环境
http://dev-cn.your-api-server.com
POST
https://api.copy.ai/api/workflow/{workflow_id}/run

这个页面将帮助你开始执行工作流运行。
要开始运行一个工作流,发送一个POST请求到 https://api.copy.ai/api/workflow/<workflow_id>/run ,请求体为包含运行起始值的JSON数据。

开始工作流程运行

要启动工作流程运行,请发送 POST 请求,其中包含包含运行起始值的 JSON 正文。<https://api.copy.ai/api/workflow/><workflow_id>/run

例如:

JSON

{
  "startVariables": {
	  "Input 1": "<Inputs vary depending on the workflow used.>",
	  "Input 2": "<The best way to see an example is to try it!>"
	},
	"metadata": {
    "api": true  /* example optional metadata to set on the workflow run */
	}
}

您将收到包含已启动工作流程运行的 ID 的响应:

JSON

{
  "status": "success",
  "data": {
    "id": "<run_id>"
  }
}

此 ID 可用于跟踪工作流运行的进度,并且在运行完成时也将包含在 Webhook 请求中。

跟踪/民意调查进度

要跟踪工作流程运行,请将 GET 请求发送到。您将收到以下格式的回复:<https://api.copy.ai/api/workflow/><workflow_id>/run/<run_id>

JSON

{
    "status": "success",
    "data":
    {
        "id": "<run_id>",
        "input":
        { 
          	"Input 1": "Inputs vary depending on the workflow used.",
			      "Input 2": "The best way to see an example is to try it!" 
        },
        "status": "PROCESSING",
        "output":
        {
            "Output 1": "<Outputs vary depending on the workflow used.>",
						"Output 2": "<The best way to see an example is to try it!>"
        },
        "createdAt": "2022-11-18T20:30:07.434Z"
    }
}

要了解有关工作流程运行详细信息和可用状态的更多信息,请访问此页面:获取工作流程运行

运行完成

运行完成后,状态将更改为,我们将向任何已注册以接收工作流完成事件的 Webhook 发送 POST 请求。COMPLETE

请求示例:

JSON

{
    "type": "workflowRun.completed",
    "workflowRunId": "<run_id>",
    "workflowId": "<workflow_id>",
    "result":
    {
      "Output 1": "<Outputs vary depending on the workflow used.>",
			"Output 2": "<The best way to see an example is to try it!>"
    },
    "metadata":
    {
      /* any metadata set on the workflow run */
    },
    "credits": 2 
}

要了解有关注册 Webhook 的更多信息,请参阅此页面:注册 Webhook

请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.copy.ai/api/workflow//run' \
--header 'x-copy-ai-api-key: key goes here' \
--header 'x-copy-ai-api-key;' \
--header 'content-type: application/json' \
--data-raw '{
  "metadata": {
    "api": true
  }
}'
响应示例响应示例
200 - 成功示例
{
  status:"success",
  data: {id:"some-UUID-1234"}
}

请求参数

Path 参数
workflow_id
string 
工作流程ID
必需
Header 参数
content-type
string 
必需
示例值:
application/json
x-copy-ai-api-key
string 
必需
示例值:
key goes here
Body 参数application/json
metadata
object 
可选
包含要在工作流运行时存储和返回的元数据的 JSON 对象。
api
boolean 
必需
startVariables
string 
必需
包含工作流程的所有启动变量的 JSON 对象。
示例

返回响应

🟢200成功
application/json
Body
status
string 
必需
data
object 
必需
id
string 
必需
🟠400请求有误
🟠404记录不存在
🟠422参数错误
修改于 2023-12-26 09:51:33
上一页
删除 Webhook
下一页
获取工作流运行
Built with