跳转到主要内容
POST
/
v3
/
organizations
/
{org_id}
/
sessions
创建会话
curl --request POST \
  --url https://api.devin.ai/v3/organizations/{org_id}/sessions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "<string>",
  "attachment_urls": [
    "<string>"
  ],
  "bypass_approval": true,
  "child_playbook_id": "<string>",
  "create_as_user_id": "<string>",
  "knowledge_ids": [
    "<string>"
  ],
  "max_acu_limit": 123,
  "platform": "<string>",
  "playbook_id": "<string>",
  "repos": [
    "<string>"
  ],
  "resumable": true,
  "secret_ids": [
    "<string>"
  ],
  "session_links": [
    "<string>"
  ],
  "session_secrets": [
    {
      "key": "<string>",
      "value": "<string>",
      "sensitive": true
    }
  ],
  "structured_output_required": true,
  "structured_output_schema": {},
  "tags": [
    "<string>"
  ],
  "title": "<string>"
}
'
import requests

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

payload = {
"prompt": "<string>",
"attachment_urls": ["<string>"],
"bypass_approval": True,
"child_playbook_id": "<string>",
"create_as_user_id": "<string>",
"knowledge_ids": ["<string>"],
"max_acu_limit": 123,
"platform": "<string>",
"playbook_id": "<string>",
"repos": ["<string>"],
"resumable": True,
"secret_ids": ["<string>"],
"session_links": ["<string>"],
"session_secrets": [
{
"key": "<string>",
"value": "<string>",
"sensitive": True
}
],
"structured_output_required": True,
"structured_output_schema": {},
"tags": ["<string>"],
"title": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: '<string>',
attachment_urls: ['<string>'],
bypass_approval: true,
child_playbook_id: '<string>',
create_as_user_id: '<string>',
knowledge_ids: ['<string>'],
max_acu_limit: 123,
platform: '<string>',
playbook_id: '<string>',
repos: ['<string>'],
resumable: true,
secret_ids: ['<string>'],
session_links: ['<string>'],
session_secrets: [{key: '<string>', value: '<string>', sensitive: true}],
structured_output_required: true,
structured_output_schema: {},
tags: ['<string>'],
title: '<string>'
})
};

fetch('https://api.devin.ai/v3/organizations/{org_id}/sessions', 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}/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'attachment_urls' => [
'<string>'
],
'bypass_approval' => true,
'child_playbook_id' => '<string>',
'create_as_user_id' => '<string>',
'knowledge_ids' => [
'<string>'
],
'max_acu_limit' => 123,
'platform' => '<string>',
'playbook_id' => '<string>',
'repos' => [
'<string>'
],
'resumable' => true,
'secret_ids' => [
'<string>'
],
'session_links' => [
'<string>'
],
'session_secrets' => [
[
'key' => '<string>',
'value' => '<string>',
'sensitive' => true
]
],
'structured_output_required' => true,
'structured_output_schema' => [

],
'tags' => [
'<string>'
],
'title' => '<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}/sessions"

payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"attachment_urls\": [\n \"<string>\"\n ],\n \"bypass_approval\": true,\n \"child_playbook_id\": \"<string>\",\n \"create_as_user_id\": \"<string>\",\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"max_acu_limit\": 123,\n \"platform\": \"<string>\",\n \"playbook_id\": \"<string>\",\n \"repos\": [\n \"<string>\"\n ],\n \"resumable\": true,\n \"secret_ids\": [\n \"<string>\"\n ],\n \"session_links\": [\n \"<string>\"\n ],\n \"session_secrets\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\",\n \"sensitive\": true\n }\n ],\n \"structured_output_required\": true,\n \"structured_output_schema\": {},\n \"tags\": [\n \"<string>\"\n ],\n \"title\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", 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.post("https://api.devin.ai/v3/organizations/{org_id}/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"attachment_urls\": [\n \"<string>\"\n ],\n \"bypass_approval\": true,\n \"child_playbook_id\": \"<string>\",\n \"create_as_user_id\": \"<string>\",\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"max_acu_limit\": 123,\n \"platform\": \"<string>\",\n \"playbook_id\": \"<string>\",\n \"repos\": [\n \"<string>\"\n ],\n \"resumable\": true,\n \"secret_ids\": [\n \"<string>\"\n ],\n \"session_links\": [\n \"<string>\"\n ],\n \"session_secrets\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\",\n \"sensitive\": true\n }\n ],\n \"structured_output_required\": true,\n \"structured_output_schema\": {},\n \"tags\": [\n \"<string>\"\n ],\n \"title\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"attachment_urls\": [\n \"<string>\"\n ],\n \"bypass_approval\": true,\n \"child_playbook_id\": \"<string>\",\n \"create_as_user_id\": \"<string>\",\n \"knowledge_ids\": [\n \"<string>\"\n ],\n \"max_acu_limit\": 123,\n \"platform\": \"<string>\",\n \"playbook_id\": \"<string>\",\n \"repos\": [\n \"<string>\"\n ],\n \"resumable\": true,\n \"secret_ids\": [\n \"<string>\"\n ],\n \"session_links\": [\n \"<string>\"\n ],\n \"session_secrets\": [\n {\n \"key\": \"<string>\",\n \"value\": \"<string>\",\n \"sensitive\": true\n }\n ],\n \"structured_output_required\": true,\n \"structured_output_schema\": {},\n \"tags\": [\n \"<string>\"\n ],\n \"title\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "acus_consumed": 123,
  "created_at": 123,
  "org_id": "<string>",
  "pull_requests": [
    {
      "pr_state": "<string>",
      "pr_url": "<string>"
    }
  ],
  "session_id": "<string>",
  "tags": [
    "<string>"
  ],
  "updated_at": 123,
  "url": "<string>",
  "child_session_ids": [
    "<string>"
  ],
  "is_archived": false,
  "parent_session_id": "<string>",
  "playbook_id": "<string>",
  "service_user_id": "<string>",
  "structured_output": {},
  "subcategory": "<string>",
  "title": "<string>",
  "user_id": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

权限

需要在组织级别具备 ManageOrgSessions 权限的服务用户账号。

高级功能的额外权限

功能所需权限
create_as_user_idImpersonateOrgSessions

Devin 模式

devin_mode 参数用于控制会话使用哪种 Devin Agent 模式:
模式说明
normal默认 Agent 模式。速度快,并且擅长长周期规划。
fast速度约快 2 倍,价格贵 4 倍,智能水平相同。
如果省略此参数,会话将使用组织的默认模式。快速模式与 Web 应用一样,受相同的功能开关和企业版 Agent 预览限制约束。

用户模拟

create_as_user_id 参数允许代表其他用户创建会话。前提条件如下:
  1. 服务用户必须具有 ImpersonateOrgSessions 权限
  2. 目标用户必须是该组织的成员
  3. 目标用户必须具有 UseDevinSessions 权限

授权

Authorization
string
header
必填

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

路径参数

org_id
string | null
必填

组织 ID(前缀:org-)

示例:

"org-abc123def456"

查询参数

devin_id
string | null

请求体

application/json
prompt
string
必填
attachment_urls
string<uri>[] | null
Required string length: 1 - 2083
bypass_approval
boolean | null
child_playbook_id
string | null
create_as_user_id
string | null
devin_mode
enum<string> | null

覆盖该会话的 Devin Agent mode。normal 使用默认 Agent mode,fast 使用 Fast mode,lite 使用 Devin Lite,ultra 使用 Devin Ultra,fusion 使用 Fusion。预览模式受与 web app 相同的功能开关和 Enterprise Agent preview 限制。

可用选项:
normal,
fast,
lite,
ultra,
fusion
knowledge_ids
string[] | null
max_acu_limit
integer | null
platform
string | null

覆盖会话的 VM 平台(例如“windows”)。如果省略(或设为“inherit”),由父级 Devin 创建的会话会继承父级的平台;否则使用组织默认平台。该值必须与你的组织已配置的平台之一匹配(不区分大小写);如果值无法识别,则会返回 400,且错误响应体中会列出该组织可用的平台标签。

playbook_id
string | null
repos
string[] | null
resumable
boolean
默认值:true

是否在会话停止后保留其虚拟机状态,以便后续恢复会话。对于一次性会话,请将其设为 false。

secret_ids
string[] | null
session_secrets
SessionSecretInput · object[] | null
structured_output_required
boolean | null

为 true 时(默认),Agent 必须在当前轮次结束前调用 provide_structured_output,且 is_final=true。为 false 时,该工具可用但非必需——不保证会在某一轮次中被调用。

structured_output_schema
Structured Output Schema · object | null

用于验证结构化输出的 JSON Schema(Draft 7),最大 64KB。必须是自包含的(不允许外部 $ref)。

tags
string[] | null
title
string | null

响应

成功响应

acus_consumed
number
必填
created_at
integer
必填
org_id
string
必填
pull_requests
SessionPullRequest · object[]
必填
session_id
string
必填
status
enum<string>
必填
可用选项:
new,
claimed,
running,
exit,
error,
suspended,
resuming
tags
string[]
必填
updated_at
integer
必填
url
string
必填
category
enum<string> | null

如果已完成分类,则为会话分配的用例类别。仅在 get/list 端点中返回。

可用选项:
bug_fixing,
ci_cd_and_devops,
code_quality_and_security,
code_review,
code_review_and_analysis,
data_and_automation,
documentation_and_content,
feature_development,
migrations_and_upgrades,
other,
refactoring_and_optimization,
research_and_exploration,
security,
unit_test_generation
child_session_ids
string[] | null
is_archived
boolean
默认值:false
origin
enum<string> | null

该会话的创建来源。

可用选项:
webapp,
slack,
teams,
api,
linear,
jira,
automation,
cli,
desktop,
code_scan,
other
parent_session_id
string | null
playbook_id
string | null
service_user_id
string | null
status_detail
enum<string> | null

会话当前状态的附加信息。当 status 为“running”时:可为“working”(正在处理)、“waiting_for_user”(需要用户输入)、“waiting_for_approval”(在安全模式下等待操作批准)或“finished”(任务已完成)。当 status 为“suspended”时:表示挂起原因,例如“inactivity”“user_request”“usage_limit_exceeded”“out_of_credits”“out_of_quota”“no_quota_allocation”“payment_declined”“org_usage_limit_exceeded”“total_session_limit_exceeded”或“error”。仅在 get/list 端点中返回。

可用选项:
working,
waiting_for_user,
waiting_for_approval,
finished,
inactivity,
user_request,
usage_limit_exceeded,
out_of_credits,
out_of_quota,
no_quota_allocation,
payment_declined,
org_usage_limit_exceeded,
total_session_limit_exceeded,
error
structured_output
Structured Output · object | null

来自会话的已验证结构化输出。仅在 GET/LIST 端点中返回。

subcategory
string | null

为会话分配的子类别显示名称。若已设置类别但未分配或未解析出子类别,则为“Other”。仅在 get/list 端点中返回。

title
string | null
user_id
string | null