Create an invitation
Creates an invitation for a project, or replaces an existing one, and returns the invitation and its one-shot link.
Send type and the object named after it. project_member takes
relation (viewer, editor or admin). team_member takes team_id
and role, and answers 501 not_implemented until team invitations
ship. Optional metadata.name (1–200 characters) labels who the link is
for. Optional replaces_invitation_id replaces that invitation: the new
row keeps the original's journey_id, and the original is deleted in the
same transaction unless it was accepted.
The link appears only in this response. Share it out of band; whoever
opens it and is signed in can redeem the role. It expires in 72 hours.
Refused for an unclaimed project, on a server without a platform project,
and when the project already has 100 pending unexpired invitations.
Authenticate with a project secret (oauth2) or a console session cookie
(sessionCookie). Creation needs the same project admin check as
createGrant (POST /grants). Cookie requests follow that scheme's CSRF
rules.
AuthorizationBearer <token>Scope: project.write
project_id*stringThe project ID: the id that createProject (POST /projects) returns. zitadel setup prints
it as "Project id" in its summary and as project_id with --json, and
writes it to .env.local as ZITADEL_PROJECT_ID.
^[a-zA-Z0-9_-]+$application/json- body
Creates a project-member invitation, or replaces an existing one.
metadata?Optional label for who the link is for. Displayed only; never matched.
replaces_invitation_id?invitation-idWhen set, this create replaces that invitation: the new invitation keeps
the original's journey_id and, without metadata of its own, the
original's metadata. The original is deleted in the same transaction. An
accepted invitation cannot be replaced. Use the id that
createInvitation (POST /invitations) or listInvitations
(GET /invitations) returns.
^[a-zA-Z0-9_-]+$type*"project_member""project_member"project_member*Type-specific input for a project_member invitation.
The invitation was created, with its one-shot link.
application/json- response
The created project-member invitation and its one-shot link. Only this response returns the link; later reads never include it.
id*invitation-idThe invitation ID (inv_<opaque>): the id that createInvitation
(POST /invitations) returns or listInvitations (GET /invitations) lists.
^[a-zA-Z0-9_-]+$project_id*project-id^[a-zA-Z0-9_-]+$metadata?|Who the administrator said the link is for. Null after accept; a decline keeps it. Cancel and replace delete the row.
status*InvitationStatusLifecycle status of the invitation. expired is derived on read from
expires_at; accepted and rejected are final. Cancel and replace delete
the row rather than leaving a cancelled status.
"pending""accepted""rejected""expired"created_by?|The user who created the invitation. Null when a project secret created
it (created_by_type is then service).
created_by_type?|What kind of principal created_by names.
created_at*stringWhen the invitation was created.
date-timeexpires_at*stringWhen the invitation expires (72 hours after create).
date-timejourney_id*stringCorrelates this invitation with its replacements. A replacement keeps the
original's journey_id. It is a random correlation id, not a resource id.
1 <= lengthresponded_by?|The user who accepted or declined the link; status says which. Null
while the invitation is pending or expired.
responded_at?|When the invitation was accepted or declined. Null while it is pending or expired.
inviter?|The user who created the invitation, resolved for display: render
display, falling back to identifier, then user_id. Present only
when listInvitations is called with expand=inviter; null when a
project secret created the invitation.
type*"project_member""project_member"project_member*Type-specific input for a project_member invitation.
link*stringThe browser URL to share. It carries the redeem token in the fragment. Only this create or replace response returns it.
import { configureZitadel, getApi } from "@zitadel/api/config";import { setApiCsrfToken } from "@zitadel/api/runtime/auth";// In the browser, through the SDK proxy: the session cookie authenticates the call.const client = getApi(configureZitadel({ projectId: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5" }));// A write the session cookie authenticates carries the session's CSRF token.setApiCsrfToken((await client.getMySessionCsrfToken()).csrf_token);const invitation = await client.createInvitation( { type: "project_member", project_member: { relation: "viewer" }, metadata: { name: "John Doe" }, }, { project_id: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5" },);{ "id": "string", "project_id": "string", "metadata": { "name": "string" }, "status": "pending", "created_by": "string", "created_by_type": "human", "created_at": "2019-08-24T14:15:22Z", "expires_at": "2019-08-24T14:15:22Z", "journey_id": "string", "responded_by": "string", "responded_at": "2019-08-24T14:15:22Z", "inviter": { "user_id": "string", "identifier": "string", "identifier_property": "string", "display": "string" }, "type": "project_member", "project_member": { "relation": "viewer" }, "link": "string"}Was this helpful?