跳转到主要内容
POST
/
v3
/
organizations
/
{org_id}
/
sessions
/
{devin_id}
/
messages
向会话发送消息
curl --request POST \
  --url https://api.devin.ai/v3/organizations/{org_id}/sessions/{devin_id}/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "message": "<string>",
  "attachment_urls": [
    "<string>"
  ],
  "message_as_user_id": "<string>"
}
'
import requests

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

payload = {
"message": "<string>",
"attachment_urls": ["<string>"],
"message_as_user_id": "<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({
message: '<string>',
attachment_urls: ['<string>'],
message_as_user_id: '<string>'
})
};

fetch('https://api.devin.ai/v3/organizations/{org_id}/sessions/{devin_id}/messages', 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/{devin_id}/messages",
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([
'message' => '<string>',
'attachment_urls' => [
'<string>'
],
'message_as_user_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}/sessions/{devin_id}/messages"

payload := strings.NewReader("{\n \"message\": \"<string>\",\n \"attachment_urls\": [\n \"<string>\"\n ],\n \"message_as_user_id\": \"<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/{devin_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message\": \"<string>\",\n \"attachment_urls\": [\n \"<string>\"\n ],\n \"message_as_user_id\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

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

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 \"message\": \"<string>\",\n \"attachment_urls\": [\n \"<string>\"\n ],\n \"message_as_user_id\": \"<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>"
}
]
}
devin_id 是在会话 ID 前加上 devin- 前缀得到的值 (例如,devin-abc123) 。

权限

需要一个在组织级别被授予 ManageOrgSessions 权限的服务用户。

授权

Authorization
string
header
必填

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

路径参数

org_id
string | null
必填

组织 ID(前缀:org-)

示例:

"org-abc123def456"

devin_id
string | null
必填

Devin 会话 ID(前缀:devin-)

示例:

"devin-abc123def456"

请求体

application/json
message
string
必填
attachment_urls
string<uri>[] | null
Required string length: 1 - 2083
message_as_user_id
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