Copy.ai 工作流程 API 入门
概述
验证
x-copy-ai-api-key
查找您的工作流程 ID
workflow_id
workflow_id
显示在API端点字段的URL中。它通常以PKGW-
开头。
网络钩子注册
https://api.copy.ai/api/webhookJSON
主体包含您的webhook URL、要通知的事件类型以及可选的工作流ID。{
"url": "<https://mywebsite.com/webhook>",
"eventType": "workflowRun.completed",
"workflowId": "<my-workflow-id>"
}
{
"status": "success",
"data": {
"id": "<id of webhook>",
"url": "<https://mywebsite.com/webhook>",
"eventType": "workflowRun.completed",
"workflowId": "<my-workflow-id>"
}
}
开始工作流程运行
<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 */
}
}
{
"status": "success",
"data": {
"id": "<run_id>"
}
}
跟踪/民意调查进度
<https://api.copy.ai/api/workflow/><workflow_id>/run/<run_id>。
您将收到以下格式的回复:{
"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"
}
}
运行完成
complete
,我们将向注册的任何 webhook 发送 POST 请求,以接收工作流的完成事件。{
"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
}
修改于 2023-12-26 09:12:59