跳转到主要内容
PATCH
/
v3
/
organizations
/
{org_id}
/
schedules
/
{schedule_id}
更新计划
curl --request PATCH \
  --url https://api.devin.ai/v3/organizations/{org_id}/schedules/{schedule_id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "bypass_approval": true,
  "enabled": true,
  "frequency": "<string>",
  "interval_count": 123,
  "name": "<string>",
  "platform": "<string>",
  "playbook_id": "<string>",
  "prompt": "<string>",
  "run_as_user_id": "<string>",
  "scheduled_at": "2023-11-07T05:31:56Z",
  "slack_channel_id": "<string>",
  "slack_team_id": "<string>",
  "tags": [
    "<string>"
  ],
  "target_devin_id": "<string>"
}
'
import requests

url = "https://api.devin.ai/v3/organizations/{org_id}/schedules/{schedule_id}"

payload = {
"bypass_approval": True,
"enabled": True,
"frequency": "<string>",
"interval_count": 123,
"name": "<string>",
"platform": "<string>",
"playbook_id": "<string>",
"prompt": "<string>",
"run_as_user_id": "<string>",
"scheduled_at": "2023-11-07T05:31:56Z",
"slack_channel_id": "<string>",
"slack_team_id": "<string>",
"tags": ["<string>"],
"target_devin_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
bypass_approval: true,
enabled: true,
frequency: '<string>',
interval_count: 123,
name: '<string>',
platform: '<string>',
playbook_id: '<string>',
prompt: '<string>',
run_as_user_id: '<string>',
scheduled_at: '2023-11-07T05:31:56Z',
slack_channel_id: '<string>',
slack_team_id: '<string>',
tags: ['<string>'],
target_devin_id: '<string>'
})
};

fetch('https://api.devin.ai/v3/organizations/{org_id}/schedules/{schedule_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.devin.ai/v3/organizations/{org_id}/schedules/{schedule_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'bypass_approval' => true,
'enabled' => true,
'frequency' => '<string>',
'interval_count' => 123,
'name' => '<string>',
'platform' => '<string>',
'playbook_id' => '<string>',
'prompt' => '<string>',
'run_as_user_id' => '<string>',
'scheduled_at' => '2023-11-07T05:31:56Z',
'slack_channel_id' => '<string>',
'slack_team_id' => '<string>',
'tags' => [
'<string>'
],
'target_devin_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.devin.ai/v3/organizations/{org_id}/schedules/{schedule_id}"

payload := strings.NewReader("{\n \"bypass_approval\": true,\n \"enabled\": true,\n \"frequency\": \"<string>\",\n \"interval_count\": 123,\n \"name\": \"<string>\",\n \"platform\": \"<string>\",\n \"playbook_id\": \"<string>\",\n \"prompt\": \"<string>\",\n \"run_as_user_id\": \"<string>\",\n \"scheduled_at\": \"2023-11-07T05:31:56Z\",\n \"slack_channel_id\": \"<string>\",\n \"slack_team_id\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"target_devin_id\": \"<string>\"\n}")

req, _ := http.NewRequest("PATCH", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.patch("https://api.devin.ai/v3/organizations/{org_id}/schedules/{schedule_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"bypass_approval\": true,\n \"enabled\": true,\n \"frequency\": \"<string>\",\n \"interval_count\": 123,\n \"name\": \"<string>\",\n \"platform\": \"<string>\",\n \"playbook_id\": \"<string>\",\n \"prompt\": \"<string>\",\n \"run_as_user_id\": \"<string>\",\n \"scheduled_at\": \"2023-11-07T05:31:56Z\",\n \"slack_channel_id\": \"<string>\",\n \"slack_team_id\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"target_devin_id\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.devin.ai/v3/organizations/{org_id}/schedules/{schedule_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"bypass_approval\": true,\n \"enabled\": true,\n \"frequency\": \"<string>\",\n \"interval_count\": 123,\n \"name\": \"<string>\",\n \"platform\": \"<string>\",\n \"playbook_id\": \"<string>\",\n \"prompt\": \"<string>\",\n \"run_as_user_id\": \"<string>\",\n \"scheduled_at\": \"2023-11-07T05:31:56Z\",\n \"slack_channel_id\": \"<string>\",\n \"slack_team_id\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"target_devin_id\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "consecutive_failures": 123,
  "created_at": "2023-11-07T05:31:56Z",
  "created_by": "<string>",
  "enabled": true,
  "frequency": "<string>",
  "last_error_at": "2023-11-07T05:31:56Z",
  "last_error_message": "<string>",
  "last_executed_at": "2023-11-07T05:31:56Z",
  "name": "<string>",
  "org_id": "<string>",
  "playbook": {
    "playbook_id": "<string>",
    "title": "<string>"
  },
  "prompt": "<string>",
  "scheduled_session_id": "<string>",
  "updated_at": "2023-11-07T05:31:56Z",
  "bypass_approval": false,
  "interval_count": 1,
  "last_edited_by": "<string>",
  "platform": "<string>",
  "schedule_type": "recurring",
  "scheduled_at": "2023-11-07T05:31:56Z",
  "slack_channel_id": "<string>",
  "slack_team_id": "<string>",
  "tags": [
    "<string>"
  ],
  "target_devin_id": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

权限

需要在组织级别拥有 ManageOrgSchedules 权限的服务账号。

注意事项

所有字段都是可选的。只有请求体中提供的字段会被更新。要禁用某个计划,将 enabled 设置为 false playbook_id 设置为 null 会清除关联的 playbook。 你可以在 recurringone_time 之间更改 schedule_type。当更改为 one_time 时,请提供 scheduled_at,其值必须是将来的 ISO 8601 日期时间。 当更改为 recurring 时,请提供 frequency,其值为有效的 cron 表达式。

执行身份

run_as_user_id 参数控制计划任务以哪个用户身份运行。计划任务被触发时,会在该用户下创建会话——该用户会收到通知,并且该会话会出现在其会话历史中。
  • 设置用户:提供一个有效的用户 ID 来更改执行身份。需要满足:
    1. 服务用户必须具有 ImpersonateOrgSessions 权限
    2. 目标用户必须是该组织的成员
    3. 目标用户必须具有 UseDevinSessions 权限
  • 清除 (设置为 null) :将计划任务恢复为以默认 bot 用户身份运行
  • 省略该字段:保持当前执行身份不变

授权

Authorization
string
header
必填

服务用户凭据(前缀:cog_)

路径参数

schedule_id
string
必填

计划 ID(前缀:sched-)

示例:

"sched-abc123def456"

org_id
string
必填

组织 ID(前缀:org-)

示例:

"org-abc123def456"

请求体

application/json
agent
enum<string> | null
可用选项:
devin,
data_analyst
bypass_approval
boolean | null
enabled
boolean | null
frequency
string | null
interval_count
integer | null
name
string | null
notify_on
enum<string> | null
可用选项:
always,
failure,
never
platform
string | null

此计划创建的 session 所使用的 VM 平台(例如 'windows')。省略时,平台保持不变。该值必须与为组织配置的平台匹配(不区分大小写);未知值会被拒绝,并返回 400,同时列出可用的平台标签。

playbook_id
string | null
prompt
string | null
run_as_user_id
string | null

设置此计划将以哪个用户 ID 运行。需要 ImpersonateOrgSessions 权限。设为 null 会恢复为默认机器人用户。省略该字段则保持当前身份不变。

schedule_type
enum<string> | null
可用选项:
recurring,
one_time
scheduled_at
string<date-time> | null
slack_channel_id
string | null
slack_team_id
string | null
tags
string[] | null
target_devin_id
string | null

响应

成功响应

agent
enum<string>
必填
可用选项:
devin,
data_analyst
consecutive_failures
integer
必填
created_at
string<date-time>
必填
created_by
string | null
必填
enabled
boolean
必填
frequency
string | null
必填
last_error_at
string<date-time> | null
必填
last_error_message
string | null
必填
last_executed_at
string<date-time> | null
必填
name
string
必填
notify_on
enum<string>
必填
可用选项:
always,
failure,
never
org_id
string
必填
playbook
PlaybookInfo · object | null
必填
prompt
string
必填
scheduled_session_id
string
必填
updated_at
string<date-time>
必填
bypass_approval
boolean
默认值:false
interval_count
integer
默认值:1
last_edited_by
string | null
platform
string | null
schedule_type
enum<string>
默认值:recurring
可用选项:
recurring,
one_time
scheduled_at
string<date-time> | null
slack_channel_id
string | null
slack_team_id
string | null
tags
string[] | null
target_devin_id
string | null