> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opigno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Invite a user to the community

Any user associated with the community (the owner or a member) can invite other users from their network to the community.

<Note>
  Members can invite others only to the public communities.

  Users associated with the `ADMINISTRATOR` scope can invite to the community **any user**, not only the ones from their network.
</Note>

## Community invitation object

Community invitations enhance social engagement by allowing users to invite other users from their network to join communities.

| Parameter              | Type                                                        | Description                                                                                          |
| :--------------------- | :---------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- |
| `id`                   | `ID`                                                        | **Required**. ID of the community invitation entity.                                                 |
| `initiatorUserContext` | [`UserContext`](/OpignoEnterpriseAPI/UserContextManagement) | **Required**. The loaded user context associated with the user who created the community invitation. |
| `inviteeUserContext`   | [`UserContext`](/OpignoEnterpriseAPI/UserContextManagement) | **Required**. The loaded user context associated with the invitee.                                   |
| `community`            | [`Community`](/OpignoEnterpriseAPI/Community/GetCommunity)  | **Required**. Community that is related to the invitation.                                           |
| `created`              | `Int`                                                       | **Required**. Timestamp when the community invitation was created.                                   |
| `cta`                  | `Cta`                                                       | The list of the available [CTA](#community-invitation-cta).                                          |

## Community invitation CTA

| Action ID                      | Description                                                                                                                                | Corresponding mutation                                                                                                       |
| :----------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| `ACCEPT_COMMUNITY_INVITATION`  | Available for the user associated with the invitee context. Allows to accept the invitation and, as a result, become the community member. | [`acceptCommunityInvitation`](/OpignoEnterpriseAPI/Community/AcceptDeclineCommunityInvitation#accept-community-invitation)   |
| `DECLINE_COMMUNITY_INVITATION` | Available for the user associated with the invitee context. Allows to decline the given community invitation.                              | [`declineCommunityInvitation`](/OpignoEnterpriseAPI/Community/AcceptDeclineCommunityInvitation#decline-community-invitation) |
| `CANCEL_COMMUNITY_INVITATION`  | Available for the user associated with the community owner context. Allows to cancel the given community invitation.                       | [`cancelCommunityInvitation`](/OpignoEnterpriseAPI/Community/AcceptDeclineCommunityInvitation#cancel-community-invitation)   |

## Create a community invitation

To invite a new member, the `createCommunityInvitation` mutation should be executed. It accepts the following arguments:

| Argument                 | Type | Description                                                         |
| :----------------------- | :--- | :------------------------------------------------------------------ |
| `communityId`            | `ID` | **Required**. ID of the community to invite a user.                 |
| `inviteeUserContextUuid` | `ID` | **Required**. The user context UUID to be invited to the community. |

<CodeGroup>
  ```filename GraphQL theme={null}
    mutation createCommunityInvitation {
      createCommunityInvitation(communityId: 2, inviteeUserContextUuid: "a1b2c3d4-e5f6-7890-abcd-ef1234567890") {
        errors
        response {
          id,
          community {
            id
          },
          created,
          cta {
            actionId
            arguments {
              key
              value
            }
          }
        }
      }
    }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "createCommunityInvitation": {
        "errors": [],
        "response": {
          "id": "1",
          "community": {
            "id": 2
          },
          "created": 1757153736,
          "cta": [
            {
              "actionId": "CANCEL_COMMUNITY_INVITATION",
              "arguments": [
                {
                  "key": "communityId",
                  "value": "2"
                }
              ]
            }
          ]
        }
      }
    }
  }
  ```
</CodeGroup>

After the successful mutation execution, the community invitation will be created.
Then it can be [accepted](/OpignoEnterpriseAPI/Community/AcceptDeclineCommunityInvitation#accept-community-invitation)
or [declined](/OpignoEnterpriseAPI/Community/AcceptDeclineCommunityInvitation#decline-community-invitation) by the invitee
or [cancelled](/OpignoEnterpriseAPI/Community/AcceptDeclineCommunityInvitation#cancel-community-invitation) by the community owner
or users associated with the `ADMINISTRATOR` scope, if it was not accepted yet.
