Skip to content
Primary navigation

Create invite

client.admin.organization.invites.create(InviteCreateParams { email, role, projects } body, RequestOptionsoptions?): Invite { id, created_at, email, 6 more }
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.

ParametersExpand Collapse
body: InviteCreateParams { email, role, projects }
email: string

Send an email to this address

role: "reader" | "owner"

owner or reader

One of the following:
"reader"
"owner"
projects?: Array<Project>

An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior.

id: string

Project’s public ID

role: "member" | "owner"

Project membership role

One of the following:
"member"
"owner"
ReturnsExpand Collapse
Invite { id, created_at, email, 6 more }

Represents an individual invite to the organization.

id: string

The identifier, which can be referenced in API endpoints

created_at: number

The Unix timestamp (in seconds) of when the invite was sent.

formatunixtime
email: string

The email address of the individual to whom the invite was sent

object: "organization.invite"

The object type, which is always organization.invite

projects: Array<Project>

The projects that were granted membership upon acceptance of the invite.

id: string

Project’s public ID

role: "member" | "owner"

Project membership role

One of the following:
"member"
"owner"
role: "owner" | "reader"

owner or reader

One of the following:
"owner"
"reader"
status: "accepted" | "expired" | "pending"

accepted,expired, or pending

One of the following:
"accepted"
"expired"
"pending"
accepted_at?: number | null

The Unix timestamp (in seconds) of when the invite was accepted.

formatunixtime
expires_at?: number | null

The Unix timestamp (in seconds) of when the invite expires.

formatunixtime

Create invite

import OpenAI from 'openai';

const client = new OpenAI({
  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted
});

const invite = await client.admin.organization.invites.create({ email: 'email', role: 'reader' });

console.log(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"
    }
  ]
}