Docs

Decline an invitation

POST
/invitations/reject

Declines a pending invitation for the signed-in user and returns the updated invitation with status rejected.

Send the plaintext token from the invitation link fragment. The invitation keeps its metadata for administrators, but this response returns metadata as null. The inviter cannot decline their own invitation; an administrator cancels it instead. Every unknown or finished token answers the same opaque 404. Authenticate with a platform-project user session cookie (sessionCookie). Cookie requests follow that scheme's CSRF rules.

Authorization

sessionCookie
cookie__Host-zitadel_session<token>

The session cookie issued at session creation or superseding handoff exchange.

A browser holds it as __Host-zitadel_session, with Secure. Over plain http to a loopback host (localhost, 127.0.0.1, ::1) the server sets it as zitadel_session instead, without Secure or the prefix, so that Safari keeps it, and accepts that name there too; __Host-zitadel_session takes precedence. A program sends __Host-zitadel_session over any transport.

A missing or invalid cookie yields 401 with code auth.unauthorized and the message Missing or invalid session token.

Cross-site request forgery (CSRF) protection: a state-changing request that this cookie authenticates must come from the same origin. A cross-site browser request is refused with 403 and code auth.csrf_invalid. Every such request must also send the session's token from GET /sessions/me/csrf in the X-Zitadel-CSRF header, or it answers the same 403. The only exceptions are the POST …/query reads and POST /invitations/lookup, which need no token. Safe methods (GET) are not checked. A request a project secret authenticates is not affected.

Request Body

application/json
  1. body

The redeem token from an invitation link's fragment.

token*string

The plaintext token from the invitation link fragment. It never appears in a URL query. Every unknown or finished token gets the same 404.

Length1 <= length

Response Body

The invitation was declined.

application/json
  1. response

An invitation that grants a project role (viewer, editor or admin) to whoever redeems its link.

id*invitation-id

The invitation ID (inv_<opaque>): the id that createInvitation (POST /invitations) returns or listInvitations (GET /invitations) lists.

Match^[a-zA-Z0-9_-]+$
project_id*project-id
Match^[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*InvitationStatus

Lifecycle 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.

Value in"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*string

When the invitation was created.

Formatdate-time
expires_at*string

When the invitation expires (72 hours after create).

Formatdate-time
journey_id*string

Correlates this invitation with its replacements. A replacement keeps the original's journey_id. It is a random correlation id, not a resource id.

Length1 <= length
responded_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"
Value in"project_member"
project_member*

Type-specific input for a project_member invitation.

Example Request
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.rejectInvitation({ token: "string" });
Example Response
{  "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"  }}

Was this helpful?