Skip to content

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

PropertyValue
Tag Nameh
Defined inNIP-29
Required forEvents 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:

  1. Group management events (kinds 9000-9009)
  2. Group join/leave requests (kinds 9021-9022)
  3. 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:

  1. Use the h tag to associate events with specific groups.
  2. Validate that group management events come from authorized users based on the group ID in the h tag.
  3. Apply group-specific policies (such as membership restrictions) based on the value of the h tag.
  4. For unmanaged groups (groups without specific relay support), still respect the h tag for basic filtering.

References

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