设置用户的计费组织
curl --request PUT \
--url https://api.devin.ai/v3/enterprise/members/users/billing-orgs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assignments": [
{
"billing_org_id": "<string>",
"user_id": "<string>"
}
]
}
'import requests
url = "https://api.devin.ai/v3/enterprise/members/users/billing-orgs"
payload = { "assignments": [
{
"billing_org_id": "<string>",
"user_id": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({assignments: [{billing_org_id: '<string>', user_id: '<string>'}]})
};
fetch('https://api.devin.ai/v3/enterprise/members/users/billing-orgs', 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/enterprise/members/users/billing-orgs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'assignments' => [
[
'billing_org_id' => '<string>',
'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/enterprise/members/users/billing-orgs"
payload := strings.NewReader("{\n \"assignments\": [\n {\n \"billing_org_id\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.devin.ai/v3/enterprise/members/users/billing-orgs")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assignments\": [\n {\n \"billing_org_id\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devin.ai/v3/enterprise/members/users/billing-orgs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"assignments\": [\n {\n \"billing_org_id\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"assigned": [
{
"billing_org_id": "<string>",
"user_id": "<string>"
}
],
"failed": [
{
"billing_org_id": "<string>",
"reason": "user_not_found",
"user_id": "<string>"
}
]
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}用户与成员资格(企业版)
设置用户的计费组织
为最多 100 个用户设置计费组织。
仅更改所提交用户的设置。即使部分分配无效,有效分配仍会一并保存,因此 200 响应中也可能包含失败项:请务必检查 failed。
错误响应表示未保存任何更改。重新提交分配会覆盖用户当前的计费组织,并新增一条审计日志记录。
PUT
/
v3
/
enterprise
/
members
/
users
/
billing-orgs
设置用户的计费组织
curl --request PUT \
--url https://api.devin.ai/v3/enterprise/members/users/billing-orgs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assignments": [
{
"billing_org_id": "<string>",
"user_id": "<string>"
}
]
}
'import requests
url = "https://api.devin.ai/v3/enterprise/members/users/billing-orgs"
payload = { "assignments": [
{
"billing_org_id": "<string>",
"user_id": "<string>"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({assignments: [{billing_org_id: '<string>', user_id: '<string>'}]})
};
fetch('https://api.devin.ai/v3/enterprise/members/users/billing-orgs', 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/enterprise/members/users/billing-orgs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'assignments' => [
[
'billing_org_id' => '<string>',
'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/enterprise/members/users/billing-orgs"
payload := strings.NewReader("{\n \"assignments\": [\n {\n \"billing_org_id\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.devin.ai/v3/enterprise/members/users/billing-orgs")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assignments\": [\n {\n \"billing_org_id\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devin.ai/v3/enterprise/members/users/billing-orgs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"assignments\": [\n {\n \"billing_org_id\": \"<string>\",\n \"user_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"assigned": [
{
"billing_org_id": "<string>",
"user_id": "<string>"
}
],
"failed": [
{
"billing_org_id": "<string>",
"reason": "user_not_found",
"user_id": "<string>"
}
]
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"error_code": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}通过一次请求为最多 100 个用户设置计费组织。仅更改你提交的用户,企业中的其他用户不受影响。如需逐个设置单个用户,也可使用 beta 版用户设置端点,该端点同样接受
今后可能会新增原因值,因此请将未知值作为失败项处理,而不是视为错误。
错误响应 (
billing_org_id。
部分成功
即使同一请求中的其他行无效,有效的分配仍会一并保存,因此200 响应中也可能包含失败项。请务必检查 failed:其中每个条目都会列出用户、所请求的组织以及 reason。这些用户的计费组织不会发生变化;请修正相应的行后重新发送。
reason | 含义 |
|---|---|
user_not_found | 该用户不是该企业的成员 (既不是直接成员,也未通过身份提供商组加入) 。 |
org_not_found | 该组织不属于此企业。 |
user_not_org_member | 该组织不是企业的主组织,且该用户不是该组织的成员。 |
4xx 或 5xx) 表示请求中的所有内容均未保存。不包含任何分配、分配数超过 100 个,或同一 user_id 出现多次的请求将被拒绝,并返回 422。
重新发送某个分配会覆盖该用户当前的计费组织,并额外生成一条审计日志条目,因此重复调用是安全的,但并非毫无代价。
权限
需要一个在企业级别同时具有ManageBilling 和 ViewOrganizations 权限的服务用户或个人访问令牌。ManageOrganizations 已包含 ViewOrganizations,因此同样满足该要求。请求体
application/json

