Skip to content

Kind 9009: Group Invite Creation ​

Overview ​

This event is used to create an invitation code for a closed group. The invitation code can then be shared with specific users to allow them to join the group without requiring manual approval of their join request.

Specification ​

PropertyValue
Kind Number9009
Event RangeRegular
Defined inNIP-29

Content Format ​

The content field can contain an optional description or context for the invitation.

Schema ​

"optional description"

Tags ​

Tag NameDescriptionFormatRequired
hGroup identifier["h", "<group-id>"]Yes
codeInvite code["code", "<invite-code>"]No
limitUsage limit["limit", "<number-of-uses>"]No
expiresExpiry timestamp["expires", "<unix-timestamp>"]No
previousTimeline references["previous", "<event-id-prefix>"]No, but recommended

Client Behavior ​

Clients with appropriate permissions can send this event to create an invitation code for a closed group. The client should include the group ID in the h tag and can optionally specify an invite code, usage limit, and expiry time.

If the code tag is not provided, the relay will typically generate a random code.

Clients should include timeline references in the previous tag to prevent messages from being used out of context.

Relay Behavior ​

Relays should validate that:

  1. The sender has the appropriate permissions to create invites for the group.
  2. The event contains a valid h tag with the group ID.
  3. The timeline references in the previous tag, if present, refer to events in the relay's database.

If validation succeeds, the relay should:

  1. Generate an invite code if not provided in the event.
  2. Store the invite code along with any specified limitations (usage limit, expiry time).
  3. Allow users who provide this code in a kind 9021 join request to automatically join the group.

Use Cases ​

  • Creating invitation links to share with specific individuals.
  • Setting up limited-use invitations for special events or promotions.
  • Implementing time-limited invitation windows for group enrollment periods.

Example ​

json
{
  "id": "...",
  "pubkey": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "created_at": 1671217411,
  "kind": 9009,
  "tags": [
    ["h", "vegans-united"],
    ["code", "PIZZA2023"],
    ["limit", "10"],
    ["expires", "1672422000"],
    ["previous", "a1b2c3d4"]
  ],
  "content": "Creating a limited-use invite code for our pizza making workshop participants",
  "sig": "..."
}

References ​

Notes ​

The event should only be accepted by relays if it comes from a user with appropriate permissions (e.g., a group admin with the capability to create invites).

The invite code can be used in conjunction with kind 9021 (join request) events, where users can include the code in the code tag to gain automatic admission to closed groups.