OpenAI 创建组织邀请
创建邀请
post /organization/invites
为用户创建加入组织的邀请。用户必须接受邀请后,才能访问该组织。
请求体参数
内容类型:application/json
email: string
向此地址发送电子邮件。
role: "reader" or "owner"
owner(所有者)或 reader(读取者)。
"reader"
"owner"
projects: optional array of object { id, role }
一个项目数组:用户接受组织邀请时,会同时获得这些项目的成员身份。省略时,为兼容旧版行为,会邀请用户加入默认项目;传入空数组时,则不会邀请用户加入任何项目,包括默认项目。
id: string
项目的公开 ID。
role: "member" or "owner"
项目成员角色。
"member"
"owner"
返回值
Invite object { id, created_at, email, 6 more }
表示发往组织的单个 invite(邀请)。
id: string
标识符,可在 API 端点中引用。
created_at: integer
邀请发送时间的 Unix 时间戳,单位为秒。
format: unixtime
email: string
邀请接收者的电子邮件地址。
object: "organization.invite"
对象类型,固定为 organization.invite。
"organization.invite"
projects: array of object { id, role }
接受邀请时获授成员身份的项目。
id: string
项目的公开 ID。
role: "member" or "owner"
项目成员角色。
"member"
"owner"
role: "owner" or "reader"
owner(所有者)或 reader(读取者)。
"owner"
"reader"
status: "accepted" or "expired" or "pending"
accepted(已接受)、expired(已过期)或 pending(待接受)。
"accepted"
"expired"
"pending"
accepted_at: optional integer or null
邀请接受时间的 Unix 时间戳,单位为秒。
format: unixtime
expires_at: optional integer or null
邀请过期时间的 Unix 时间戳,单位为秒。
format: unixtime
示例
## 从环境变量读取管理员密钥;组织邀请ID和示例电子邮件地址应替换为实际值
curl https://api.openai.com/v1/organization/invites \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-d '{
"email": "email",
"role": "reader"
}'
200 — 示例
译注:官方通用请求示例的组织角色为 reader,通用响应示例却为 owner,状态为 accepted。此处保留原例以展示字段结构,不将其视作同一次真实调用的结果;后面的具体示例另行展示。
以下 JSON 展示返回字段;字段名、对象类型、角色、状态和标识符按原文保留。
{
"id": "id",
"created_at": 0,
"email": "email",
"object": "organization.invite",
"projects": [
{
"id": "id",
"role": "member"
}
],
"role": "owner",
"status": "accepted",
"accepted_at": 0,
"expires_at": 0
}
示例
## 从环境变量读取管理员密钥;组织邀请ID和示例电子邮件地址应替换为实际值
curl -X POST https://api.openai.com/v1/organization/invites \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{
"email": "anotheruser@example.com",
"role": "reader",
"projects": [
{
"id": "project-xyz",
"role": "member"
},
{
"id": "project-abc",
"role": "owner"
}
]
}'
响应示例
以下为对应请求的响应示例。
{
"object": "organization.invite",
"id": "invite-def",
"email": "anotheruser@example.com",
"role": "reader",
"status": "pending",
"created_at": 1711471533,
"expires_at": 1711471533,
"accepted_at": null,
"projects": [
{
"id": "project-xyz",
"role": "member"
},
{
"id": "project-abc",
"role": "owner"
}
]
}
TRAE-AI编程


更多建议: