Appearance
Tag: h
Overview
The h
tag identifies a group in the relay-based groups system. It serves as the primary identifier for group membership and allows events to be associated with specific groups.
Specification
Property | Value |
---|---|
Tag Name | h |
Defined in | NIP-29 |
Required for | Events sent to relay-based groups (kinds 9000-9022 and any user-created content within groups) |
Format
["h", "<group-id>"]
Usage Description
The h
tag contains the group identifier, which should be a string restricted to the characters a-z0-9-_
. Group IDs should preferably be random to avoid name collisions.
Events sent by users to groups (chat messages, text notes, moderation events, etc.) MUST have an h
tag with the value set to the group ID.
Group identifiers may also be expressed in the format <host>'<group-id>
. For example, a group with ID abcdef
hosted at the relay wss://groups.nostr.com
would be identified by the string groups.nostr.com'abcdef
.
When encountering just the <host>
without the '<group-id>
, clients MAY infer _
as the group ID, which is a special top-level group dedicated to relay-local discussions.
Examples
Basic Example
json
["h", "vegans-united"]
Extended Example with Host Identifier
json
["h", "groups.nostr.com'vegans-united"]
Client Behavior
Clients should include the h
tag in all events sent to groups, including:
- Group management events (kinds 9000-9009)
- Group join/leave requests (kinds 9021-9022)
- Content events posted to the group (notes, messages, etc.)
When displaying group content, clients should filter events based on the h
tag to show only content relevant to the current group.
Relay Behavior
Relays should:
- Use the
h
tag to associate events with specific groups. - Validate that group management events come from authorized users based on the group ID in the
h
tag. - Apply group-specific policies (such as membership restrictions) based on the value of the
h
tag. - For unmanaged groups (groups without specific relay support), still respect the
h
tag for basic filtering.
References
Related Tags
- Tag: d - Used in the group metadata events (kind 39000, 39001, 39002, 39003)
- Tag: p - Used to reference users in group management events
- Tag: previous - Used for timeline references in group events
Notes
The h
tag differs from the d
tag in that h
is used in events sent to a group, while d
is used in the relay-generated events that describe group metadata (kinds 39000-39003).
In unmanaged groups (impromptu groups without explicit relay support for NIP-29), the h
tag is the primary mechanism for categorizing events by group.