Create invite
client.Admin.Organization.Invites.New(ctx, body) (*Invite, error)
POST/organization/invites
Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization.
Create invite
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAdminAPIKey("My Admin API Key"),
)
invite, err := client.Admin.Organization.Invites.New(context.TODO(), openai.AdminOrganizationInviteNewParams{
Email: "email",
Role: openai.AdminOrganizationInviteNewParamsRoleReader,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", invite.ID)
}
{
"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"
}
]
}
Returns Examples
{
"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"
}
]
}